Topic: WolfSSL_read does not return
Dear support team,
I am using WolfSSL 3.15.3 library. I am trying to send e-mail via smpt.gmail.com on port 587. After sending "starttls" command I start tls with wolfSSL_read. This function does not return control to the program. Logs from the WolfSSL library are attached and defined as LOG 1 in logs.txt.
When I pause the program I get the following stack:
MyCallbackIORecv() at main.c:135 0xc524
Receive() at internal.c:2 616 0x1e4ac
GetInputData() at internal.c:6 225 0x216fa
ProcessReply() at internal.c:6 354 0x2199e
ReceiveData() at internal.c:7 593 0x22c04
wolfSSL_read_internal() at ssl.c:571 0xdb76
wolfSSL_read() at ssl.c:595 0xdbba
TLSInit() at main.c:767 0xd112
pxPortInitialiseStack() at port.c:233 0x262c
The program does not get below GetInputData. MyCallbackIORecv code:
int MyCallbackIORecv(WOLFSSL *ssl, char *buf, int sz, void *ctx)
{
int recvd, ret;
int sd = *(int*)ctx;
recvd = (int)FreeRTOS_recv((void *)sd, buf, sz, 0);
if(recvd == -pdFREERTOS_ERRNO_ENOTCONN)
ret=WOLFSSL_CBIO_ERR_CONN_CLOSE;
else if(recvd == -pdFREERTOS_ERRNO_ENOMEM)
ret=WOLFSSL_CBIO_ERR_GENERAL;
else if(recvd == -pdFREERTOS_ERRNO_EINVAL)
ret=WOLFSSL_CBIO_ERR_GENERAL;
else if(recvd < 0)
ret=WOLFSSL_CBIO_ERR_GENERAL;
else
ret=recvd;
return ret;
}
I see that FreeRTOS_recv returns 0, so MyCallbackIORecv do the same. FreeRTOS_recv does not block. When I add the following lines
else if(recvd == 0)
ret=WOLFSSL_CBIO_ERR_WANT_READ;
or
else if(recvd == 0)
ret=WOLFSSL_CBIO_ERR_WANT_READ;
to MyCallbackIORecv I get the log defined as LOG 2 in the attached file.
I dont know why wolfSSL_read function does not return. Could anyone help me with this?
Regards,
Kamil