From: Hugo Landau Date: Thu, 9 Nov 2023 10:27:13 +0000 (+0000) Subject: QUIC PORT: Record a SSL_CTX for use when creating handshake layer objects X-Git-Tag: openssl-3.3.0-alpha1~436 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=29542870412cea69f9430d8322c9e6f19c1f9dce;p=thirdparty%2Fopenssl.git QUIC PORT: Record a SSL_CTX for use when creating handshake layer objects Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/22674) --- diff --git a/include/internal/quic_port.h b/include/internal/quic_port.h index 86614d607c7..cb277c1971f 100644 --- a/include/internal/quic_port.h +++ b/include/internal/quic_port.h @@ -13,6 +13,7 @@ # include "internal/quic_types.h" # include "internal/quic_reactor.h" # include "internal/quic_demux.h" +# include "internal/quic_predef.h" # include "internal/thread_arch.h" # ifndef OPENSSL_NO_QUIC @@ -50,6 +51,12 @@ typedef struct quic_port_args_st { */ OSSL_TIME (*now_cb)(void *arg); void *now_cb_arg; + + /* + * This SSL_CTX will be used when constructing the handshake layer object + * inside newly created channels. + */ + SSL_CTX *channel_ctx; } QUIC_PORT_ARGS; typedef struct quic_port_st QUIC_PORT; diff --git a/ssl/quic/quic_impl.c b/ssl/quic/quic_impl.c index 618b4f4ac40..45666190cf4 100644 --- a/ssl/quic/quic_impl.c +++ b/ssl/quic/quic_impl.c @@ -1495,6 +1495,7 @@ static int create_channel(QUIC_CONNECTION *qc) port_args.libctx = qc->ssl.ctx->libctx; port_args.propq = qc->ssl.ctx->propq; port_args.mutex = qc->mutex; + port_args.channel_ctx = qc->ssl.ctx; port_args.now_cb = get_time_cb; port_args.now_cb_arg = qc; diff --git a/ssl/quic/quic_port.c b/ssl/quic/quic_port.c index 8b727d2f128..661b6c6cb8c 100644 --- a/ssl/quic/quic_port.c +++ b/ssl/quic/quic_port.c @@ -37,6 +37,7 @@ QUIC_PORT *ossl_quic_port_new(const QUIC_PORT_ARGS *args) port->mutex = args->mutex; port->now_cb = args->now_cb; port->now_cb_arg = args->now_cb_arg; + port->channel_ctx = args->channel_ctx; if (!port_init(port)) { OPENSSL_free(port); @@ -59,6 +60,9 @@ static int port_init(QUIC_PORT *port) { size_t rx_short_cid_len = 8; + if (port->channel_ctx == NULL) + goto err; + if ((port->demux = ossl_quic_demux_new(/*BIO=*/NULL, /*Short CID Len=*/rx_short_cid_len, get_time, port)) == NULL) diff --git a/ssl/quic/quic_port_local.h b/ssl/quic/quic_port_local.h index 7aaf4d6a425..fc0521d02bc 100644 --- a/ssl/quic/quic_port_local.h +++ b/ssl/quic/quic_port_local.h @@ -34,6 +34,9 @@ struct quic_port_st { OSSL_TIME (*now_cb)(void *arg); void *now_cb_arg; + /* Used to create handshake layer objects inside newly created channels. */ + SSL_CTX *channel_ctx; + /* Asynchronous I/O reactor. */ QUIC_REACTOR rtor; diff --git a/ssl/quic/quic_tserver.c b/ssl/quic/quic_tserver.c index b5ba3eeb854..7882cca700e 100644 --- a/ssl/quic/quic_tserver.c +++ b/ssl/quic/quic_tserver.c @@ -120,6 +120,7 @@ QUIC_TSERVER *ossl_quic_tserver_new(const QUIC_TSERVER_ARGS *args, port_args.libctx = srv->args.libctx; port_args.propq = srv->args.propq; port_args.mutex = srv->mutex; + port_args.channel_ctx = srv->ctx; port_args.now_cb = srv->args.now_cb; port_args.now_cb_arg = srv->args.now_cb_arg;