summaryrefslogtreecommitdiffstats
path: root/ssl
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2023-08-17 14:32:00 +0100
committerMatt Caswell <matt@openssl.org>2023-08-24 10:33:58 +0100
commitcb931288730d3ad3e3a6ad9a9db13a8180d31ed9 (patch)
tree8591150f42baa002e36ffd3189002274eab670b3 /ssl
parent5ffad4bad9bd701cc3d14c96304484884ace0831 (diff)
Add the ability to set SSL_trace as the msg_callback in tserver
This is useful for debugging purposes. The standard SSL_trace msgcallback can be used with tserver. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Hugo Landau <hlandau@openssl.org> (Merged from https://github.com/openssl/openssl/pull/21800)
Diffstat (limited to 'ssl')
-rw-r--r--ssl/quic/quic_tserver.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/ssl/quic/quic_tserver.c b/ssl/quic/quic_tserver.c
index 5401453dc5..366673f5cb 100644
--- a/ssl/quic/quic_tserver.c
+++ b/ssl/quic/quic_tserver.c
@@ -12,6 +12,7 @@
#include "internal/quic_statm.h"
#include "internal/common.h"
#include "internal/time.h"
+#include "quic_local.h"
/*
* QUIC Test Server Module
@@ -20,6 +21,9 @@
struct quic_tserver_st {
QUIC_TSERVER_ARGS args;
+ /* Dummy SSL object for this QUIC connection for use by msg_callback */
+ SSL *ssl;
+
/*
* The QUIC channel providing the core QUIC connection implementation.
*/
@@ -72,6 +76,7 @@ QUIC_TSERVER *ossl_quic_tserver_new(const QUIC_TSERVER_ARGS *args,
{
QUIC_TSERVER *srv = NULL;
QUIC_CHANNEL_ARGS ch_args = {0};
+ QUIC_CONNECTION *qc = NULL;
if (args->net_rbio == NULL || args->net_wbio == NULL)
goto err;
@@ -121,6 +126,13 @@ QUIC_TSERVER *ossl_quic_tserver_new(const QUIC_TSERVER_ARGS *args,
|| !ossl_quic_channel_set_net_wbio(srv->ch, srv->args.net_wbio))
goto err;
+ qc = OPENSSL_zalloc(sizeof(*qc));
+ if (qc == NULL)
+ goto err;
+ srv->ssl = (SSL *)qc;
+ qc->ch = srv->ch;
+ srv->ssl->type = SSL_TYPE_QUIC_CONNECTION;
+
return srv;
err:
@@ -132,6 +144,7 @@ err:
#if defined(OPENSSL_THREADS)
ossl_crypto_mutex_free(&srv->mutex);
#endif
+ OPENSSL_free(qc);
}
OPENSSL_free(srv);
@@ -146,6 +159,7 @@ void ossl_quic_tserver_free(QUIC_TSERVER *srv)
ossl_quic_channel_free(srv->ch);
BIO_free(srv->args.net_rbio);
BIO_free(srv->args.net_wbio);
+ OPENSSL_free(srv->ssl);
SSL_free(srv->tls);
SSL_CTX_free(srv->ctx);
#if defined(OPENSSL_THREADS)
@@ -526,8 +540,10 @@ void ossl_quic_tserver_set_msg_callback(QUIC_TSERVER *srv,
SSL *ssl, void *arg),
void *arg)
{
- ossl_quic_channel_set_msg_callback(srv->ch, f, NULL);
+ ossl_quic_channel_set_msg_callback(srv->ch, f, srv->ssl);
ossl_quic_channel_set_msg_callback_arg(srv->ch, arg);
+ SSL_set_msg_callback(srv->tls, f);
+ SSL_set_msg_callback_arg(srv->tls, arg);
}
int ossl_quic_tserver_new_ticket(QUIC_TSERVER *srv)