Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue on MQTT with TLS on MKR1000 #293

Open
mdelain opened this issue Jun 3, 2020 · 0 comments
Open

Issue on MQTT with TLS on MKR1000 #293

mdelain opened this issue Jun 3, 2020 · 0 comments

Comments

@mdelain
Copy link

mdelain commented Jun 3, 2020

Hi guys,

I'm currently writing code samples for the MKR family - using my intermediate dev skills. I've successfully managed to connect using SSL on MKR NB, now I'm porting the code on MKR1000.

I'm trying to connect to Live Objects, and I'm having trouble with TLS on MKR1000.

I've been trying a bare sketch (from the ArduinoMQTTClient examples) to test the connection (below), and the MQTT client gives up with a -2 error code (connection refused). Working just fine without the WiFiSSLClient.

Usually, the cert is not included in the default set (it's the DigiCert Global Root CA). The certificate to use is RSA 2048 / SHA (256 but not sure: available here + screenshot below). However I don't really know if the correct cert is uploaded in the chip when using the FW update utility, as you can only provide the server URL (maybe it's getting the cert from the the homepage...).

I didn't find any cert files in the WiFi101 lib to tweak, which could have been a workaround (not so easily reproducible for beginners).

Also, the server documentation says:

MQTTS endpoint supports
-TLS v1.2 (recommended)
-TLS v1.1 (deprecated)
-TLS v1 (deprecated)

NB: Even if deprecated, TLS v1 and v1.1 are still functional.

MQTTS endpoint supports the following cipher suites:
-TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 for TLS v1.2 only (recommended)
-TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
-TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
-TLS_RSA_WITH_AES_128_GCM_SHA256 for TLS v1.2 only
-TLS_RSA_WITH_AES_128_CBC_SHA
-TLS_RSA_WITH_AES_256_CBC_SHA

Based on this elements and the capabilities of the latest Wi-Fi FW (I'm using version 19.6.1), should the library and MKR1000 be handle the connection?

Any help much appreciated ;)

#include <ArduinoMqttClient.h>
#include <WiFi101.h>
#include "arduino_secrets.h"

WiFiSSLClient wifiClient;
MqttClient mqttClient(wifiClient);

const char broker[] = "liveobjects.orange-business.com";
int        port     = 8883;

void setup() {
  Serial.begin(9600);
  
  Serial.println("Attempting to connect to Wi-Fi");
  while (WiFi.begin(SECRET_SSID, SECRET_PASS) != WL_CONNECTED) {
    Serial.print(".");
    delay(5000);
  }

  Serial.println("You're connected to the network");
  Serial.println();
  
  mqttClient.setId("MKR1000");
  mqttClient.setUsernamePassword("json+device", SECRET_MQTT_PASS);

  Serial.print("Attempting to connect to the MQTT broker: ");
  Serial.println(broker);

  if (!mqttClient.connect(broker, port)) {
    Serial.print("MQTT connection failed! Error code = ");
    Serial.println(mqttClient.connectError());
    while (1);
  }
  
  Serial.println("You're connected to the MQTT broker!");
  Serial.println();
}

void loop() {
  mqttClient.poll();
  delay(1000);
}

cert_info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant