diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2012-06-15 12:46:09 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2012-06-15 12:46:09 +0000 |
commit | 93ab9e421e4517b81d11ca741d55e6bb6f696c40 (patch) | |
tree | 04cf24ccc17855f9fb19412dd359b792e5855c85 /apps/s_server.c | |
parent | dfcf48f499f19fd17a3aee03151ea301814ea6ec (diff) |
Initial record tracing code. Print out all fields in SSL/TLS records
for debugging purposes. Needs "enable-ssl-trace" configuration option.
Diffstat (limited to 'apps/s_server.c')
-rw-r--r-- | apps/s_server.c | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/apps/s_server.c b/apps/s_server.c index 7881083c2e..0305a264f9 100644 --- a/apps/s_server.c +++ b/apps/s_server.c @@ -288,6 +288,7 @@ static SSL_CTX *ctx2=NULL; static int www=0; static BIO *bio_s_out=NULL; +static BIO *bio_s_msg = NULL; static int s_debug=0; #ifndef OPENSSL_NO_TLSEXT static int s_tlsextdebug=0; @@ -1207,6 +1208,15 @@ int MAIN(int argc, char *argv[]) #endif else if (strcmp(*argv,"-msg") == 0) { s_msg=1; } + else if (strcmp(*argv,"-msgfile") == 0) + { + if (--argc < 1) goto bad; + bio_s_msg = BIO_new_file(*(++argv), "w"); + } +#ifndef OPENSSL_NO_SSL_TRACE + else if (strcmp(*argv,"-trace") == 0) + { s_msg=2; } +#endif else if (strcmp(*argv,"-hack") == 0) { hack=1; } else if (strcmp(*argv,"-state") == 0) @@ -2004,6 +2014,11 @@ end: BIO_free(bio_s_out); bio_s_out=NULL; } + if (bio_s_msg != NULL) + { + BIO_free(bio_s_msg); + bio_s_msg = NULL; + } apps_shutdown(); OPENSSL_EXIT(ret); } @@ -2158,8 +2173,13 @@ static int sv_body(char *hostname, int s, unsigned char *context) } if (s_msg) { - SSL_set_msg_callback(con, msg_cb); - SSL_set_msg_callback_arg(con, bio_s_out); +#ifndef OPENSSL_NO_SSL_TRACE + if (s_msg == 2) + SSL_set_msg_callback(con, SSL_trace); + else +#endif + SSL_set_msg_callback(con, msg_cb); + SSL_set_msg_callback_arg(con, bio_s_msg ? bio_s_msg : bio_s_out); } #ifndef OPENSSL_NO_TLSEXT if (s_tlsextdebug) @@ -2712,8 +2732,13 @@ static int www_body(char *hostname, int s, unsigned char *context) } if (s_msg) { - SSL_set_msg_callback(con, msg_cb); - SSL_set_msg_callback_arg(con, bio_s_out); +#ifndef OPENSSL_NO_SSL_TRACE + if (s_msg == 2) + SSL_set_msg_callback(con, SSL_trace); + else +#endif + SSL_set_msg_callback(con, msg_cb); + SSL_set_msg_callback_arg(con, bio_s_msg ? bio_s_msg : bio_s_out); } for (;;) |