diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index 375badbf3..599699481 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -990,7 +990,8 @@ int main( int argc, char *argv[] ) ssl_set_dbg( &ssl, my_debug, stdout ); if( opt.nbio == 2 ) - ssl_set_bio_timeout( &ssl, &server_fd, my_send, my_recv, NULL, 0 ); + ssl_set_bio_timeout( &ssl, &server_fd, my_send, my_recv, NULL, + opt.read_timeout ); else ssl_set_bio_timeout( &ssl, &server_fd, net_send, net_recv, #if defined(POLARSSL_HAVE_TIME) @@ -1392,6 +1393,17 @@ reconnect: goto exit; } + if( opt.nbio > 0 ) + ret = net_set_nonblock( server_fd ); + else + ret = net_set_block( server_fd ); + if( ret != 0 ) + { + printf( " failed\n ! net_set_(non)block() returned -0x%x\n\n", + -ret ); + goto exit; + } + while( ( ret = ssl_handshake( &ssl ) ) != 0 ) { if( ret != POLARSSL_ERR_NET_WANT_READ && diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 0d686d125..372e5a98d 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -2318,6 +2318,20 @@ run_test "DTLS proxy: 3d, min handshake, resumption" \ -s "Extra-header:" \ -c "HTTP/1.0 200 OK" +needs_more_time 4 +run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \ + -p "$P_PXY drop=5 delay=5 duplicate=5" \ + "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \ + psk=abc123 debug_level=3 nbio=2" \ + "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \ + debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \ + force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \ + 0 \ + -s "a session has been resumed" \ + -c "a session has been resumed" \ + -s "Extra-header:" \ + -c "HTTP/1.0 200 OK" + needs_more_time 4 run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \ -p "$P_PXY drop=5 delay=5 duplicate=5" \