Hello,
I'm having a hard time trying to connect trough an encrypted socket.
My final objective is to establish an MQTT_client connection through a TLS1.2 socket.
Currently I'm trying to use the TI ssl example to connect to www.google.com or to test.mosquitto.org, I've used all combination of ciphers and metods, flashed the correct CA file and even private key and certificate, and trying to connect to mosquitto via 8884 port.
I've followed the TI wiki to setup the environment for this example.
From the example I removed the command:
lRetVal = sl_SetSockOpt(iSockID, SL_SOL_SOCKET, \
SO_SECURE_DOMAIN_NAME_VERIFICATION, \
g_Host, strlen((const char *)g_Host));
because it always returns SL_ENOPROTOOPT (-92)
I'm under linux fedora24 so to download google certificate I followed the wiki procedure exporting it from chrome, when I try to connect using the function sl_Connect(), it returns the error SL_ESEC_PROTOCOL_VERSION (-370)
Using different combinations of methods and ciphers sometimes I receive the error SL_ESEC_HANDSHAKE_FAILURE (-340).
Therefore I tried the same example configuring it for the server test.mosquitto.org:
- SERVER_NAME "test.mosquitto.org"
- GOOGLE_DST_PORT 8883
- SL_SSL_CA_CERT_FILE_NAME "/cert/129.der" downloaded from test.mosquitto.org in der format
Result: same errors as above.
At last I tried mosquitto to the port 8884, following the mosquitto procedure:
- generate client.key in PEM format
- generate client.csr file
- paste on mosquitto page
- download client.crt
- convert certificate in DER format: $openssl x509 -outform der -in client.crt -out client_crt.der
- convert private_key in DER format: $openssl rsa -in client.key -pubout -outform DER -out client_key.der
- flash files in cc3200 via UniFlash
I added the following code to the example:
-------------------------------------------------------------------------------------------------------------------
#define SL_SSL_KEY_CERT_FILE_NAME "/cert/127.der"
#define SL_SSL_CRT_CERT_FILE_NAME "/cert/128.der"
lRetVal = sl_SetSockOpt(iSockID, SL_SOL_SOCKET, \
SL_SO_SECURE_FILES_PRIVATE_KEY_FILE_NAME, \
SL_SSL_KEY_CERT_FILE_NAME, \
strlen(SL_SSL_KEY_CERT_FILE_NAME));
if(lRetVal < 0)
{
UART_PRINT("Device couldn't set socket options key \n\r");
GPIO_IF_LedOn(MCU_RED_LED_GPIO);
return lRetVal;
}
lRetVal = sl_SetSockOpt(iSockID, SL_SOL_SOCKET, \
SL_SO_SECURE_FILES_CERTIFICATE_FILE_NAME, \
SL_SSL_CRT_CERT_FILE_NAME, \
strlen(SL_SSL_CRT_CERT_FILE_NAME));
if(lRetVal < 0)
{
UART_PRINT("Device couldn't set socket options crt \n\r");
GPIO_IF_LedOn(MCU_RED_LED_GPIO);
return lRetVal;
}
-------------------------------------------------------------------------------------------------------------------
This time the return error is SL_ESECHANDSHAKETIMEDOUT (-462).
If I use openssl from pc with the same parameters, the socket connects without errors.
Could you give me some advice for trying to solve this issue?
Thanks,
Rosario