flightonary / Moscapsule

MQTT Client for iOS written in Swift
MIT License
273 stars 69 forks source link

Fixed crash when using password-protected private key file #59

Closed tefshuo closed 7 years ago

tefshuo commented 7 years ago

Noticed a crash (EXC_BAD_ACCESS) on the password callback (pw_callback in MosquittoCallbackBridge) when it tries to cast the userdata object. I passed in the password of the private key file via MQTTClientCert object on MQTTConfig.

Found the problem was that mosq was passed in as the userdata instead of mosq->userdata. See the diff.

Hope this makes sense! :)

Btw for completeness, here's how I encrypted the private key: $ openssl pkcs8 -topk8 -v2 des3 -in mqtt.key -out mqtt-encrypted.key

flightonary commented 7 years ago

thank you for your PR.