summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2012-12-26 22:40:46 +0000
committerDr. Stephen Henson <steve@openssl.org>2012-12-26 22:40:46 +0000
commitbc200e691cd68870c2062d3c1e74280a59aaa5ab (patch)
tree52713bc083b97da4ba573ac996b20041f614933e /apps
parenta08f8d73ccac52dfd6e674f2d5abbe70986c7fc8 (diff)
SSL/TLS record tracing code (backport from HEAD).
Diffstat (limited to 'apps')
-rw-r--r--apps/s_client.c28
-rw-r--r--apps/s_server.c37
2 files changed, 57 insertions, 8 deletions
diff --git a/apps/s_client.c b/apps/s_client.c
index 6ff11eac94..6e5eaa06df 100644
--- a/apps/s_client.c
+++ b/apps/s_client.c
@@ -217,6 +217,7 @@ static int ocsp_resp_cb(SSL *s, void *arg);
static int audit_proof_cb(SSL *s, void *arg);
#endif
static BIO *bio_c_out=NULL;
+static BIO *bio_c_msg=NULL;
static int c_quiet=0;
static int c_ign_eof=0;
@@ -754,6 +755,15 @@ int MAIN(int argc, char **argv)
#endif
else if (strcmp(*argv,"-msg") == 0)
c_msg=1;
+ else if (strcmp(*argv,"-msgfile") == 0)
+ {
+ if (--argc < 1) goto bad;
+ bio_c_msg = BIO_new_file(*(++argv), "w");
+ }
+#ifndef OPENSSL_NO_SSL_TRACE
+ else if (strcmp(*argv,"-trace") == 0)
+ c_msg=2;
+#endif
else if (strcmp(*argv,"-showcerts") == 0)
c_showcerts=1;
else if (strcmp(*argv,"-nbio_test") == 0)
@@ -1115,9 +1125,11 @@ bad:
if (bio_c_out == NULL)
{
- if (c_quiet && !c_debug && !c_msg)
+ if (c_quiet && !c_debug)
{
bio_c_out=BIO_new(BIO_s_null());
+ if (c_msg && !bio_c_msg)
+ bio_c_msg=BIO_new_fp(stdout,BIO_NOCLOSE);
}
else
{
@@ -1390,8 +1402,13 @@ re_start:
}
if (c_msg)
{
- SSL_set_msg_callback(con, msg_cb);
- SSL_set_msg_callback_arg(con, bio_c_out);
+#ifndef OPENSSL_NO_SSL_TRACE
+ if (c_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_c_msg ? bio_c_msg : bio_c_out);
}
#ifndef OPENSSL_NO_TLSEXT
if (c_tlsextdebug)
@@ -1975,6 +1992,11 @@ end:
BIO_free(bio_c_out);
bio_c_out=NULL;
}
+ if (bio_c_msg != NULL)
+ {
+ BIO_free(bio_c_msg);
+ bio_c_msg=NULL;
+ }
apps_shutdown();
OPENSSL_EXIT(ret);
}
diff --git a/apps/s_server.c b/apps/s_server.c
index 0ffd11ba43..f53766d5d8 100644
--- a/apps/s_server.c
+++ b/apps/s_server.c
@@ -290,6 +290,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;
@@ -1244,6 +1245,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)
@@ -1589,6 +1599,8 @@ bad:
if (s_quiet && !s_debug && !s_msg)
{
bio_s_out=BIO_new(BIO_s_null());
+ if (s_msg && !bio_s_msg)
+ bio_s_msg=BIO_new_fp(stdout,BIO_NOCLOSE);
}
else
{
@@ -2080,9 +2092,14 @@ end:
ssl_excert_free(exc);
if (bio_s_out != NULL)
{
- BIO_free(bio_s_out);
+ 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);
}
@@ -2237,8 +2254,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)
@@ -2794,8 +2816,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 (;;)