From 1c5b9fc19ffa694bb783d2f5bb82ace54b96a11b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Sat, 27 Jun 2015 14:38:51 +0200 Subject: [PATCH] Avoid truncating peer cert info in ssl_server2 --- programs/ssl/ssl_server2.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index a5c50d057..c66a4e91f 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -1993,10 +1993,12 @@ reset: else mbedtls_printf( " ok\n" ); - if( mbedtls_ssl_get_peer_cert( &ssl ) ) + if( mbedtls_ssl_get_peer_cert( &ssl ) != NULL ) { + char crt_buf[512]; + mbedtls_printf( " . Peer certificate information ...\n" ); - mbedtls_x509_crt_info( (char *) buf, sizeof( buf ) - 1, " ", + mbedtls_x509_crt_info( crt_buf, sizeof( crt_buf ), " ", mbedtls_ssl_get_peer_cert( &ssl ) ); mbedtls_printf( "%s\n", buf ); }