]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
OpenSSL: Allow systemwide secpolicy overrides for TLS version
authorJouni Malinen <jouni@codeaurora.org>
Tue, 8 Sep 2020 14:55:36 +0000 (17:55 +0300)
committerJouni Malinen <j@w1.fi>
Tue, 8 Sep 2020 16:32:28 +0000 (19:32 +0300)
Explicit configuration to enable TLS v1.0 and/or v1.1 did not work with
systemwide OpenSSL secpolicy=2 cases (e.g., Ubuntu 20.04). Allow such
systemwide configuration to be overridden if the older TLS versions have
been explicitly enabled in the network profile. The default behavior
follows the systemwide policy, but this allows compatibility with old
authentication servers without having to touch the systemwide policy.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
src/crypto/tls_openssl.c

index e73dd7f5b4755ad6643dc17ad97dd2d6429c19fe..f7dfecbbfa3be55a0043bba8f35d619953dde659 100644 (file)
@@ -2995,16 +2995,12 @@ static int tls_set_conn_flags(struct tls_connection *conn, unsigned int flags,
 
                /* Explicit request to enable TLS versions even if needing to
                 * override systemwide policies. */
-               if (flags & TLS_CONN_ENABLE_TLSv1_0) {
+               if (flags & TLS_CONN_ENABLE_TLSv1_0)
                        version = TLS1_VERSION;
-               } else if (flags & TLS_CONN_ENABLE_TLSv1_1) {
-                       if (!(flags & TLS_CONN_DISABLE_TLSv1_0))
-                               version = TLS1_1_VERSION;
-               } else if (flags & TLS_CONN_ENABLE_TLSv1_2) {
-                       if (!(flags & (TLS_CONN_DISABLE_TLSv1_0 |
-                                      TLS_CONN_DISABLE_TLSv1_1)))
-                               version = TLS1_2_VERSION;
-               }
+               else if (flags & TLS_CONN_ENABLE_TLSv1_1)
+                       version = TLS1_1_VERSION;
+               else if (flags & TLS_CONN_ENABLE_TLSv1_2)
+                       version = TLS1_2_VERSION;
                if (!version) {
                        wpa_printf(MSG_DEBUG,
                                   "OpenSSL: Invalid TLS version configuration");
@@ -3018,6 +3014,18 @@ static int tls_set_conn_flags(struct tls_connection *conn, unsigned int flags,
                }
        }
 #endif /* >= 1.1.0 */
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L && \
+       !defined(LIBRESSL_VERSION_NUMBER) && \
+       !defined(OPENSSL_IS_BORINGSSL)
+       if ((flags & (TLS_CONN_ENABLE_TLSv1_0 | TLS_CONN_ENABLE_TLSv1_1)) &&
+           SSL_get_security_level(ssl) >= 2) {
+               /*
+                * Need to drop to security level 1 to allow TLS versions older
+                * than 1.2 to be used when explicitly enabled in configuration.
+                */
+               SSL_set_security_level(conn->ssl, 1);
+       }
+#endif
 
 #ifdef CONFIG_SUITEB
 #ifdef OPENSSL_IS_BORINGSSL