You are reading a single comment by @lukevanhorn and its replies. Click here to read the full conversation.
  • It works!

    I tried your suggestion of deleting the keys after initiating the connection.

    Updated code example:

    SPI3.setup({ mosi:B5, miso:B4, sck:B3 });
    var eth = require("WIZnet").connect(SPI3, A8);
    eth.setIP();
    eth.getIP();
    
    var options = url.parse("mqtt://A1XXXXXXXXX9AA.iot.us-­east-1.amazonaws.com:8883");
    options.key = atob("MIIEow ... d4/IvHs");
    options.cert = atob("MIIDWj ... +NrCQ==");
    options.ca = atob("MIIE0z ... dao7WNq");
    
    var mqtt = require("MQTT").create();
    mqtt.on("connected", function() {
      console.log("connected to AWS IoT...");
      mqtt.subscribe("test/topic");
    });
    
    mqtt.on("publish", function (pub) {
      console.log("\r\nnew message received: ");
      console.log("topic: "+pub.topic);
      console.log("message: "+pub.message);
    });
    
    require("tls").connect(options, function(res) {
      console.log("tls connected");
      mqtt.connect(res);
    });
    
    delete options.key;
    delete options.cert;
    delete options.ca;
    

    And the results:

    Connecting with TLS...
    Loading the CA root certificate...
    Loading the Client certificate...
    Loading the Client Key...
    Performing the SSL/TLS handshake...
    tls connected
    Client connected
    =undefined
    >Verifying peer X.509 certificate...
    MQTT connection accepted
    connected to AWS IoT...
    >
    new message received:
    topic: test/topic
    message: hello world!
    

    The 'hello world' message was published from another client application.

    Exciting! Thanks for making this happen so quickly.

About

Avatar for lukevanhorn @lukevanhorn started