summaryrefslogtreecommitdiff
path: root/src/sslkeylog.c
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2015-01-29 00:19:01 +0100
committerPeter Wu <peter@lekensteyn.nl>2015-01-29 00:19:01 +0100
commit85171f30c274c8f6c0d2d9bb77460908d6c6ba9c (patch)
tree3850d0404142443a7b88be7332737ee6cf5d3569 /src/sslkeylog.c
parent0d0b245d2632a5ff5ab327d62dbe2a4f78e9e564 (diff)
downloadwireshark-notes-85171f30c274c8f6c0d2d9bb77460908d6c6ba9c.tar.gz
sslkeylog: intercept server functions
Also intercept SSL_do_handshake (nginx) and SSL_accept (s_server).
Diffstat (limited to 'src/sslkeylog.c')
-rw-r--r--src/sslkeylog.c39
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;
}