[Openvpn-devel,v2] Use correct ifdefs for LibreSSL support

Message ID 20190225183531.27399-1-stefan.strogin@gmail.com
State Accepted
Headers show
Series [Openvpn-devel,v2] Use correct ifdefs for LibreSSL support | expand

Commit Message

Stefan Strogin Feb. 25, 2019, 7:35 a.m. UTC
- TLS 1.3 is not ready yet in LibreSSL. Also there is a theoretical
possibility of OpenSSL >=1.1.1 built without TLS 1.3 support.
- EC_KEY_METHOD API and SSL_get1_supported_ciphers are added into LibreSSL
master (not yet released in 2.9.0).
- Some methods that are available since LibreSSL 2.7.0 were thrown away
in ssl_openssl.c regardless of LibreSSL version. Use them with newer LibreSSL.

Signed-off-by: Stefan Strogin <stefan.strogin@gmail.com>
---
 src/openvpn/ssl_openssl.c | 33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

Comments

Arne Schwabe March 3, 2019, 10:41 p.m. UTC | #1
Am 25.02.19 um 19:35 schrieb Stefan Strogin:
> - TLS 1.3 is not ready yet in LibreSSL. Also there is a theoretical
> possibility of OpenSSL >=1.1.1 built without TLS 1.3 support.
> - EC_KEY_METHOD API and SSL_get1_supported_ciphers are added into LibreSSL
> master (not yet released in 2.9.0).
> - Some methods that are available since LibreSSL 2.7.0 were thrown away
> in ssl_openssl.c regardless of LibreSSL version. Use them with newer LibreSSL.
> 

Acked-By: Arne Schwabe <arne@rfc2549.org>

Looks good so far. I am struggling to find a security/release policy how
long LibreSSL SSL versions are still supported. I would be nice to have
some idea when we can remove the LibreSSL 2.7.0 defines.

Arne
Stefan Strogin March 3, 2019, 11:02 p.m. UTC | #2
On 04/03/2019 11:41, Arne Schwabe wrote:
> Looks good so far. I am struggling to find a security/release policy how
> long LibreSSL SSL versions are still supported. I would be nice to have
> some idea when we can remove the LibreSSL 2.7.0 defines.

Thanks Arne!

I am not associated with the OpenBSD or LibreSSL projects, but from open
sources I can find that:

«LibreSSL transitions to a new stable release branch every 6 months in
coordination with the OpenBSD development schedule. LibreSSL stable branches
are updated for 1 year after their corresponding OpenBSD branch is tagged for
release. See below for the current stable release branches.» [1]

LibreSSL 2.6.3 - OpenBSD 6.2 which was released on 9 October 2017.
Therefore LibreSSL 2.6 support should have ended on 9 Oct 2018.
Accordingly LibreSSL 2.7 support will end on 15 April 2019 (one year since
OpenBSD 6.3 release).

[1] https://www.libressl.org/releases.html

--
Stefan
Gert Doering March 4, 2019, 8:01 a.m. UTC | #3
Thanks.

Tested on OpenBSD 6.3 (haven't upgraded that box to 6.4 yet)...

OpenVPN 2.5_git [git:d2master/a47508606be2c635+] x86_64-unknown-openbsd6.3 [SSL (OpenSSL)] [LZO] [LZ4] [MH/RECVDA] [AEAD] built on Mar  4 2019
library versions: LibreSSL 2.7.2, LZO 2.10

.. and passed t_client tests.

Your patch has been applied to the master branch.

commit a47508606be2c6359d4b27c3b65b72dfe4786222
Author: Stefan Strogin
Date:   Mon Feb 25 20:35:31 2019 +0200

     Use correct ifdefs for LibreSSL support

     Signed-off-by: Stefan Strogin <stefan.strogin@gmail.com>
     Acked-by: Arne Schwabe <arne@rfc2549.org>
     Message-Id: <20190225183531.27399-1-stefan.strogin@gmail.com>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg18239.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/ssl_openssl.c b/src/openvpn/ssl_openssl.c
index ddb78da7..8bcebac4 100644
--- a/src/openvpn/ssl_openssl.c
+++ b/src/openvpn/ssl_openssl.c
@@ -465,7 +465,7 @@  tls_ctx_restrict_ciphers_tls13(struct tls_root_ctx *ctx, const char *ciphers)
         return;
     }
 
-#if (OPENSSL_VERSION_NUMBER < 0x1010100fL)
+#if !defined(TLS1_3_VERSION)
     crypto_msg(M_WARN, "Not compiled with OpenSSL 1.1.1 or higher. "
                "Ignoring TLS 1.3 only tls-ciphersuites '%s' setting.",
                ciphers);
@@ -526,7 +526,8 @@  tls_ctx_check_cert_time(const struct tls_root_ctx *ctx)
 
     ASSERT(ctx);
 
