Other Parts Discussed in Thread: CC3100, MSP430F5529, CC3100SDK, CC31XXEMUBOOST, UNIFLASH
I am in the process of configuring CC3100 + MSP430F5529 Launch Pad to support TLS/SSL. For the purpose of experimentation I am trying to modify CC3100 HTTP Client example. I also have a CC31XXEMUBOOST which I used upload to certificates to serial flash. Current compiler version is TI v15.12.1 LTS, CC3100SDK version is 1.2 and CCS6.1. The files httpcli and ssock are reference CC3100SDK and not the http_lib from library_project_ccs. I have reviewed numerous posts with reference to CC3100 and TLS implementation on e2e.ti.com, but yet am unable to get the program working.
Questions:
- Can someone describe to process to enable HTTPCli_LIBTYPE_MIN flag to build the library as suggested on CC3100 HTTP Client
- The process of creating and flashing the certificate file to CC3100 serial flash.
Below some of what I have done per the research.
To set the HTTPCli_LIBTYPE_MIN flag, I went to Project Properties > CCS Build > MSP430 Compiler > Advanced Options > Predefine Symbols and added HTTPCli_LIBTYPE_MIN into the Pre-defined NAME section. I also noticed under Project Properties > C/C++ General > Paths and Symbols > #Symbol tab there is options to assign a value to HTTPCli_LIBTYPE_MIN. Should a value of 1 be assigned here?
I followed CCS/CC3100: CC3100 and added __SL__, _USE_CLI_ and __CCS__ macro. At a high level what is the purpose of these macros.
To generate the certificates I referenced CC3100 SSL Demo Application and CC3200 SSL Demo Application. I followed the usage section and CA Certificate from CC3200 SSL Demo Application.
Below is the ConnectToHTTPServer code. The call to HTTPCli_connect returns a -102 error code.
static _i32 ConnectToHTTPServer(HTTPCli_Handle httpClient) { _i32 retVal = -1; struct sockaddr_in addr; // Begin Secure Connect struct HTTPCli_SecureParams sparams; // END Secure Connect #ifdef USE_PROXY struct sockaddr_in paddr; paddr.sin_family = AF_INET; paddr.sin_port = htons(PROXY_PORT); paddr.sin_addr.s_addr = sl_Htonl(PROXY_IP); HTTPCli_setProxy((struct sockaddr *)&paddr); #endif // Begin Secure Connect SlDateTime_t dt; /* Set current Date to validate certificate */ dt.sl_tm_day = 18; dt.sl_tm_mon = 8; dt.sl_tm_year = 2017; dt.sl_tm_hour = 4; dt.sl_tm_min = 17; dt.sl_tm_sec = 0; sl_DevSet(SL_DEVICE_GENERAL_CONFIGURATION, SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME, sizeof(SlDateTime_t), (unsigned char *)(&dt)); // END Secure Connect /* Resolve HOST NAME/IP */ retVal = sl_NetAppDnsGetHostByName(HOST_NAME, pal_Strlen(HOST_NAME), &g_DestinationIP, SL_AF_INET); if(retVal < 0) { CLI_Write(" Device couldn't get the IP for the host-name\r\n"); ASSERT_ON_ERROR(retVal); } // Begin Secure Connect /* Set secure TLS connection */ /* Security parameters */ sparams.method.secureMethod = SL_SO_SEC_METHOD_TLSV1_2; sparams.mask.secureMask = SL_SEC_MASK_TLS_RSA_WITH_AES_256_CBC_SHA; //SL_SEC_MASK_SSL_RSA_WITH_RC4_128_SHA; //SL_SEC_MASK_TLS_RSA_WITH_AES_256_CBC_SHA; strncpy(sparams.cafile, SL_SSL_CA_CERT, sizeof(SL_SSL_CA_CERT)); sparams.privkey[0] = 0; sparams.cert[0] = 0; sparams.dhkey[0] = 0; HTTPCli_setSecureParams(&sparams); // END Secure Connect /* Set up the input parameters for HTTP Connection */ addr.sin_family = AF_INET; addr.sin_port = htons(HOST_PORT); addr.sin_addr.s_addr = sl_Htonl(g_DestinationIP); /* HTTPCli open call: handle, address params only */ HTTPCli_construct(httpClient); // retVal = HTTPCli_connect(httpClient, (struct sockaddr *)&addr, 0, NULL); retVal = HTTPCli_connect(httpClient, (struct sockaddr *)&addr, HTTPCli_TYPE_TLS, NULL); if (retVal < 0) { CLI_Write("Connection to server failed\n\r"); ASSERT_ON_ERROR(retVal); } CLI_Write(" Successfully connected to the server \r\n"); return SUCCESS; }
Through the debug process I noticed that in the error is occurring at
ret = connect(skt, sa, slen);
in httpcli.c file.
In summary I believe this might be a simple configuration issue. Appreciate you support to resolve this issue.
References: