From 296e3b11744401b8e2e2677ff915bdabc2db8375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 19 Aug 2014 12:59:03 +0200 Subject: [PATCH] Request renego before write in ssl_server2 Will be useful for: - detecting termination of messages by other means than connection close - DTLS (can be seen as a special case of the above: datagram-oriented) --- programs/ssl/ssl_server2.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index 20df7819b8..ae512c0ae3 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -1589,6 +1589,22 @@ reset: /* * 7. Write the 200 Response */ + if( opt.renegotiate ) + { + /* Request renegotiation while the client is waiting for input */ + printf( " . Requestion renegotiation..." ); + fflush( stdout ); + while( ( ret = ssl_renegotiate( &ssl ) ) != 0 ) + { + if( ret != POLARSSL_ERR_NET_WANT_READ && + ret != POLARSSL_ERR_NET_WANT_WRITE ) + { + printf( " failed\n ! ssl_renegotiate returned %d\n\n", ret ); + goto reset; + } + } + } + printf( " > Write to client:" ); fflush( stdout ); @@ -1618,22 +1634,6 @@ reset: if( opt.renegotiate ) { - /* - * Request renegotiation (this must be done when the client is still - * waiting for input from our side). - */ - printf( " . Requestion renegotiation..." ); - fflush( stdout ); - while( ( ret = ssl_renegotiate( &ssl ) ) != 0 ) - { - if( ret != POLARSSL_ERR_NET_WANT_READ && - ret != POLARSSL_ERR_NET_WANT_WRITE ) - { - printf( " failed\n ! ssl_renegotiate returned %d\n\n", ret ); - goto reset; - } - } - /* * Should be a while loop, not an if, but here we're not actually * expecting data from the client, and since we're running tests