mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-30 23:11:10 +00:00
Properly send close_notify in ssl_client2
This commit is contained in:
parent
a13500fdf7
commit
f138874811
|
@ -1130,7 +1130,7 @@ send_request:
|
||||||
case POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY:
|
case POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY:
|
||||||
printf( " connection was closed gracefully\n" );
|
printf( " connection was closed gracefully\n" );
|
||||||
ret = 0;
|
ret = 0;
|
||||||
goto reconnect;
|
goto close_notify;
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
case POLARSSL_ERR_NET_CONN_RESET:
|
case POLARSSL_ERR_NET_CONN_RESET:
|
||||||
|
@ -1165,7 +1165,32 @@ send_request:
|
||||||
goto send_request;
|
goto send_request;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 7c. Reconnect?
|
* 8. Done, cleanly close the connection
|
||||||
|
*/
|
||||||
|
close_notify:
|
||||||
|
printf( " . Closing the connection..." );
|
||||||
|
|
||||||
|
while( ( ret = ssl_close_notify( &ssl ) ) < 0 )
|
||||||
|
{
|
||||||
|
if( ret == POLARSSL_ERR_NET_CONN_RESET )
|
||||||
|
{
|
||||||
|
printf( " ok (already closed by peer)\n" );
|
||||||
|
ret = 0;
|
||||||
|
goto reconnect;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ret != POLARSSL_ERR_NET_WANT_READ &&
|
||||||
|
ret != POLARSSL_ERR_NET_WANT_WRITE )
|
||||||
|
{
|
||||||
|
printf( " failed\n ! ssl_close_notify returned %d\n\n", ret );
|
||||||
|
goto reconnect;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf( " ok\n" );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 9. Reconnect?
|
||||||
*/
|
*/
|
||||||
reconnect:
|
reconnect:
|
||||||
if( opt.reconnect != 0 )
|
if( opt.reconnect != 0 )
|
||||||
|
|
Loading…
Reference in a new issue