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.

MSP432E401Y: AWS IoT Certificates

Part Number: MSP432E401Y

Hi, 

the certs.c file in the example code provided for the AWS IOT plugin looks like the following :

 

/*
 *  ======== certs.c ========
 */

/*
 * USER STEP: Copy the lines in the root CA certificate file
 *
 *            Paste the lines in string format for the following array:
 */
unsigned char root_ca_pem[] = "";

unsigned int root_ca_pem_len = sizeof(root_ca_pem);

/*
 * USER STEP: Copy the lines in the cert.pem certificate file
 *
 *            Paste the lines in string format for the following array:
 */
unsigned char client_cert_pem[] = "";

unsigned int client_cert_pem_len = sizeof(client_cert_pem);

/*
 * USER STEP: Copy the lines in the privateKey.pem certificate file
 *
 *            Paste the lines in string format for the following array:
 */
unsigned char client_private_key_pem[] = "";

unsigned int client_private_key_pem_len = sizeof(client_private_key_pem);

I have tried pasting the certs into the code from AWS IoT core and I am unable to connect. Error is : "getaddrinfo returned -3126"

I was wondering, how do I past these certificates, I am currently pasting them like the following : 

unsigned char root_ca_pem[] =  "-----BEGIN CERTIFICATE-----"
"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
"-----END CERTIFICATE-----";

unsigned char client_cert_pem[] = "-----BEGIN CERTIFICATE-----"
"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
"-----END CERTIFICATE-----";

unsigned char client_private_key_pem[] =  "-----BEGIN RSA PRIVATE KEY-----"
"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
"-----END RSA PRIVATE KEY-----";

