QLOG: Wire title-setting code to QUIC_CHANNEL and SSL_CTX
authorHugo Landau <hlandau@openssl.org>
Fri, 8 Sep 2023 12:42:53 +0000 (13:42 +0100)
committerHugo Landau <hlandau@openssl.org>
Fri, 2 Feb 2024 11:49:34 +0000 (11:49 +0000)
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22037)

include/internal/quic_ssl.h
ssl/quic/quic_channel_local.h
ssl/quic/quic_impl.c
ssl/ssl_lib.c
ssl/ssl_local.h

index a9822df7dfeaa5a7e1dce9fe3d5a866489922eca..7a53af7f6502248b2e8b473634fd0948da573676 100644 (file)
@@ -129,6 +129,15 @@ QUIC_CHANNEL *ossl_quic_conn_get_channel(SSL *s);
 int ossl_quic_has_pending(const SSL *s);
 int ossl_quic_get_shutdown(const SSL *s);
 
+/*
+ * Set QLOG diagnostic title. String is copied internally on success and need
+ * not remain allocated. Only has any effect if logging has not already begun.
+ * For use by tests only. Setting this on a context affects any QCSO created
+ * after this is called but does not affect QCSOs already created from a
+ * context.
+ */
+int ossl_quic_set_diag_title(SSL_CTX *ctx, const char *title);
+
 # endif
 
 #endif
index 4cd4dd84b70cda84d936a9207ba4edb65ad146db..564b789f9c2f2cb6c3eea218b3805dace4e60b25 100644 (file)
@@ -439,7 +439,7 @@ struct quic_channel_st {
     size_t                          num_ack_range_scratch;
 
     /* Title for QLOG purposes. We own this copy. */
-    char                            *quic_channel_local;
+    char                            *qlog_title;
 };
 
 # endif
index 1248013a4bb754d76c31bfe9e7a6b7f103edd953..7c0d2c65b776114f82f9f235d61f892bf98c1789 100644 (file)
@@ -1510,6 +1510,7 @@ static int create_channel(QUIC_CONNECTION *qc)
     }
 #ifndef OPENSSL_NO_QLOG
     args.use_qlog   = 1; /* disabled if env not set */
+    args.qlog_title = qc->ssl.ctx->qlog_title;
 #endif
 
     port_args.channel_ctx = qc->ssl.ctx;
@@ -3705,3 +3706,19 @@ QUIC_CHANNEL *ossl_quic_conn_get_channel(SSL *s)
 
     return ctx.qc->ch;
 }
+
+int ossl_quic_set_diag_title(SSL_CTX *ctx, const char *title)
+{
+#ifndef OPENSSL_NO_QLOG
+    OPENSSL_free(ctx->qlog_title);
+    ctx->qlog_title = NULL;
+
+    if (title == NULL)
+        return 1;
+
+    if ((ctx->qlog_title = OPENSSL_strdup(title)) == NULL)
+        return 0;
+#endif
+
+    return 1;
+}
index 71a39a10056c326886d59a7a9134f33ac73265c5..6788d2c1042180f5d7756db7bf5544252bad1f53 100644 (file)
@@ -4214,6 +4214,9 @@ void SSL_CTX_free(SSL_CTX *a)
 #endif
 
     OPENSSL_free(a->propq);
+#ifndef OPENSSL_NO_QLOG
+    OPENSSL_free(a->qlog_title);
+#endif
 
     OPENSSL_free(a);
 }
index 211b72c6fe6eda9c1326b0f37e6230106d43fdba..1db5df46dfaa028728ce9fec9c34eb4fc41574aa 100644 (file)
@@ -1189,6 +1189,10 @@ struct ssl_ctx_st {
     size_t client_cert_type_len;
     unsigned char *server_cert_type;
     size_t server_cert_type_len;
+
+# ifndef OPENSSL_NO_QLOG
+    char *qlog_title; /* Session title for QLOG */
+# endif
 };
 
 typedef struct cert_pkey_st CERT_PKEY;