title: Lua SSL certificate and Azure Iot hub
body: <p>I am trying to connect my NodeMCU ESP-12N to Azure IoT hub. </p>
  
  <p>I have created client with code like this:</p>
  
  <pre><code>esp8266 = mqtt.Client(DEVICE, 240, USER, PASSWD)
  </code></pre>
  
  <p>and receiving error on calling esp8266:connect</p>
  
  <blockquote>
    <p>PANIC: unprotected error in call to Lua API (init.lua:127: ssl not
    available)</p>
  </blockquote>
  
  <p>When I previously have connect my Arduino, then it was important to flash Wi-Fi with SSL certificate. However I can't do it with NodeMCU (or more right to say - don't know how). </p>
  
  <p>I can get certificates with:</p>
  
  <pre><code>openssl s_client -showcerts -connect ArduinoDemoHub.azure-devices.net:8883
  </code></pre>
  
  <p>When I have add (thank you @MarcelStör for hint, I have tried previously net.cert.verify)</p>
  
  <pre><code>tls.cert.verify([[
  -----BEGIN CERTIFICATE-----
  MIIGsTCCBJmgADJKJFdWgAIQF5Koy/50vI3cQAAAAhAXjANBgkqhkiG9w0BAQsF
  ......
  lz3ZDUcyzRgG6TRtA3SjASEUlJMt3f7xuI2nNpt8p5gy9pXuRw==
  -----END CERTIFICATE-----
  ]])
  
  tls.cert.verify(true)
  </code></pre>
  
  <p>I'v received another error:</p>
  
  <blockquote>
    <p>Error Connecting: -5</p>
  </blockquote>
  
  <p><strong>UPDATE</strong>:
  There is <a href="https://stackoverflow.com/questions/41834637/trouble-connecting-nodemcu-to-microsoft-azure-iot-hub">another similar topic</a>, and I have set time, but still without result.</p>
  
  <p><strong>UPDATE 2</strong>:
  Here are some links that I trying to use:</p>
  
  <p><a href="https://maxwellweru.com/use-azure-iot-hub-without-client-libraries-mqtt/" rel="nofollow noreferrer">Use Azure IoT Hub without client libraries (MQTT)</a></p>
  
  <p><a href="http://thinglabs.io/workshop/esp8266/sending-d2c-messages/" rel="nofollow noreferrer">Sending Device-to-Cloud (D2C) Messages</a></p>
  
  <p><a href="https://github.com/sankarcheppali/NodeMCUProjects" rel="nofollow noreferrer">sankarcheppali gitHub with samples</a></p>
  
  <p>Here is official Link
  <a href="https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-mqtt-support" rel="nofollow noreferrer">Communicate with your IoT hub using the MQTT protocol</a>
   that tells:</p>
  
  <blockquote>
    <p>To use the MQTT protocol directly, your client must connect over
    TLS/SSL. Attempts to skip this will fail with connection errors.</p>
  </blockquote>
  
  <p>This link also provides username that is different from old code samples: </p>
  
  <pre><code>{iothubhostname}/{device_id}/api-version=2016-11-14
  </code></pre>