QUIC PORT: Record a SSL_CTX for use when creating handshake layer objects
authorHugo Landau <hlandau@openssl.org>
Thu, 9 Nov 2023 10:27:13 +0000 (10:27 +0000)
committerHugo Landau <hlandau@openssl.org>
Thu, 21 Dec 2023 08:11:59 +0000 (08:11 +0000)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22674)

include/internal/quic_port.h
ssl/quic/quic_impl.c
ssl/quic/quic_port.c
ssl/quic/quic_port_local.h
ssl/quic/quic_tserver.c

index 86614d607c72863fb88c0bbcb4d1bcc940d040ad..cb277c1971fc3e73394bf420b0e009a5729282f0 100644 (file)
@@ -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;
index 618b4f4ac40fe534435d8a19258f64658987b8ae..45666190cf4817835700f3a762e3c430d09b2b04 100644 (file)
@@ -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;
 
index 8b727d2f128be7ff4c9899b897deabe75bd4b1ec..661b6c6cb8ca186312d0c8d97875062695fd4fa9 100644 (file)
@@ -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)
index 7aaf4d6a425d8a46a9042f98b7f16936cfd29336..fc0521d02bc0135ca75f6374d2a526e07b00cdcd 100644 (file)
@@ -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;
 
index b5ba3eeb854ed6488e2434831a89a4ca8dc0f906..7882cca700ede8e6579f0345dd15c2053fa04354 100644 (file)
@@ -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;