From: Ken Hornstein Date: Wed, 1 Nov 2017 18:00:18 +0000 (-0400) Subject: Report on the TLS negotation time X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/939f1fee996a43fbbf4074874c3be5467592efe1?ds=inline Report on the TLS negotation time --- diff --git a/uip/imaptest.c b/uip/imaptest.c index 01d3ee52..befedabb 100644 --- a/uip/imaptest.c +++ b/uip/imaptest.c @@ -81,6 +81,7 @@ static int get_imap_response(netsec_context *, const char *token, static void ts_report(struct timeval *tv, const char *fmt, ...) CHECK_PRINTF(2, 3); +static void imap_negotiate_tls(netsec_context *); static void add_msg(bool queue, const char *fmt, ...) CHECK_PRINTF(2, 3); @@ -220,8 +221,8 @@ main (int argc, char **argv) if (netsec_set_tls(nsc, 1, 0, &errstr) != OK) die("%s", errstr); - if (initialtls && netsec_negotiate_tls(nsc, &errstr) != OK) - die("%s", errstr); + if (initialtls) + imap_negotiate_tls(nsc); } if (sasl) { @@ -296,9 +297,8 @@ main (int argc, char **argv) fprintf(stderr, "STARTTLS failed: %s\n", errstr); goto finish; } - if (netsec_negotiate_tls(nsc, &errstr) != OK) { - die("%s", errstr); - } + + imap_negotiate_tls(nsc); } if (sasl) { @@ -790,6 +790,26 @@ add_msg(bool queue, const char *fmt, ...) } } +/* + * Negotiate TLS connection, with optional timestamp + */ + +static void +imap_negotiate_tls(netsec_context *nsc) +{ + char *errstr; + struct timeval tv; + + if (timestamp) + gettimeofday(&tv, NULL); + + if (netsec_negotiate_tls(nsc, &errstr) != OK) + die("%s", errstr); + + if (timestamp) + ts_report(&tv, "TLS negotation time"); +} + /* * Give a timestamp report. */