From f1fd4544a3747682010ed89ac908713fe90b8304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bodo=20M=C3=B6ller?= Date: Tue, 3 Jan 2006 03:27:19 +0000 Subject: Various changes in the new TLS extension code, including the following: - fix indentation - rename some functions and macros - fix up confusion between SSL_ERROR_... and SSL_AD_... values --- apps/s_client.c | 4 ++-- apps/s_server.c | 23 +++++++++++++---------- 2 files changed, 15 insertions(+), 12 deletions(-) (limited to 'apps') diff --git a/apps/s_client.c b/apps/s_client.c index b5c044bfa7..181cb3f15b 100644 --- a/apps/s_client.c +++ b/apps/s_client.c @@ -239,11 +239,11 @@ typedef struct tlsextctx_st { static int MS_CALLBACK ssl_servername_cb(SSL *s, int *ad, void *arg) { tlsextctx * p = (tlsextctx *) arg; - const unsigned char * hn= SSL_get_servername(s, TLSEXT_TYPE_SERVER_host); + const unsigned char * hn= SSL_get_servername(s, TLSEXT_NAMETYPE_host_name); if (SSL_get_servername_type(s) != -1) p->ack = !SSL_session_reused(s) && hn != NULL; else - BIO_printf(bio_err,"SSL_get_tlsext_hostname does not work\n"); + BIO_printf(bio_err,"Can't use SSL_get_servername\n"); return SSL_ERROR_NONE; } diff --git a/apps/s_server.c b/apps/s_server.c index 068e0c54b1..6c106f7f02 100644 --- a/apps/s_server.c +++ b/apps/s_server.c @@ -539,7 +539,7 @@ typedef struct tlsextctx_st { static int MS_CALLBACK ssl_servername_cb(SSL *s, int *ad, void *arg) { tlsextctx * p = (tlsextctx *) arg; - const char * servername = SSL_get_servername(s, TLSEXT_TYPE_SERVER_host); + const char * servername = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name); if (servername) BIO_printf(p->biodebug,"Hostname in TLS extension: \"%s\"\n",servername); @@ -1257,12 +1257,14 @@ bad: #endif #endif - if (cipher != NULL) { - if(!SSL_CTX_set_cipher_list(ctx,cipher)) { + if (cipher != NULL) + { + if(!SSL_CTX_set_cipher_list(ctx,cipher)) + { BIO_printf(bio_err,"error setting cipher list\n"); ERR_print_errors(bio_err); goto end; - } + } #ifndef OPENSSL_NO_TLSEXT if (ctx2 && !SSL_CTX_set_cipher_list(ctx2,cipher)) { @@ -1271,7 +1273,7 @@ bad: goto end; } #endif - } + } SSL_CTX_set_verify(ctx,s_server_verify,verify_callback); SSL_CTX_set_session_id_context(ctx,(void*)&s_server_session_id_context, sizeof s_server_session_id_context); @@ -1283,13 +1285,14 @@ bad: SSL_CTX_set_session_id_context(ctx2,(void*)&s_server_session_id_context, sizeof s_server_session_id_context); + tlsextcbp.biodebug = bio_s_out; + SSL_CTX_set_tlsext_servername_callback(ctx2, ssl_servername_cb); + SSL_CTX_set_tlsext_servername_arg(ctx2, &tlsextcbp); + SSL_CTX_set_tlsext_servername_callback(ctx, ssl_servername_cb); + SSL_CTX_set_tlsext_servername_arg(ctx, &tlsextcbp); } - tlsextcbp.biodebug = bio_s_out; - SSL_CTX_set_tlsext_servername_callback(ctx2, ssl_servername_cb); - SSL_CTX_set_tlsext_servername_arg(ctx2, &tlsextcbp); - SSL_CTX_set_tlsext_servername_callback(ctx, ssl_servername_cb); - SSL_CTX_set_tlsext_servername_arg(ctx, &tlsextcbp); #endif + if (CAfile != NULL) { SSL_CTX_set_client_CA_list(ctx,SSL_load_client_CA_file(CAfile)); -- cgit v1.2.3