Topic: wolfSSL with wolfIP

I'm experimenting with using wolfSSL and wolfIP. When calling wolfSSL_connect() I get a failure with the log message "Your IO Send callback is null, please set".

I can see this is something to do with wolfSSL_SetIOWriteCTX(), but I'm not entirely sure what value to use - I'm a novice with wolfSSL.

Are there specific values I should set to link the two components together?

Share

Re: wolfSSL with wolfIP

Hi ah346743,

To better help you, can you let me know what platform you building on?  For example, is this an STM32CubeIDE project?

Warm regards, Anthony

Share

Re: wolfSSL with wolfIP

Hi

Yes, it's an STM32CubeIDE project on the Nucleo F429ZI development board. I've configured wolfSSL and wolfIP via CubeMX.

Share

Re: wolfSSL with wolfIP

Hi ah346743!
 
I am one of the developers that work on the wolfIP project. This isn't a bug, just a wiring step that's easy to miss.

The message "Your IO Send callback is null, please set" means wolfSSL doesn't yet know how to send/receive bytes. On STM32 + wolfIP there are no BSD sockets, so wolfSSL's built-in I/O is compiled out and you have to point it at wolfIP. Note that wolfSSL_SetIOWriteCtx() only sets the context pointer; it does not install the send callback, which is why it's still null.

You don't need that function at all. wolfIP ships a helper pair that does the whole job:

```
  ctx = wolfSSL_CTX_new(wolfTLSv1_3_client_method());
  wolfSSL_SetIO_wolfIP_CTX(ctx, ipstack);          /* installs send/recv callbacks */

  fd = wolfIP_sock_socket(ipstack, AF_INET, IPSTACK_SOCK_STREAM, 0);
  wolfIP_sock_connect(ipstack, fd, &remote, sizeof(remote));   /* TCP connect first */

  ssl = wolfSSL_new(ctx);
  wolfSSL_SetIO_wolfIP(ssl, fd);                    /* bind this session to the fd */

  ret = wolfSSL_connect(ssl);
```


Two things I would look out for:

1. Call wolfSSL_SetIO_wolfIP_CTX before wolfSSL_new. The callback is copied into the session at creation time.
2. wolfSSL_connect() won't finish in one call; it returns WANT_READ/WANT_WRITE until data moves. Keep wolfIP_poll(ipstack, HAL_GetTick()); running in your main loop and call wolfSSL_connect() again until it succeeds.

A full bare-metal example is here: src/port/stm32h563/tls_client.c

Could you try that and let me know? Two quick questions I have that may help you:

- Were you wiring the I/O manually, or calling the wolfSSL_SetIO_wolfIP* helpers?
- In CubeMX under Software Packs → Select Components, is the wolfSSL-IO component checked? If you get a linker error on wolfSSL_SetIO_wolfIP_CTX instead of the runtime message, that component isn't enabled.

Most of our Cube-pack TLS testing has been on the H5 a full working example lives here that may help you https://github.com/wolfSSL/wolfssl-exam … 2/pull/10.

Thanks
Aidan - wolfSSL

Share

Re: wolfSSL with wolfIP

Hi Aidan, thanks for the reply. Unfortunately I've not been able to get any further.

wolfSSL-IO component is enabled, but there is a linker failure with wolfSSL_SetIO_wolfIP_CTX not found. I can see the prototype in wolfip.h, but it's conditionally compiled out as the #define for WOLFSSL_WOLFIP is commented out in wolfSSL.I-CUBE-wolfIP_conf.h. Even if I manually edit that file to define WOLFSSL_WOLFIP there's no implementation for the function anywhere.

I've tried running the H5 example but it only seems to be wolfIP, I can't see it using the wolfSSL-IO component. I've actually got wolfIP running by itself; I can pick up an IP address with DHCP and do a DNS lookup of the target server, I just can't integrate it with wolfSSL (Although to get it to work I've had to modify wolfSSL.I-CUBE-wolfSSL_conf.h to add a Nucleo 429ZI board, and also manually modify wolfIP/config.h to #define RXBUF_SIZE (3 * 1024) and #define TXBUF_SIZE (3 * 1024) )

Unfortunately this is a bit of a background project and due to other work I may have very limited time to continue investigating. I'm happy to share source code, installation details etc with you if it'd help, just let me know details.

Share