title: Issues connecting to mosquitto broker with node mqtt client via SSL/TLS
body: <p>Helllo, I created a mosquitto broker via the eclipse docker image and recently followed this guide to add SSL/TLS support: <a href="http://www.steves-internet-guide.com/mosquitto-tls/" rel="nofollow noreferrer">http://www.steves-internet-guide.com/mosquitto-tls/</a>.</p>
  
  <p>When I am sshed in the VPS which is running the broker, I can use the command:</p>
  
  <pre><code>mosquitto_pub -h VPS_NAME -t test/topic -p 8883 --cafile ca.crt -m message -u BROKER_USERNAME -P BROKER_PASSWORD
  </code></pre>
  
  <p>and it publishes all fine and dandy. However when I run the same command on a local computer, I get the error: </p>
  
  <pre><code>'Unable to connect (Lookup error.).
  </code></pre>
  
  <p>I don't get any new logs from the broker container, so I think it's not even reaching the container. However when I run:</p>
  
  <pre><code>mosquitto_pub -h BROKER_IP_ADRESS -t test/topic -p 8883 --cafile ca.crt -m message -u BROKER_USERNAME -P BROKER_PASSWORD
  </code></pre>
  
  <p>I do get a response which is Error: A TLS error occured, and on my docker logs I get:</p>
  
  <pre><code>1583004287: New connection from LOCAL_IP_ADDRESS on port 8883.
  1583004287: OpenSSL Error: error:14037438:SSL routines:ACCEPT_SR_KEY_EXCH:tlsv1 alert internal error
  1583004287: OpenSSL Error: error:140370E5:SSL routines:ACCEPT_SR_KEY_EXCH:ssl handshake failure
  1583004287: Socket error on client &lt;unknown&gt;, disconnecting.
  </code></pre>
  
  <p>I am only able to get a sucessful publish send when I add the --insecure command to the publish however I want to make sure the client knows that it's talking to the right server so I don't think this is the right solution.</p>
  
  <p>In the end I want to run an mqtt client on a node application, I've tried this piece of code: </p>
  
  <pre><code>
  const fs = require('fs');
  
  const optionsz = {
    ca: [ fs.readFileSync(__dirname + '/ca.pem') ],
    host: 'BROKER_IP_ADDRESS',
    servername: 'VPS_NAME',
    port: 8883,
    rejectUnauthorized : false,
    username : 'BROKER_USERNAME', // mqtt credentials if these are needed to connect
    password : 'BROKER_PASSWORD',
    clientId : 'test',
    // Necessary only if the server's cert isn't for "localhost".
    checkServerIdentity: () =&gt; { return null; },
  };
  
  
  class MqttHandler {
    constructor() {
      this.mqttClient = null;
  
    };
  
  
    connect() {
      // Connect mqtt with credentials (in case of needed, otherwise we can omit 2nd param)
      this.mqttClient = mqtt.connect(this.host, optionsz);
  ...
  </code></pre>
  
  <p>when I run this i keep getting disconnect events, and on my docker logs i get:</p>
  
  <pre><code>1583004505: New connection from LOCAL_IP_ADDRESS on port 8883.
  1583004505: OpenSSL Error: error:140260FC:SSL routines:ACCEPT_SR_CLNT_HELLO:unknown protocol
  1583004505: Socket error on client &lt;unknown&gt;, disconnecting.
  </code></pre>
  
  <p>I am really confused on how to even tackle this issue, I've been able to connect to a broker without SSL/TLS protection, but I wanted to make my device communication more secure.
  Thank you for your time!</p>