mirror of
https://github.com/apache/httpd.git
synced 2025-08-08 15:02:10 +03:00
mod_ssl: Log private key material to file set by $SSLKEYLOGFILE in the
environment, using the standard format which can be parsed by (e.g.) wireshark for decoding SSL/TLS traffic; supported from OpenSSL 1.1.1. * modules/ssl/ssl_private.h: Add keylog_file to SSLModConfigRec. * modules/ssl/ssl_engine_init.c (ssl_init_Module): Open log file if SSLKEYLOGFILE is set in the environment. (ssl_init_ctx_protocol): Register the keylog callback with OpenSSL. * modules/ssl/ssl_engine_kernel.c (modssl_callback_keylog): New function. PR: 63391 Github: closes #74 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1869842 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
6
CHANGES
6
CHANGES
@@ -1,6 +1,10 @@
|
||||
-*- coding: utf-8 -*-
|
||||
Changes with Apache 2.5.1
|
||||
|
||||
|
||||
*) mod_ssl: Support logging private key material for use with
|
||||
wireshark via log file given by SSLKEYLOGFILE environment
|
||||
variable. Requires OpenSSL 1.1.1. PR 63391. [Joe Orton]
|
||||
|
||||
*) mod_proxy: Improve tunneling loop to support half closed connections and
|
||||
pending data draining (for protocols like rsync). PR 61616. [Yann Ylavic]
|
||||
|
||||
|
@@ -1 +1 @@
|
||||
10226
|
||||
10228
|
||||
|
@@ -79,6 +79,10 @@ SSLModConfigRec *ssl_config_global_create(server_rec *s)
|
||||
mc->stapling_refresh_mutex = NULL;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENSSL_KEYLOG
|
||||
mc->keylog_file = NULL;
|
||||
#endif
|
||||
|
||||
apr_pool_userdata_set(mc, SSL_MOD_CONFIG_KEY,
|
||||
apr_pool_cleanup_null,
|
||||
pool);
|
||||
|
@@ -440,6 +440,28 @@ apr_status_t ssl_init_Module(apr_pool_t *p, apr_pool_t *plog,
|
||||
init_bio_methods();
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENSSL_KEYLOG
|
||||
{
|
||||
const char *logfn = getenv("SSLKEYLOGFILE");
|
||||
|
||||
if (logfn) {
|
||||
rv = apr_file_open(&mc->keylog_file, logfn,
|
||||
APR_FOPEN_CREATE|APR_FOPEN_WRITE|APR_FOPEN_APPEND|APR_FOPEN_LARGEFILE,
|
||||
APR_FPROT_UREAD|APR_FPROT_UWRITE,
|
||||
mc->pPool);
|
||||
if (rv) {
|
||||
ap_log_error(APLOG_MARK, APLOG_NOTICE, rv, s, APLOGNO(10226)
|
||||
"Could not open log file '%s' configured via SSLKEYLOGFILE",
|
||||
logfn);
|
||||
return rv;
|
||||
}
|
||||
|
||||
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, s, APLOGNO(10227)
|
||||
"Init: Logging SSL private key material to %s", logfn);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -826,6 +848,12 @@ static apr_status_t ssl_init_ctx_protocol(server_rec *s,
|
||||
* https://github.com/openssl/openssl/issues/7178 */
|
||||
SSL_CTX_clear_mode(ctx, SSL_MODE_AUTO_RETRY);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENSSL_KEYLOG
|
||||
if (mctx->sc->mc->keylog_file) {
|
||||
SSL_CTX_set_keylog_callback(ctx, modssl_callback_keylog);
|
||||
}
|
||||
#endif
|
||||
|
||||
return APR_SUCCESS;
|
||||
}
|
||||
|
@@ -2803,3 +2803,17 @@ int ssl_callback_SRPServerParams(SSL *ssl, int *ad, void *arg)
|
||||
}
|
||||
|
||||
#endif /* HAVE_SRP */
|
||||
|
||||
|
||||
#ifdef HAVE_OPENSSL_KEYLOG
|
||||
/* Callback used with SSL_CTX_set_keylog_callback. */
|
||||
void modssl_callback_keylog(const SSL *ssl, const char *line)
|
||||
{
|
||||
conn_rec *conn = SSL_get_app_data(ssl);
|
||||
SSLSrvConfigRec *sc = mySrvConfig(conn->base_server);
|
||||
|
||||
if (sc && sc->mc->keylog_file) {
|
||||
apr_file_printf(sc->mc->keylog_file, "%s\n", line);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@@ -250,6 +250,10 @@ void free_bio_methods(void);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x10101000L && !defined(LIBRESSL_VERSION_NUMBER)
|
||||
#define HAVE_OPENSSL_KEYLOG
|
||||
#endif
|
||||
|
||||
/* mod_ssl headers */
|
||||
#include "ssl_util_ssl.h"
|
||||
|
||||
@@ -603,6 +607,10 @@ typedef struct {
|
||||
apr_global_mutex_t *stapling_refresh_mutex;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENSSL_KEYLOG
|
||||
/* Used for logging if SSLKEYLOGFILE is set at startup. */
|
||||
apr_file_t *keylog_file;
|
||||
#endif
|
||||
} SSLModConfigRec;
|
||||
|
||||
/** Structure representing configured filenames for certs and keys for
|
||||
@@ -963,6 +971,11 @@ int ssl_stapling_init_cert(server_rec *, apr_pool_t *, apr_pool_t *,
|
||||
int ssl_callback_SRPServerParams(SSL *, int *, void *);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENSSL_KEYLOG
|
||||
/* Callback used with SSL_CTX_set_keylog_callback. */
|
||||
void modssl_callback_keylog(const SSL *ssl, const char *line);
|
||||
#endif
|
||||
|
||||
/** I/O */
|
||||
void ssl_io_filter_init(conn_rec *, request_rec *r, SSL *);
|
||||
void ssl_io_filter_register(apr_pool_t *);
|
||||
|
Reference in New Issue
Block a user