Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Support for ALPN in Mosquitto #924
To connect to AWS IOT Broker on port 443, one needs to specify the ALPN protocol for AWS i.e. “x-amzn-mqtt-ca”. Since currently there is no direct way to do this using the Mosquitto API client library, one needs to instantiate a SSL_CTX object instead of relying on the one Mosquitto internally creates. With this SSL_CTX it is possible to set the ALPN protocol using the OpenSSL API, SSL_CTX_set_alpn_protos. Once this is done, the Mosquitto client instance is initialized with this SS_CTX object using opts_set(mosq_opt_t::MOSQ_OPT_SSL_CTX, ...). This works. The problem is during reconnect , this bit of jugglery is not accounted for and hence reconnect fails. It would be a good feature to enable setting the ALPN protocol at the Mosquitto API which would in turn make it simpler to handle the reconnect scenarios. The alternative would be to consider that a developer might need to provide his own SSL_CTX object (for whatever reasons) and since Mosquitto does allow you to do so, it should also consider this during reconnect!