Skip to main content
Visitor II
December 9, 2021
Question

How to establish a SSL/TLS socket connection with X-CUBE-CELLULAR v6.0.1?

  • December 9, 2021
  • 1 reply
  • 1165 views

I'm updating X-CUBE-CELLULAR in my project from v3.0.0 to v6.0.1, but I haven't found documentation or examples to create secure sockets.

With v3, it was as simple as follows:

 bool tls = (pCtx->protocol==HTTP_PROTO_HTTPS);
 
 pCtx->sock = net_socket(NET_AF_INET, NET_SOCK_STREAM, NET_IPPROTO_TCP);
 
 if(tls == true)
 {
 ret = net_setsockopt(pCtx->sock, NET_SOL_SOCKET, NET_SO_SECURE, NULL, 0);
 }

With v6, I manage to create the socket, but I can't find secure options:

pCtx->sock = com_socket(COM_AF_INET, COM_SOCK_STREAM, COM_IPPROTO_TCP);

I find hard to believe this feature is not supported since nowadays most of IoT communications require SSL certificates.

Please, can you confirm that it is possible? In that case, I really would appreciate if you provide an example to create secure sockets.

My project is configured to use modem sockets type (USE_SOCKETS_MODEM).

I've also tried LwIP sockets type (USE_SOCKETS_LWIP), but I can't set secure options through the socket API either. Nonetheless, I found this example (not yet tested) to work with LwIP + mbedTLS: LWIP + Mbedtls SSL + SMTP email client (st.com)

All things considered, I still prefer modem sockets in order to free resources in the MCU, so it would be the ideal solution.

@S.RA​, It seems you are the right person to ask. Thank you in advance for your help.

Regards,

Viviana

    This topic has been closed for replies.

    1 reply

    ST Employee
    December 10, 2021

    Hello,

    In the V5.2.0 there is an example with MQTTS.

    Application uses Network library middleware that use MbedTLS.

    Here is the IAR project path: STM32CubeExpansion_CELLULAR_V5.2.0\Projects\STM32L496G_Discovery\Demonstrations\Cellular\IDE_Mqtt\EWARM\Project.eww

    So the idea is to add Network_Library to your project and use the API with TLS activated.

    Hope it helps you.

    TLS is not provided in XCC V6 because Cellular Middleware is Socket BSP API and TLS is part of upper layers such as HTTP, MQTT ...

    Ronan,