This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC3200-LAUNCHXL: MQTT+TLS connection failure with the server

Part Number: CC3200-LAUNCHXL
Other Parts Discussed in Thread: CC3200, UNIFLASH

Hi,

      • I'm currently using TI's CC3200 Launchpad as a part of a project that uses MQTT to connect securely to AWS IOT broker.
      • Im using FreeRTOS (not TI_RTOS) and successfully tested FreeRTOS_Demo and WLAN_station example applications that comes with the SDK
      • I then moved into the MQTT_Client example and succesfully connected to "iot.eclipse.org" without security.
      With all these verified, I started modifying the same 

with security

      (before moving into AWS broker) by doing the following :-
    • Downloaded the DST root CA certificate by openssl command : openssl s_client -showcerts -CApath /etc/ssl/certs/ -connect iot.eclipse.org:8883 
    • After I typed this command, 2 certificates were printed on the terminal window and I chose the one which said i:/O=Digital Signature Trust Co./CN=DST Root CA X3 and copy pasted the certificate as seen on the terminal windows (starting with BEGIN CERTIFICATE and ending with END CERTIFICATE) into a .pem file . (Am I wrong here itself ? )
    • From other forums,I understood that the certificate needs to be flashed in .der format, so converted the .pem file into .der using the command openssl x509 -outform der -in certificate.pem -out certificate.der
    • The DER file was flashed into the serial Flash of CC3200 using the UNIFLASH TOOL. I didn't find much documentation on how to add a certificate into a particular location but I figured it out that by using the option 'ADD FILES', one could add a file into any location, so I did add my .der file to the location with the name field as /certs/dst.der and checking the options Erase, update and verify and finally it was successfully programmed into the flash. ( Am I wrong here too ?)

Now, coming back to the program, the following changes were made based on this https://e2e.ti.com/support/wireless_connectivity/simplelink_wifi_cc31xx_cc32xx/f/968/p/417213/2212382?tisearch=e2e-sitesearch&keymatch=mqtt%20secure#2212382

#define SERVER_ADDRESS "iot.eclipse.org" //No change btw
#define PORT_NUMBER 8883  

#define SL_SSL_CA_CERT "/cert/dst.der"
char *security_file_list[4] = {NULL,NULL,SL_SSL_CA_CERT,NULL};

/* connection configuration */
connect_config usr_connect_config[] =
{
{
{
{
SL_MQTT_NETCONN_URL|SL_MQTT_NETCONN_SEC,
SERVER_ADDRESS,
PORT_NUMBER,
SL_SO_SEC_METHOD_SSLv3_TLSV1_2,
SL_SEC_MASK_SECURE_DEFAULT,
4,
security_file_list
},
SERVER_MODE,
true,
},
NULL,
"uusseerr",
NULL,
NULL,
true,
KEEP_ALIVE_TIMER,
{Mqtt_Recv, sl_MqttEvt, sl_MqttDisconnect},
TOPIC_COUNT,
{TOPIC1, TOPIC2, TOPIC3},
{QOS2, QOS2, QOS2},
{WILL_TOPIC,WILL_MSG,WILL_QOS,WILL_RETAIN},
false
}
};

Running this I get the following Error as seen in Tera term

Host Driver Version: 1.0.0.10
Build Version 2.4.7.2.31.1.3.4.1.1.5.3.34
Device is configured in default state
Started SimpleLink Device: STA Mode
[WLAN EVENT] STA Connected to the AP: PWIFI , BSSID: 8:86:3b:d7:cd:da
[NETAPP EVENT] IP acquired by the device

Device has connected to PWIFI
Device IP Address is 192.168.2.172

Time set to : 15/03/2018 00:10:30
Version: Client LIB 1.0.3, Common LIB 1.1.1.
Blocking an network for (finite) 30 secs to monitor 1 fd(s)

ERROR: Could not establish connection to server.

ERROR: Closing the socket.

Broker connect fail for conn no. 1

Exiting the Application

I tried changing the cipher suites but it was of no use . Where did it possibly go wrong ?

[SDK version is 1.1.0 and service pack version is 1.0.0.10.0]

  • Hi Akshay,

    I have replicated the problem, and believe that the issue is with the root CA cert.
    iot.eclipse.org seems to require the DST Root CA X3 cert, but I'm still debugging why it won't work despite passing in what should be the correct cert.

    I'll keep debugging this and will inform you when I find how to get the mqtt client connecting with the correct certificate.

    Regards,
    Michael
  • Hi Michael,

    Yes , you are correct. It's the problem with the root CA certificate and I sorted it out.

    The problem is, the DST Root CA certificate was already present in the directory /etc/ssl/certs/ in a .pem format. I converted that into .der ,flashed it using Uniflash and voilà, it worked.

    The only work left for me is to connect to AWS IOT Broker, which requires a client certificate and private key in addition to the CA certificate. I already had these with me , and I used the same method, but it didn't work (showed Broker connect fail for conn 1).  Maybe, it is again the issue with the certificates.

    I'll update when I get that going :). Any other suggestions guys ?(for connecting to AWS IOT server)

  • Hi Akshay,

    Glad you sorted out the problem with the root CA.
    For AWS IoT development, this wiki page is a good reference:
    processors.wiki.ti.com/.../AWS_IoT_Development
    You'll probably want to use TI's provided AWS IoT SDK, since it helps you take advantage of AWS IoT features and capabilities such as device shadows.

    It should be possible to AWS IoT using the barebones MQTT example that you're currently using. Other than double-checking the certificates, I would also look at the device config on the AWS side and make sure that you have your thing policy with open permissions linked to your thing. Looking online, this site seems to have a good explanation of what to look for:
    www.hackster.io/.../connecting-amazon-aws-iot-with-python-on-windows-fc3ca5
    You could give that a shot and see if it works. However, I would still advise using TI's AWS IoT SDK.

    Let me know if you need more help or if you have additional questions.

    Regards,
    Michael
  • Hi Michael,

    Thanks for your help. I was finally able to connect to AWS IOT server using the barebones MQTT example.
    Two factors acted as an impediment : One was the QoS, which is by default 2 and that value isn't supported by AWS, so made it to 1 (or 0), secondly the conversion of private key (in .key format) to .der was done incorrectly.

    Regards,
    Akshay