-#if OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(LIBRESSL_VERSION_NUMBER)
+#if (OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(LIBRESSL_VERSION_NUMBER)) \
+    || LIBRESSL_VERSION_NUMBER >= 0x2070000fL
     /* OpenSSL 1.0.2 and up */
     cert = SSL_CTX_get0_certificate(ctx->ctx);
 #else
@@ -561,7 +562,8 @@  tls_ctx_check_cert_time(const struct tls_root_ctx *ctx)
     }
 
 cleanup:
-#if OPENSSL_VERSION_NUMBER < 0x10002000L || defined(LIBRESSL_VERSION_NUMBER)
+#if OPENSSL_VERSION_NUMBER < 0x10002000L \
+    || (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x2070000fL)
     SSL_free(ssl);
 #endif
     return;
@@ -1209,7 +1211,9 @@  err:
     return 0;
 }
 
-#if OPENSSL_VERSION_NUMBER > 0x10100000L && !defined(OPENSSL_NO_EC) && !defined(LIBRESSL_VERSION_NUMBER)
+#if ((OPENSSL_VERSION_NUMBER > 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)) \
+     || LIBRESSL_VERSION_NUMBER > 0x2090000fL) \
+    && !defined(OPENSSL_NO_EC)
 
 /* called when EC_KEY is destroyed */
 static void
@@ -1331,7 +1335,7 @@  err:
     }
     return 0;
 }
-#endif /* OPENSSL_VERSION_NUMBER > 1.1.0 dev */
+#endif /* OPENSSL_VERSION_NUMBER > 1.1.0 dev && !defined(OPENSSL_NO_EC) */
 
 int
 tls_ctx_use_management_external_key(struct tls_root_ctx *ctx)
@@ -1340,7 +1344,8 @@  tls_ctx_use_management_external_key(struct tls_root_ctx *ctx)
 
     ASSERT(NULL != ctx);
 
-#if OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(LIBRESSL_VERSION_NUMBER)
+#if (OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(LIBRESSL_VERSION_NUMBER)) \
+    || LIBRESSL_VERSION_NUMBER >= 0x2070000fL
     /* OpenSSL 1.0.2 and up */
     X509 *cert = SSL_CTX_get0_certificate(ctx->ctx);
 #else
@@ -1362,7 +1367,9 @@  tls_ctx_use_management_external_key(struct tls_root_ctx *ctx)
             goto cleanup;
         }
     }
-#if OPENSSL_VERSION_NUMBER > 0x10100000L && !defined(OPENSSL_NO_EC) && !defined(LIBRESSL_VERSION_NUMBER)
+#if ((OPENSSL_VERSION_NUMBER > 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)) \
+     || LIBRESSL_VERSION_NUMBER > 0x2090000fL) \
+    && !defined(OPENSSL_NO_EC)
     else if (EVP_PKEY_id(pkey) == EVP_PKEY_EC)
     {
         if (!tls_ctx_use_external_ec_key(ctx, pkey))
@@ -1375,17 +1382,18 @@  tls_ctx_use_management_external_key(struct tls_root_ctx *ctx)
         crypto_msg(M_WARN, "management-external-key requires an RSA or EC certificate");
         goto cleanup;
     }
-#else  /* if OPENSSL_VERSION_NUMBER > 0x10100000L && !defined(OPENSSL_NO_EC) && !defined(LIBRESSL_VERSION_NUMBER) */
+#else  /* OPENSSL_VERSION_NUMBER > 1.1.0 dev && !defined(OPENSSL_NO_EC) */
     else
     {
         crypto_msg(M_WARN, "management-external-key requires an RSA certificate");
         goto cleanup;
     }
-#endif /* OPENSSL_VERSION_NUMBER > 1.1.0 dev */
+#endif /* OPENSSL_VERSION_NUMBER > 1.1.0 dev && !defined(OPENSSL_NO_EC) */
 
     ret = 0;
 cleanup:
-#if OPENSSL_VERSION_NUMBER < 0x10002000L || defined(LIBRESSL_VERSION_NUMBER)
+#if OPENSSL_VERSION_NUMBER < 0x10002000L \
+    || (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x2070000fL)
     if (ssl)
     {
         SSL_free(ssl);
@@ -1998,7 +2006,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 defined(TLS1_3_VERSION)
     if (tls13)
     {
         SSL_CTX_set_min_proto_version(tls_ctx.ctx, TLS1_3_VERSION);
@@ -2019,7 +2027,8 @@  show_available_tls_ciphers_list(const char *cipher_list,
         crypto_msg(M_FATAL, "Cannot create SSL object");
     }
 
-#if (OPENSSL_VERSION_NUMBER < 0x1010000fL)
+#if (OPENSSL_VERSION_NUMBER < 0x1010000fL) || \
+    (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER <= 0x2090000fL)
     STACK_OF(SSL_CIPHER) *sk = SSL_get_ciphers(ssl);
 #else
     STACK_OF(SSL_CIPHER) *sk = SSL_get1_supported_ciphers(ssl);