Skip to content

Commit

Permalink
[ssl] Ignore MBEDTLS_ERR_SSL_WANT_READ and MBEDTLS_ERR_SSL_RECEIVED_N…
Browse files Browse the repository at this point in the history
…EW_SESSION_TICKET. (#291)
  • Loading branch information
Apprentice-Alchemist authored Jul 4, 2024
1 parent 31e9db6 commit ba49f62
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions libs/ssl/ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ static value ssl_recv_char(value ssl) {
val_check_kind(ssl,k_ssl);
r = mbedtls_ssl_read( val_ssl(ssl), &c, 1 );
if( r <= 0 )
neko_error();
ssl_error(r);
return alloc_int( c );
}

Expand All @@ -248,10 +248,15 @@ static value ssl_recv( value ssl, value data, value pos, value len ) {
HANDLE_EINTR(recv_again);
return block_error();
}
if( dlen == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY )
if (dlen == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY
|| dlen == MBEDTLS_ERR_SSL_WANT_READ
#ifdef MBEDTLS_ERR_SSL_RECEIVED_NEW_SESSION_TICKET
|| dlen == MBEDTLS_ERR_SSL_RECEIVED_NEW_SESSION_TICKET
#endif
)
return alloc_int(0);
if( dlen < 0 )
neko_error();
ssl_error(dlen);
return alloc_int( dlen );
}

Expand All @@ -270,7 +275,11 @@ static value ssl_read( value ssl ) {
HANDLE_EINTR(read_again);
return block_error();
}
if( len == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY )
if( len == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY || len == MBEDTLS_ERR_SSL_WANT_READ
#ifdef MBEDTLS_ERR_SSL_RECEIVED_NEW_SESSION_TICKET
|| len == MBEDTLS_ERR_SSL_RECEIVED_NEW_SESSION_TICKET
#endif
)
break;
if( len == 0 )
break;
Expand Down

0 comments on commit ba49f62

Please sign in to comment.