I am fairly new to TSL/SSL and pardon me if this is a very basic doubt but I am trying to connect to cloud using Websocket headers . The flow for connection as implemented on ESP32 with mbedtls library (as per my understanding) is as follows:
- initialize SSL context and configure and seed the entropy.
- parse the server root certificate.
- Configure as client and connect to the host using the above ssl context on port 443.
- Perform SSL handshake
- Send the following header using the mbedtls_write API. The header is as shown:
const char * request_base = ""
"GET /endpoints/54484249/ws HTTP/1.1\r\n"
"device-wireless-mac: <MAC address>\r\n"
6. Receive the response from the server using mbedtls_read
I want to implement an equivalent process in CC3235 to connect to the same cloud. Accordingly I took the following steps:
1. Opened a secured TCP socket by giving the IP using sl_Socket(sa->sa_family,SL_SOCK_STREAM,SL_SEC_SOCKET);
2. Set the device date and time using SNTP.
3. Set the Root CA certificate in .pem format, security mask and security method using sl_SetSockOpt API.
4. Using sl_Connect connect to the server. I get -114 initially then the second time it returns 0. Therefore, I am assuming that SSL handshake was successful.
Is this assumption correct?
5. I then send the above mentioned header to the server using sl_Send and all the bytes get transferred. Also, there is no SL_SOCKET_TX_FAILED_EVENT.
6. After sending the data to the server, I am waiting for the response, however I always get SL_ERROR_BSD_EAGAIN (-11) as the response and then it goes in faultISR().
Also after checking the server logs, it was clear that sl_Send data was not reaching the server.
As far as I have checked they are not using any websocket packets structure or websocket libraries, just sending the above buffer through secure TCP socket usingTSL.
It will be really helpful if you guys could shed some light on what is missing and should be the right approach for implementing the same in CC3235.