diff options
-rw-r--r-- | src/sslkeylog.c | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/src/sslkeylog.c b/src/sslkeylog.c index 0d09b5d..2a3ff9b 100644 --- a/src/sslkeylog.c +++ b/src/sslkeylog.c @@ -21,7 +21,6 @@ #define FIRSTLINE "# SSL key logfile generated by sslkeylog.c\n" #define FIRSTLINE_LEN (sizeof(FIRSTLINE) - 1) -static int (*_SSL_connect)(SSL *ssl); static int keylog_file_fd = -1; static inline void put_hex(char *buffer, int pos, char c) @@ -72,12 +71,8 @@ static void init_keylog_file(void) } } -int SSL_connect(SSL *ssl) +static void tap_ssl_key(SSL *ssl) { - if (!_SSL_connect) { - _SSL_connect = (int (*)(SSL *ssl)) dlsym(RTLD_NEXT, "SSL_connect"); - } - int ret = _SSL_connect(ssl); /* SSLv2 is not supported (Wireshark does not support it either). Write the * logfile when the master key is available for SSLv3/TLSv1. */ if (ssl->s3 != NULL && @@ -87,5 +82,37 @@ int SSL_connect(SSL *ssl) dump_to_fd(ssl, keylog_file_fd); } } +} + +int SSL_connect(SSL *ssl) +{ + static int (*func)(); + if (!func) { + func = dlsym(RTLD_NEXT, __func__); + } + int ret = func(ssl); + tap_ssl_key(ssl); + return ret; +} + +int SSL_do_handshake(SSL *ssl) +{ + static int (*func)(); + if (!func) { + func = dlsym(RTLD_NEXT, __func__); + } + int ret = func(ssl); + tap_ssl_key(ssl); + return ret; +} + +int SSL_accept(SSL *ssl) +{ + static int (*func)(); + if (!func) { + func = dlsym(RTLD_NEXT, __func__); + } + int ret = func(ssl); + tap_ssl_key(ssl); return ret; } |