mirror of
https://github.com/openssl/openssl.git
synced 2024-11-27 05:21:51 +08:00
Remove sslkeylog file setup from quic-hq-interop
Now that libcrypto supports the user of SSLKEYLOGFILE, the interop demo attempts to open the same file based on the same env variable. The hq-interop-demo code can just be removed, and it fixes the open failure when both libcrypto and hq-interop attempt to open and write the same file, which is causing the nightly failure Reviewed-by: Paul Dale <ppzgs1@gmail.com> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/25819)
This commit is contained in:
parent
4c29044a83
commit
43ba601723
@ -55,7 +55,6 @@
|
||||
#include <openssl/err.h>
|
||||
|
||||
static int handle_io_failure(SSL *ssl, int res);
|
||||
static int set_keylog_file(SSL_CTX *ctx, const char *keylog_file);
|
||||
|
||||
#define REQ_STRING_SZ 1024
|
||||
|
||||
@ -73,18 +72,6 @@ static int set_keylog_file(SSL_CTX *ctx, const char *keylog_file);
|
||||
*/
|
||||
static BIO *session_bio = NULL;
|
||||
|
||||
/**
|
||||
* @brief A static pointer to a BIO object used for logging key material.
|
||||
*
|
||||
* This variable holds a reference to a BIO object that is used to log
|
||||
* cryptographic key material for debugging purposes. It is initialized to
|
||||
* NULL and should be assigned a valid BIO object before use.
|
||||
*
|
||||
* @note This variable is static, meaning it is only accessible within the
|
||||
* file in which it is declared.
|
||||
*/
|
||||
static BIO *bio_keylog = NULL;
|
||||
|
||||
/**
|
||||
* @brief Creates a BIO object for a UDP socket connection to a server.
|
||||
*
|
||||
@ -349,84 +336,6 @@ static int handle_io_failure(SSL *ssl, int res)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Callback function to log key material during an SSL session.
|
||||
*
|
||||
* This function is invoked by OpenSSL when key material needs to be logged
|
||||
* for debugging purposes. It writes the provided key log line to the
|
||||
* `bio_keylog` BIO, ensuring thread-safe output by writing the entire line
|
||||
* at once.
|
||||
*
|
||||
* @param ssl A pointer to the SSL object associated with the session.
|
||||
* @param line The key log line to be written.
|
||||
*
|
||||
* @note If `bio_keylog` is NULL, an error message is printed to stderr, and
|
||||
* the function returns without logging the key material.
|
||||
*/
|
||||
static void keylog_callback(const SSL *ssl, const char *line)
|
||||
{
|
||||
if (bio_keylog == NULL) {
|
||||
fprintf(stderr, "Keylog callback is invoked without valid file!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* There might be concurrent writers to the keylog file, so we must ensure
|
||||
* that the given line is written at once.
|
||||
*/
|
||||
BIO_printf(bio_keylog, "%s\n", line);
|
||||
(void)BIO_flush(bio_keylog);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets up the key logging file for an SSL context.
|
||||
*
|
||||
* This function configures a file to log SSL/TLS key material for the
|
||||
* provided SSL context. If a keylog file is specified, it will be opened
|
||||
* in append mode, allowing for concurrent writes and preserving existing
|
||||
* logs. If no keylog file is provided, key logging is disabled.
|
||||
*
|
||||
* @param ctx A pointer to the SSL_CTX object where the keylog file is set.
|
||||
* @param keylog_file The path to the keylog file. If NULL, key logging is
|
||||
* disabled.
|
||||
* @return 0 on success, or 1 if there was an error opening the keylog file.
|
||||
*
|
||||
* @note The function writes a header to the keylog file if it is empty and
|
||||
* seekable. It also ensures that any previously opened keylog files are
|
||||
* closed before opening a new one.
|
||||
*/
|
||||
static int set_keylog_file(SSL_CTX *ctx, const char *keylog_file)
|
||||
{
|
||||
/* Close any open files */
|
||||
BIO_free_all(bio_keylog);
|
||||
bio_keylog = NULL;
|
||||
|
||||
if (ctx == NULL || keylog_file == NULL) {
|
||||
/* Keylogging is disabled, OK. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Append rather than write in order to allow concurrent modification.
|
||||
* Furthermore, this preserves existing keylog files which is useful when
|
||||
* the tool is run multiple times.
|
||||
*/
|
||||
bio_keylog = BIO_new_file(keylog_file, "a");
|
||||
if (bio_keylog == NULL) {
|
||||
printf("Error writing keylog file %s\n", keylog_file);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Write a header for seekable, empty files (this excludes pipes). */
|
||||
if (BIO_tell(bio_keylog) == 0) {
|
||||
BIO_puts(bio_keylog,
|
||||
"# SSL/TLS secrets log file, generated by OpenSSL\n");
|
||||
(void)BIO_flush(bio_keylog);
|
||||
}
|
||||
SSL_CTX_set_keylog_callback(ctx, keylog_callback);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief A static integer indicating whether the session is cached.
|
||||
*
|
||||
@ -778,7 +687,6 @@ static int setup_connection(char *hostname, char *port, int ipv6,
|
||||
{
|
||||
unsigned char alpn[] = {10, 'h', 'q', '-', 'i', 'n', 't', 'e', 'r', 'o', 'p'};
|
||||
int ret = 0;
|
||||
char *sslkeylogfile = NULL;
|
||||
BIO *bio = NULL;
|
||||
|
||||
/*
|
||||
@ -810,11 +718,6 @@ static int setup_connection(char *hostname, char *port, int ipv6,
|
||||
goto end;
|
||||
}
|
||||
|
||||
sslkeylogfile = getenv("SSLKEYLOGFILE");
|
||||
if (sslkeylogfile != NULL)
|
||||
if (set_keylog_file(*ctx, sslkeylogfile))
|
||||
goto end;
|
||||
|
||||
/*
|
||||
* If the SSL_CIPHER_SUITES env variable is set, assign those
|
||||
* ciphers to the context
|
||||
|
Loading…
Reference in New Issue
Block a user