QUIC SSL: Restrict SSL_CTX_set_ssl_version, SSL_set_ssl_method
authorHugo Landau <hlandau@openssl.org>
Mon, 16 Jan 2023 15:33:01 +0000 (15:33 +0000)
committerPauli <pauli@openssl.org>
Tue, 4 Jul 2023 23:02:27 +0000 (09:02 +1000)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20061)

doc/man3/BIO_f_ssl.pod
doc/man3/SSL_CTX_set_ssl_version.pod
ssl/ssl_lib.c

index 365168646abfd8b732880a10490401ea83605b55..371c124388de9c48d7fe5e4385fc278d207e2525 100644 (file)
@@ -131,6 +131,8 @@ BIO_set_ssl(), BIO_get_ssl(), BIO_set_ssl_mode(),
 BIO_set_ssl_renegotiate_bytes(), BIO_set_ssl_renegotiate_timeout(),
 BIO_get_num_renegotiates(), and BIO_do_handshake() are implemented as macros.
 
+BIO_ssl_copy_session_id() is not currently supported on QUIC SSL objects.
+
 =head1 RETURN VALUES
 
 BIO_f_ssl() returns the SSL B<BIO_METHOD> structure.
index 10aa63f729c80bec13718735fde01064c0461521..a311b1bf58f780ac5a628702a831ebb8325ac1fa 100644 (file)
@@ -47,6 +47,9 @@ it would usually be preferable to create a new SSL_CTX object than to
 try to reuse an existing one in this fashion.  Its usage is considered
 deprecated.
 
+SSL_set_ssl_method() cannot be used to change a non-QUIC SSL object to a QUIC
+SSL object or vice versa.
+
 =head1 RETURN VALUES
 
 The following return values can occur for SSL_CTX_set_ssl_version()
index ce3a4cc89f4f47024cdc4807c67f00bf9d9c3fc5..057c8e895a21d03ba4c1e64bf486af5674ba5b22 100644 (file)
@@ -672,6 +672,11 @@ int SSL_CTX_set_ssl_version(SSL_CTX *ctx, const SSL_METHOD *meth)
 {
     STACK_OF(SSL_CIPHER) *sk;
 
+    if (IS_QUIC_CTX(ctx)) {
+        ERR_raise(ERR_LIB_SSL, SSL_R_WRONG_SSL_VERSION);
+        return 0;
+    }
+
     ctx->method = meth;
 
     if (!SSL_CTX_set_ciphersuites(ctx, OSSL_default_ciphersuites())) {
@@ -1990,7 +1995,7 @@ STACK_OF(X509) *SSL_get_peer_cert_chain(const SSL *s)
 int SSL_copy_session_id(SSL *t, const SSL *f)
 {
     int i;
-    /* TODO(QUIC): Do we want to support this for QUIC connections? */
+    /* TODO(QUIC): Not allowed for QUIC currently. */
     SSL_CONNECTION *tsc = SSL_CONNECTION_FROM_SSL_ONLY(t);
     const SSL_CONNECTION *fsc = SSL_CONNECTION_FROM_CONST_SSL_ONLY(f);
 
@@ -4530,9 +4535,10 @@ int SSL_set_ssl_method(SSL *s, const SSL_METHOD *meth)
     int ret = 1;
     SSL_CONNECTION *sc = SSL_CONNECTION_FROM_SSL(s);
 
-    /* TODO(QUIC): Do we want this for QUIC? */
+    /* Not allowed for QUIC */
     if (sc == NULL
-        || (s->type != SSL_TYPE_SSL_CONNECTION && s->method != meth))
+        || (s->type != SSL_TYPE_SSL_CONNECTION && s->method != meth)
+        || (s->type == SSL_TYPE_SSL_CONNECTION && IS_QUIC_METHOD(meth)))
         return 0;
 
     if (s->method != meth) {