Any help with this would be appreciated. This is the SDK I am using : www.ti.com/.../SIMPLELINK-SDK-PLUGIN-FOR-AWSIOT

  • Hi Adam,

    Let me see if I can find help from an expert on this topic.

  • Hi,

    I am investigating your issue, and will need an additional day before I can give you a substantial response. I appreciate your patience.

    Regards,

    Michael

  • Thanks, I look forward to your response. 

  • Hi,

    I don't think your cert formatting is correct. You might be missing endline characters that you will need to add to your array. Please see this example for how the Starfield Class 2 Certification Authority root ca cert would be formatted:

    unsigned char root_ca_pem[] =
    "-----BEGIN CERTIFICATE-----\r\n"
    "MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzEl\r\n"
    "MCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMp\r\n"
    "U3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQw\r\n"
    "NjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBoMQswCQYDVQQGEwJVUzElMCMGA1UE\r\n"
    "ChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZp\r\n"
    "ZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqGSIb3\r\n"
    "DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf\r\n"
    "8MOh2tTYbitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN\r\n"
    "+lq2cwQlZut3f+dZxkqZJRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0\r\n"
    "X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVmepsZGD3/cVE8MC5fvj13c7JdBmzDI1aa\r\n"
    "K4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSNF4Azbl5KXZnJHoe0nRrA\r\n"
    "1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HFMIHCMB0G\r\n"
    "A1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fR\r\n"
    "zt0fhvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0\r\n"
    "YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBD\r\n"
    "bGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8w\r\n"
    "DQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGsafPzWdqbAYcaT1epoXkJKtv3\r\n"
    "L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLMPUxA2IGvd56D\r\n"
    "eruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl\r\n"
    "xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynp\r\n"
    "VSJYACPq4xJDKVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEY\r\n"
    "WQPJIrSPnNVeKtelttQKbfi3QBFGmh95DmK/D5fs4C8fF5Q=\r\n"
    "-----END CERTIFICATE-----";

    Please ensure that your certs are formatted as above, and let me know if you still encounter issues when trying to connect to AWS.

    Regards,

    Michael

  • Still testing but this didnt work. 

    From what I can see, string format will be only \n at the end of every line, including the end certificate line.

  • Okay, I have managed to break past some of the issues I was having before but there doesn't seem to be much help for the issue I am getting now. 

    The following is the function that the code is failing on. 

    int32_t SlNetSock_startSec(int16_t sd, SlNetSockSecAttrib_t *secAttrib, uint8_t flags)
    {
        int32_t    retVal = SLNETERR_RET_CODE_OK;
        int16_t    realSd;
        uint8_t    sdFlags;
        SlNetIf_t *netIf;
        void      *sdContext;
    
        /* Check if the sd input exists and return it                            */
        retVal = SlNetSock_getVirtualSdConf(sd, &realSd, &sdFlags, &sdContext, &netIf);
    
        /* Check if sd found or if the non mandatory function exists             */
        if (SLNETERR_RET_CODE_OK != retVal)
        {
            return retVal;
        }
        if (NULL == (netIf->ifConf)->sockstartSec)
        {
            /* Non mandatory function doesn't exists, return error code          */
            return SLNETERR_RET_CODE_DOESNT_SUPPORT_NON_MANDATORY_FXN;
        }
        /* StartSec function called, set bit                                     */
        sdFlags |= flags;
        /* Function exists in the interface of the socket descriptor, dispatch
           the startSec command                                                  */
        retVal = (netIf->ifConf)->sockstartSec(realSd, sdContext, secAttrib, flags);
        SLNETSOCK_NORMALIZE_RET_VAL(retVal,SLNETSOCK_ERR_SOCKSTARTSEC_FAILED);
    
        return retVal;
    }
    

    When it runs the following function, it returns non mandatory function doesnt exist

        if (NULL == (netIf->ifConf)->sockstartSec)
        {
            /* Non mandatory function doesn't exists, return error code          */
            return SLNETERR_RET_CODE_DOESNT_SUPPORT_NON_MANDATORY_FXN;
        }

    Any help would be appreciated. Cheers.

    Adam 

  • An update on this, I am getting an overflow when using SlNetSock_secAttribCreate()

    Error remains : SlNetSock_startSec retruned -2021 as described 2 posts up. 

    Any help would be greatly appreciated getting this integrated. 

    Cheers,

    Adam 

  • Hi Adam,

    To clarify, are you trying to run the AWS IoT plugin on top of the MSP432E4 ethernet stack? I was somehow under the impression that you were using the CC31xx Wi-Fi device interfaced with the MSP432E4 as a host device. The needed debug steps are different depending on what device you use, and so far I have been providing instructions for the CC31xx.

    Regards,

    Michael

  • Hi Michael, 

    The part number is in my first post. I am using the MSP432E401Y connected via Ethernet. 

    Can you have a look at the stack as I seem to be getting a memory failure issue. Can you look into this with some real certificates and see if you are getting the same issue?

    I have done nothing but what is instructed in the manual. 

    All the best,

    Adam 

  • Here is what my serial terminal says : 

    Service Status: DHCPC    : Enabled  :          : 000
    
    
    
    Service Status: DHCPC    : Enabled  : Running  : 000
    
    
    
    Starting the AWS IoT example application
    
    
    
    Network Added: 
    
    If-1:10.30.30.25
    
    
    
    Service Status: DHCPC    : Enabled  : Running  : 017
    
    
    
    startSNTP: Current time: Mon Jun 21 20:44:06 2021
    
    
    
    
    
    AWS IoT SDK Version 3.0.1-
    
    
    
    
    
    
    Connecting...
    
    
    
    
    ERROR: iot_tls_connect L#250 
    
    SlNetSock_startSec retruned -2021
    
    
    
    
    
    
    ERROR: runAWSClient L#142 
    
    Error(-4) connecting to a3tbnoe8hq38io-ats.iot.us-west-2.amazonaws.com:8883
    
    
    
    
    Subscribing...
    
    
    
    
    ERROR: runAWSClient L#160 
    
    Error subscribing : -13 
    
    
    
    
    ERROR: runAWSClient L#221 
    
    An error occurred in the loop. Error code = -13