title: Connecting a Mosquitto MQTT C client to Azure IoT-hub
body: <p>As the title states, I'm having difficulties connecting my Mosquitto MQTT client (written in C) to my Azure IoT-hub. I've managed to connect to many different platforms before (e.g. Amazon EC2, ThingsBoard, TheThings.io, SierraWireless, ...), so I know my client is pretty solid.</p>
  
  <p>The difficulty here is the fact that I need some sort of certificate to be allowed to connect, and I'm not sure what I need to do this.</p>
  
  <p>I have added the following configuration in order to get this working:</p>
  
  <pre><code>mosquitto_opts_set(client, MOSQ_OPT_PROTOCOL_VERSION, "MQTT_PROTOCOL_V311");
  mosquitto_tls_set(client, "/home/ca-certificates.crt", NULL, NULL, NULL, NULL);
  mosquitto_tls_insecure_set(client, 1);
  mosquitto_tls_opts_set(client, 0, "tlsv1", NULL);
  mosquitto_username_pw_set(client, "hubname.azure-devices.net/deviceName", "SharedAccessSignature=SharedAccessSignature sr=hubname.azure-devices.net%2Fdevices%2FdeviceName&amp;sig=sigValue&amp;se=1553087157");
  </code></pre>
  
  <p>In the code above, "hubname", "deviceName" and "sigValue" are of course replaced with real values in my code.</p>
  
  <p>Can any of you point me to what I'm doing wrong, or what other configuration steps I need to take?</p>