Browse code

Drop support for OpenSSL 1.0.1

OpenSSL 1.0.1 was supported until 2016-12-31. Rhel6/Centos6 still
use this version but considering that RHEL7 and RHEL8 are already
out, these versions can also stay with OpenVPN 2.4.

All the supported Debian based distributions also come with at
least 1.0.2.

We (accidently) unconditionally compiled some key exporter code on
OpenSSL 1.0.2+ without problems. So always compile the whole
key exporter feature for OpenSSL.

This also allows the tls groups commit to be applied without
adding ifdefs to disable that functionality on OpenSSL 1.0.1

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Steffan Karger <steffan.karger@foxcrypto.com>
Message-Id: <20200717134739.21168-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20441.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>

Arne Schwabe authored on 2020/07/17 22:47:32
Showing 9 changed files
... ...
@@ -35,10 +35,6 @@ jobs:
35 35
       env: SSLLIB="openssl" RUN_COVERITY="1"
36 36
       os: linux
37 37
       compiler: gcc
38
-    - name: gcc | openssl-1.0.1u
39
-      env: SSLLIB="openssl" OPENSSL_VERSION="1.0.1u"
40
-      os: linux
41
-      compiler: gcc
42 38
     - name: gcc | openssl-1.1.1d
43 39
       env: SSLLIB="openssl" OPENSSL_VERSION="1.1.1d"
44 40
       os: linux
... ...
@@ -87,10 +83,6 @@ jobs:
87 87
       env: SSLLIB="mbedtls"
88 88
       os: osx
89 89
       compiler: clang
90
-    - name: mingw64 | openssl-1.0.1u
91
-      env: SSLLIB="openssl" CHOST=x86_64-w64-mingw32 OPENSSL_VERSION="1.0.1u"
92
-      os: linux
93
-      compiler: ": Win64 build only"
94 90
     - name: mingw64 | openssl-1.1.1d
95 91
       env: SSLLIB="openssl" CHOST=x86_64-w64-mingw32 OPENSSL_VERSION="1.1.1d"
96 92
       os: linux
... ...
@@ -45,6 +45,10 @@ User-visible Changes
45 45
   client-disconnect-script is now called immediately. Previously it
46 46
   was called, when the VPN session was terminated.
47 47
 
48
+- Support for building with OpenSSL 1.0.1 has been removed. The minimum
49
+  supported OpenSSL version is now 1.0.2.
50
+
51
+
48 52
 Overview of changes in 2.4
49 53
 ==========================
50 54
 
... ...
@@ -71,12 +71,13 @@ REQUIRES:
71 71
   (1) TUN and/or TAP driver to allow user-space programs to control
72 72
       a virtual point-to-point IP or Ethernet device.  See
73 73
       TUN/TAP Driver Configuration section below for more info.
74
-
75
-OPTIONAL (but recommended):
76
-  (1) OpenSSL library, necessary for encryption, version 1.0.1 or higher
74
+  (2) OpenSSL library, necessary for encryption, version 1.0.2 or higher
77 75
       required, available from http://www.openssl.org/
78
-  (2) mbed TLS library, an alternative for encryption, version 2.0 or higher
76
+      or
77
+  (3) mbed TLS library, an alternative for encryption, version 2.0 or higher
79 78
       required, available from https://tls.mbed.org/
79
+
80
+OPTIONAL:
80 81
   (3) LZO real-time compression library, required for link compression,
81 82
       available from http://www.oberhumer.com/opensource/lzo/
82 83
       OpenBSD users can use ports or packages to install lzo, but remember
... ...
@@ -848,7 +848,7 @@ if test "${with_crypto_library}" = "openssl"; then
848 848
 		# if the user did not explicitly specify flags, try to autodetect
849 849
 		PKG_CHECK_MODULES(
850 850
 			[OPENSSL],
851
-			[openssl >= 1.0.1],
851
+			[openssl >= 1.0.2],
852 852
 			[have_openssl="yes"],
853 853
 			[] # If this fails, we will do another test next
854 854
 		)
