Skip to contentSkip to conversation

v2: fix release/2.4 regression of 2.4.7, permit build with LibreSSL

Openvpn-devel In review Matthias Andree 3 participants 6 messages Aug 18, 2019 – Sep 21, 2019

lore
Share & tools
lore
#0 lore raw

It was deemed that the previous patch was insufficient, so let's take a new stab. Note that this does not mean I endorse using LibreSSL, but at least we should not be breaking existing library support in a point release 2.4.7 (that cannot be compiled against LibreSSL) when 2.4.6 could.

Details on the rationale also in the subsequent patch's description.

#1 lore raw

PATCH 1/1 Fix regression, reinstate LibreSSL support.

OpenVPN 2.4.6 could be compiled with LibreSSL, 2.4.7 cannot. This was broken since 9de7fe0a "Add support for tls-ciphersuites for TLS 1.3".

This patch avoids using TLS 1.3 directly, be it that OpenSSL was compiled without TLS 1.3 support, or LibreSSL was used.

This patch was based on an OpenBSD patch by
Jeremie Courreges-Anglas <[email protected]...>, see
https://cvsweb.openbsd.org/cgi-bin/cvsweb/ports/net/openvpn/patches/patch-src_openvpn_ssl_openssl_c
but was revised to be more obvious and check actual feature macros, do not rely on current LibreSSL implementation details alone.

Franco Fichtner reports that OPNsense has been a long-time user of LibreSSL without reported breakage, see also:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=238382#c10

---
 src/openvpn/ssl_openssl.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
