Other Parts Discussed in Thread: UNIFLASH
Hi all,
I am attempting to connect to AWS IoT through an Enterprise WiFi network using the CC3200 SDK. I am not strictly following the AWS SDK, however, I did follow the instructions to flash my device certificates (generated within AWS). Now I have 5 files in the /cert/ folder: ca.pem and private.key for the Enterprise WiFi connection and ca.der, cert.der, and key.der for the AWS connection (as per the AWS SDKs README). I have confirmed this via output from Uniflash's List File System shown below:
[11:27:50] INFO: file start size fail total size filename
[11:27:50] INFO: index block [BLKs] safe [BLKs]
[11:27:50] INFO: ----------------------------------------------------------------------------
[11:27:50] INFO: N/A 0 5 N/A 5 FATFS
[11:27:50] INFO: 9 73 5 yes 10 /tmp/phy.cal
[11:27:50] INFO: 10 83 1 yes 2 /sys/stacfg.ini
[11:27:50] INFO: 11 5 33 yes 66 /sys/servicepack.ucf
[11:27:50] INFO: 12 71 1 no 1 /cert/ca.pem
[11:27:50] INFO: 13 72 1 no 1 /cert/private.key
[11:27:50] INFO: 20 99 1 no 1 /cert/ca.der
[11:27:50] INFO: 21 100 1 no 1 /cert/cert.der
[11:27:50] INFO: 22 101 1 no 1 /cert/key.der
(Note I have deleted several rows which I did not believe to be useful here).
My relevant C code looks like this:
method.secureMethod = SL_SO_SEC_METHOD_TLSV1_2; cipher.secureMask = SL_SEC_MASK_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256; certdir_ca = "/cert/ca.der"; certdir_cert = "/cert/cert.der"; certdir_key = "/cert/key.der"; iSocketID = sl_Socket(SL_AF_INET, SL_SOCK_STREAM, SL_SEC_SOCKET); lRetVal = sl_SetSockOpt(iSocketID, SL_SOL_SOCKET, SL_SO_SECMETHOD, (_u8 *)&method, sizeof(method)); lRetVal = sl_SetSockOpt(iSocketID, SL_SOL_SOCKET, SL_SO_SECURE_MASK, (_u8 *)&cipher, sizeof(cipher)); lRetVal = sl_SetSockOpt(iSocketID, SL_SOL_SOCKET, SL_SO_SECURE_FILES_CA_FILE_NAME, certdir_ca, strlen(certdir_ca)); lRetVal = sl_SetSockOpt(iSocketID, SL_SOL_SOCKET, SL_SO_SECURE_FILES_CERTIFICATE_FILE_NAME, certdir_cert, strlen(certdir_cert)); lRetVal = sl_SetSockOpt(iSocketID, SL_SOL_SOCKET, SL_SO_SECURE_FILES_PRIVATE_KEY_FILE_NAME, certdir_key, strlen(certdir_key)); lRetVal = sl_Connect(iSocketID, (SlSockAddr_t *)&Addr, sizeof(SlSockAddrIn_t));
I am using the CC3200 SDK v 1.3 as well as CCS v 7.2
EDIT: My problem is that I am able to connect to my enterprise WiFi network but not to AWS.
Questions
1. Is there anything obviously wrong with this code?
2. Also, is there any way to debug the output of sl_Connect()? The documentation merely says that a negative value indicates a failed connection but it would be nice to see the response from AWS to better understand the failure.