... ...
@@ -863,7 +863,7 @@ if test "${with_crypto_library}" = "openssl"; then
863 863
 	# If pkgconfig check failed or OPENSSL_CFLAGS/OPENSSL_LIBS env vars
864 864
 	# are used, check the version directly in the OpenSSL include file
865 865
 	if test "${have_openssl}" != "yes"; then
866
-		AC_MSG_CHECKING([additionally if OpenSSL is available and version >= 1.0.1])
866
+		AC_MSG_CHECKING([additionally if OpenSSL is available and version >= 1.0.2])
867 867
 		AC_COMPILE_IFELSE(
868 868
 			[AC_LANG_PROGRAM(
869 869
 				[[
... ...
@@ -871,7 +871,7 @@ if test "${with_crypto_library}" = "openssl"; then
871 871
 				]],
872 872
 				[[
873 873
 /*	     Version encoding: MNNFFPPS - see opensslv.h for details */
874
-#if OPENSSL_VERSION_NUMBER < 0x10001000L
874
+#if OPENSSL_VERSION_NUMBER < 0x10002000L
875 875
 #error OpenSSL too old
876 876
 #endif
877 877
 				]]
... ...
@@ -914,12 +914,9 @@ if test "${with_crypto_library}" = "openssl"; then
914 914
 		[have_crypto_aead_modes="no"]
915 915
 	)
916 916
 
917
+	# All supported OpenSSL version (>= 1.0.2)
918
+	# have this feature
917 919
 	have_export_keying_material="yes"
918
-	AC_CHECK_FUNC(
919
-		[SSL_export_keying_material],
920
-		,
921
-		[have_export_keying_material="no"]
922
-	)
923 920
 
924 921
 	AC_CHECK_FUNCS(
925 922
 		[ \
... ...
@@ -940,7 +937,6 @@ if test "${with_crypto_library}" = "openssl"; then
940 940
 			X509_STORE_get0_objects \
941 941
 			X509_OBJECT_free \
942 942
 			X509_OBJECT_get_type \
943
-			EVP_PKEY_id \
944 943
 			EVP_PKEY_get0_RSA \
945 944
 			EVP_PKEY_get0_DSA \
946 945
 			EVP_PKEY_get0_EC_KEY \
... ...
@@ -428,13 +428,6 @@ openvpn_decrypt_aead(struct buffer *buf, struct buffer work,
428 428
     tag_ptr = BPTR(buf);
429 429
     ASSERT(buf_advance(buf, tag_size));
430 430
     dmsg(D_PACKET_CONTENT, "DECRYPT MAC: %s", format_hex(tag_ptr, tag_size, 0, &gc));
431
-#if defined(ENABLE_CRYPTO_OPENSSL) && OPENSSL_VERSION_NUMBER < 0x10001040L
432
-    /* OpenSSL <= 1.0.1c bug requires set tag before processing ciphertext */
433
-    if (!EVP_CIPHER_CTX_ctrl(ctx->cipher, EVP_CTRL_GCM_SET_TAG, tag_size, tag_ptr))
434
-    {
435
-        CRYPT_ERROR("setting tag failed");
436
-    }
437
-#endif
438 431
 
439 432
     if (buf->len < 1)
440 433
     {
... ...
@@ -271,20 +271,6 @@ EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey)
271 271
 }
272 272
 #endif
273 273
 
274
-#if !defined(HAVE_EVP_PKEY_ID)
275
-/**
276
- * Get the PKEY type
277
- *
278
- * @param pkey                Public key object
279
- * @return                    The key type
280
- */
281
-static inline int
282
-EVP_PKEY_id(const EVP_PKEY *pkey)
283
-{
284
-    return pkey ? pkey->type : EVP_PKEY_NONE;
285
-}
286
-#endif
287
-
288 274
 #if !defined(HAVE_EVP_PKEY_GET0_DSA)
289 275
 /**
290 276
  * Get the DSA object of a public key
... ...
@@ -8670,7 +8670,7 @@ add_option(struct options *options,
8670 8670
         options->keying_material_exporter_label = p[1];
8671 8671
         options->keying_material_exporter_length = ekm_length;
8672 8672
     }
8673
-#endif /* if defined(ENABLE_CRYPTO_OPENSSL) && OPENSSL_VERSION_NUMBER >= 0x10001000 */
8673
+#endif /* HAVE_EXPORT_KEYING_MATERIAL */
8674 8674
     else if (streq(p[0], "allow-recursive-routing") && !p[1])
8675 8675
     {
8676 8676
         VERIFY_PERMISSION(OPT_P_GENERAL);
... ...
@@ -1108,7 +1108,7 @@ key_state_ssl_init(struct key_state_ssl *ks_ssl,
1108 1108
         }
1109 1109
     }
1110 1110
 
1111
-#if HAVE_EXPORT_KEYING_MATERIAL
1111
+#ifdef HAVE_EXPORT_KEYING_MATERIAL
1112 1112
     /* Initialize keying material exporter */
1113 1113
     if (session->opt->ekm_size)
1114 1114
     {
... ...
@@ -164,7 +164,6 @@ key_state_export_keying_material(struct key_state_ssl *ssl,
164 164
 {
165 165
     if (session->opt->ekm_size > 0)
166 166
     {
167
-#if (OPENSSL_VERSION_NUMBER >= 0x10001000)
168 167
         unsigned int size = session->opt->ekm_size;
169 168
         struct gc_arena gc = gc_new();
170 169
         unsigned char *ekm = (unsigned char *) gc_malloc(size, true, &gc);
... ...
@@ -188,7 +187,6 @@ key_state_export_keying_material(struct key_state_ssl *ssl,
188 188
             setenv_del(session->opt->es, "exported_keying_material");
189 189
         }
190 190
         gc_free(&gc);
191
-#endif /* if (OPENSSL_VERSION_NUMBER >= 0x10001000) */
192 191
     }
193 192
 }
194 193
 
... ...
@@ -559,7 +557,7 @@ tls_ctx_set_cert_profile(struct tls_root_ctx *ctx, const char *profile)
559 559
 #else  /* ifdef HAVE_SSL_CTX_SET_SECURITY_LEVEL */
560 560
     if (profile)
561 561
     {
562
-        msg(M_WARN, "WARNING: OpenSSL 1.0.1 does not support --tls-cert-profile"
562
+        msg(M_WARN, "WARNING: OpenSSL 1.0.2 does not support --tls-cert-profile"
563 563
             ", ignoring user-set profile: '%s'", profile);
564 564
     }
565 565
 #endif /* ifdef HAVE_SSL_CTX_SET_SECURITY_LEVEL */
... ...
@@ -573,19 +571,11 @@ tls_ctx_check_cert_time(const struct tls_root_ctx *ctx)
573 573
 
574 574
     ASSERT(ctx);
575 575
 
576
-#if (OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(LIBRESSL_VERSION_NUMBER)) \
577
-    || LIBRESSL_VERSION_NUMBER >= 0x2070000fL
578
-    /* OpenSSL 1.0.2 and up */
579 576
     cert = SSL_CTX_get0_certificate(ctx->ctx);
580
-#else
581
-    /* OpenSSL 1.0.1 and earlier need an SSL object to get at the certificate */
582
-    SSL *ssl = SSL_new(ctx->ctx);
583
-    cert = SSL_get_certificate(ssl);
584
-#endif
585 577
 
586 578
     if (cert == NULL)
587 579
     {
588
-        goto cleanup; /* Nothing to check if there is no certificate */
580
+        return; /* Nothing to check if there is no certificate */
589 581
     }
590 582
 
591 583
     ret = X509_cmp_time(X509_get0_notBefore(cert), NULL);
... ...
@@ -607,13 +597,6 @@ tls_ctx_check_cert_time(const struct tls_root_ctx *ctx)
607 607
     {
608 608
         msg(M_WARN, "WARNING: Your certificate has expired!");
609 609
     }
610
-
611
-cleanup:
612
-#if OPENSSL_VERSION_NUMBER < 0x10002000L \
613
-    || (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x2070000fL)
614
-    SSL_free(ssl);
615
-#endif
616
-    return;
617 610
 }
618 611
 
619 612
 void
... ...
@@ -680,7 +663,6 @@ tls_ctx_load_ecdh_params(struct tls_root_ctx *ctx, const char *curve_name
680 680
     }
681 681
     else
682 682
     {
683
-#if OPENSSL_VERSION_NUMBER >= 0x10002000L
684 683
 #if (OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER))
685 684
 
686 685
         /* OpenSSL 1.0.2 and newer can automatically handle ECDH parameter
... ...
@@ -691,29 +673,6 @@ tls_ctx_load_ecdh_params(struct tls_root_ctx *ctx, const char *curve_name
691 691
          * so do nothing */
692 692
 #endif
693 693
         return;
694
-#else  /* if OPENSSL_VERSION_NUMBER >= 0x10002000L */
695
-        /* For older OpenSSL we have to extract the curve from key on our own */
696
-        EC_KEY *eckey = NULL;
697
-        const EC_GROUP *ecgrp = NULL;
698
-        EVP_PKEY *pkey = NULL;
699
-
700
-        /* Little hack to get private key ref from SSL_CTX, yay OpenSSL... */
701
-        SSL *ssl = SSL_new(ctx->ctx);
702
-        if (!ssl)
703
-        {
704
-            crypto_msg(M_FATAL, "SSL_new failed");
705
-        }
706
-        pkey = SSL_get_privatekey(ssl);
707
-        SSL_free(ssl);
708
-
709
-        msg(D_TLS_DEBUG, "Extracting ECDH curve from private key");
710
-
711
-        if (pkey != NULL && (eckey = EVP_PKEY_get1_EC_KEY(pkey)) != NULL
712
-            && (ecgrp = EC_KEY_get0_group(eckey)) != NULL)
713
-        {
714
-            nid = EC_GROUP_get_curve_name(ecgrp);
715
-        }
716
-#endif /* if OPENSSL_VERSION_NUMBER >= 0x10002000L */
717 694
     }
718 695
 
719 696
     /* Translate NID back to name , just for kicks */
... ...
@@ -1462,15 +1421,7 @@ tls_ctx_use_management_external_key(struct tls_root_ctx *ctx)
1462 1462
 
1463 1463
     ASSERT(NULL != ctx);
1464 1464
 
1465
-#if (OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(LIBRESSL_VERSION_NUMBER)) \
1466
-    || LIBRESSL_VERSION_NUMBER >= 0x2070000fL
1467
-    /* OpenSSL 1.0.2 and up */
1468 1465
     X509 *cert = SSL_CTX_get0_certificate(ctx->ctx);
1469
-#else
1470
-    /* OpenSSL 1.0.1 and earlier need an SSL object to get at the certificate */
1471
-    SSL *ssl = SSL_new(ctx->ctx);
1472
-    X509 *cert = SSL_get_certificate(ssl);
1473
-#endif
1474 1466
 
1475 1467
     ASSERT(NULL != cert);
1476 1468
 
... ...
@@ -1510,13 +1461,6 @@ tls_ctx_use_management_external_key(struct tls_root_ctx *ctx)
1510 1510
 
1511 1511
     ret = 0;
1512 1512
 cleanup:
1513
-#if OPENSSL_VERSION_NUMBER < 0x10002000L \
1514
-    || (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x2070000fL)
1515
-    if (ssl)
1516
-    {
1517
-        SSL_free(ssl);
1518
-    }
1519
-#endif
1520 1513
     if (ret)
1521 1514
     {
1522 1515
         crypto_msg(M_FATAL, "Cannot enable SSL external private key capability");