src/openvpn/ssl_openssl.c +5 -5
index a78dae99..293bb192 100644
@@ -206,7 +206,7 @@ info_callback(INFO_CALLBACK_SSL_CONST SSL *s, int where, int ret)
 int
 tls_version_max(void)
 {
-#if defined(TLS1_3_VERSION)
+#if defined(TLS1_3_VERSION) && !defined(OPENSSL_NO_TLS1_3)
     return TLS_VER_1_3;
 #elif defined(TLS1_2_VERSION) || defined(SSL_OP_NO_TLSv1_2)
     return TLS_VER_1_2;
@@ -233,7 +233,7 @@ openssl_tls_version(int ver)
     {
         return TLS1_2_VERSION;
     }
-#if defined(TLS1_3_VERSION)
+#if defined(TLS1_3_VERSION) && !defined(OPENSSL_NO_TLS1_3)
     else if (ver == TLS_VER_1_3)
     {
         return TLS1_3_VERSION;
@@ -459,8 +459,8 @@ tls_ctx_restrict_ciphers_tls13(struct tls_root_ctx *ctx, const char *ciphers)
         return;
     }
 
-#if (OPENSSL_VERSION_NUMBER < 0x1010100fL)
-        crypto_msg(M_WARN, "Not compiled with OpenSSL 1.1.1 or higher. "
+#if (OPENSSL_VERSION_NUMBER < 0x1010100fL) || !defined(TLS1_3_VERSION) || defined(OPENSSL_NO_TLS1_3)
+        crypto_msg(M_WARN, "Not compiled with OpenSSL 1.1.1 or higher, or without TLS 1.3 support. "
                        "Ignoring TLS 1.3 only tls-ciphersuites '%s' setting.",
                         ciphers);
 #else
@@ -1846,7 +1846,7 @@ show_available_tls_ciphers_list(const char *cipher_list,
         crypto_msg(M_FATAL, "Cannot create SSL_CTX object");
     }
 
-#if (OPENSSL_VERSION_NUMBER >= 0x1010100fL)
+#if (OPENSSL_VERSION_NUMBER >= 0x1010100fL) && defined(TLS1_3_VERSION) && !defined(OPENSSL_NO_TLS1_3)
     if (tls13)
     {
         SSL_CTX_set_min_proto_version(tls_ctx.ctx, TLS1_3_VERSION);

--
2.21.0

Acked-by on v1 1/1
#2 lore raw

Re: [Openvpn-devel] [PATCH] Fix regression, reinstate LibreSSL support.

Am 18.08.19 um 13:18 schrieb Matthias Andree:

Quoted 5 lines

OpenVPN 2.4.6 could be compiled with LibreSSL, 2.4.7 cannot. This was broken since 9de7fe0a "Add support for tls-ciphersuites for TLS 1.3".

This patch avoids using TLS 1.3 directly, be it that OpenSSL was compiled without TLS 1.3 support, or LibreSSL was used.

Test looks good. I don't like the additonal ifdefs but yeah seem no way around them.

The ifdefs don't break OpenSSL. But I have not tested LibreSSL.

#3 lore raw

Re: [Openvpn-devel] [PATCH] Fix regression, reinstate LibreSSL support.

Am 18.08.19 um 14:11 schrieb Arne Schwabe:

Quoted 6 lines

Am 18.08.19 um 13:18 schrieb Matthias Andree:

Quoted 5 lines

OpenVPN 2.4.6 could be compiled with LibreSSL, 2.4.7 cannot. This was broken since 9de7fe0a "Add support for tls-ciphersuites for TLS 1.3".

This patch avoids using TLS 1.3 directly, be it that OpenSSL was compiled without TLS 1.3 support, or LibreSSL was used.

Quoted 7 lines

Test looks good. I don't like the additonal ifdefs but yeah seem no way around them.

The ifdefs don't break OpenSSL. But I have not tested LibreSSL.

So, four weeks later, what is the commit status of this change?

I don't yet see it in Git and no relevant messages here.

#4 lore raw

[Openvpn-devel] [PATCH applied] Re: Fix regression, reinstate LibreSSL support.

In reply to Matthias Andree

Your patch has been applied to the release/2.4 branch.

Sorry for the delay. Vacation, and too many distractions.

Lightly tested on an OpenSSL 1.1, a mbedTLS build and an LibreSSL 2.7.2 on OpenBSD 6.3 - with OpenSSL and mbedTLS, it builds and passes all tests.

With LibreSSL 2.7.2, it fails due to

./../../openvpn.git/src/openvpn/ssl_openssl.c:1873: undefined reference to `SSL_get1_supported_ciphers'

which looks like this:

#if (OPENSSL_VERSION_NUMBER < 0x1010000fL)
    STACK_OF(SSL_CIPHER) *sk = SSL_get_ciphers(ssl);
#else
    STACK_OF(SSL_CIPHER) *sk = SSL_get1_supported_ciphers(ssl);   

#endif

this is code which has been in release/2.4 for quite some time (part of the TLS 1.3 support, commit e8467c864, "--show-tls" enhancements) - so if it doesn't break for you, I assume that the call was added to more recent LibreSSL versions.

commit c8823f7b09c3a6a2101b54763ac2ef146d372328 (release/2.4)

Author: Matthias Andree
Date:   Sun Aug 18 13:18:11 2019 +0200
     Fix regression, reinstate LibreSSL support.

     Signed-off-by: Matthias Andree <[email protected]...>
     Acked-by: Arne Schwabe <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg18790.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw

Re: [Openvpn-devel] [PATCH applied] Re: Fix regression, reinstate LibreSSL support.

Am 18.09.19 um 14:01 schrieb Gert Doering:

Quoted 18 lines

Your patch has been applied to the release/2.4 branch.

Sorry for the delay. Vacation, and too many distractions.

Lightly tested on an OpenSSL 1.1, a mbedTLS build and an LibreSSL 2.7.2 on OpenBSD 6.3 - with OpenSSL and mbedTLS, it builds and passes all tests.

With LibreSSL 2.7.2, it fails due to

./../../openvpn.git/src/openvpn/ssl_openssl.c:1873: undefined reference to `SSL_get1_supported_ciphers'

which looks like this:

#if (OPENSSL_VERSION_NUMBER < 0x1010000fL)
    STACK_OF(SSL_CIPHER) *sk = SSL_get_ciphers(ssl);
#else
    STACK_OF(SSL_CIPHER) *sk = SSL_get1_supported_ciphers(ssl);   
Quoted 6 lines

#endif

this is code which has been in release/2.4 for quite some time (part of the TLS 1.3 support, commit e8467c864, "--show-tls" enhancements) - so if it doesn't break for you, I assume that the call was added to more recent LibreSSL versions.

I was testing against LibreSSL 2.9.2, the oldest for FreeBSD, and this particular call is listed in the OpenBSD 6.5 changelog here:
https://www.openbsd.org/plus65.html "Provided SSL_get_client_ciphers() and SSL_get1_supported_ciphers() (part of the OpenSSL 1.1 API)." But I haven't figured out when or where this was added to LibreSSL releases.

It really looks to me that there isn't a strategy for LibreSSL, but I'll not backport things to old LibreSSL version, the answer should be "upgrade or else leave it to your packager/distributor".