1 (edited by linxiong2 2022-11-21 02:03:24)

Topic: STM32CubeMX_STM32F407_FreeRTOS_Lwip to wolfSSL5.5.3 err -308

When trying to connect my client , I get the -308 error on both client processes.

I was wondering if there is anyway I can see what is causing it.

I've been dealing with it for days. Still can't find the problem.


wolfSSL Entering wolfSSL_Init
wolfSSL Entering wolfCrypt_Init
wolfSSL Entering SSLv23_client_method_ex
wolfSSL Entering wolfSSL_CTX_new_ex
wolfSSL Entering wolfSSL_CertManagerNew
wolfSSL Leaving WOLFSSL_CTX_new, return 0
wolfSSL Entering wolfSSL_CTX_set_verify
wolfSSL Entering SSL_new
wolfSSL Leaving SSL_new, return 0
wolfSSL Entering SSL_set_fd
wolfSSL Entering SSL_set_read_fd
wolfSSL Leaving SSL_set_read_fd, return 1
wolfSSL Entering SSL_set_write_fd
wolfSSL Leaving SSL_set_write_fd, return 1
wolfSSL Entering SSL_connect()
wolfSSL Entering SendTls13ClientHello
Adding signature algorithms extension
Adding supported versions extension
wolfSSL Entering EccMakeKey
wolfSSL Leaving EccMakeKey, return 0
growing output buffer
Key Share extension to write
Supported Versions extension to write
Signature Algorithms extension to write
Point Formats extension to write
Supported Groups extension to write
Encrypt-Then-Mac extension to write
EMS extension to write
Your IO Send callback is null, please set
wolfSSL Leaving SendTls13ClientHello, return -308
wolfSSL error occurred, error = -308
wolfSSL Entering SSL_get_error
wolfSSL Leaving SSL_get_error, return -308
wolfSSL Entering ERR_error_string
error = -308, error state on socket
wolfSSL Entering SSL_shutdown()
wolfSSL Entering SendAlert
growing output buffer
Your IO Send callback is null, please set
wolfSSL Leaving SendAlert, return -308
wolfSSL error occurred, error = -308
wolfSSL Entering SSL_free
Free'ing client ssl
Shrinking output buffer
CTX ref count not 0 yet, no free
wolfSSL Leaving SSL_free, return 0
wolfSSL Entering SSL_CTX_free
CTX ref count down to 0, doing full free
wolfSSL Entering wolfSSL_CertManagerFree
wolfSSL Leaving SSL_CTX_free, return 0
wolfSSL Entering wolfSSL_Cleanup
wolfSSL Entering wolfCrypt_Cleanup

    int fd;
    int len;
    int ret;
    const int PORT = 443;
    struct sockaddr_in addr;

    WOLFSSL *ssl = NULL;
    WOLFSSL_CTX* ctx = NULL;
        if ((ctx = wolfSSL_CTX_new(wolfSSLv23_client_method())) == NULL) 
            printf( "wolfSSL_CTX_new error.\r\n");
            return -1;
        wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, 0);

        if ((ssl = wolfSSL_new(ctx)) == NULL)
            printf("wolfssl new fail\r\n");
        if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
            printf("fd < 0\r\n");

        addr.sin_addr.s_addr = inet_addr(ipAddr); //baidu ip
        addr.sin_family = AF_INET;
        addr.sin_port = htons(PORT);

        while(connect(fd,(struct sockaddr*)&addr,sizeof(addr)) != 0)
            printf("connect error \r\n");    
        if ((ret = wolfSSL_set_fd(ssl,fd)) != SSL_SUCCESS)
            printf("set fd fail\r\n");
        if ((ret = wolfSSL_connect(ssl)) != SSL_SUCCESS)
            char buffer[80];
            int err = wolfSSL_get_error(ssl, ret);
            printf("error = %d, %s\r\n", err, wolfSSL_ERR_error_string(err, buffer));   

        //wolfssl will connect before write/read
        len = wolfSSL_write(ssl,(byte*)request_get,strlen(request_get));
        if(len < 0)
            printf("ssl write fail\r\n");
        char ch[1024];
        while(wolfSSL_read(ssl, &ch, 1024) > 0)
            printf("%s", ch);
            memset(ch, 0, 1024);
    } while (0);



Re: STM32CubeMX_STM32F407_FreeRTOS_Lwip to wolfSSL5.5.3 err -308

Hello linxiong2

Thanks for joining the wolfSSL forums. The error is due to the IO callbacks being configured but not set:

Your IO Send callback is null, please set

For LWIP we support their socket interface by default if you add `WOLFSSL_LWIP` to the generated configuration file `wolfSSL.I-CUBE-wolfSSL_conf.h`.

The documentation or the Cube pack is here:
https://github.com/wolfSSL/wolfssl/tree … /STM32Cube

Eric - wolfSSL Support

Re: STM32CubeMX_STM32F407_FreeRTOS_Lwip to wolfSSL5.5.3 err -308

The problem has been solved. Thank you for your help.