]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Add SSL_CTX_get_max_proto_version() not in openssl 1.0
authorSelva Nair <selva.nair@gmail.com>
Sat, 20 Jan 2018 17:11:34 +0000 (12:11 -0500)
committerGert Doering <gert@greenie.muc.de>
Thu, 25 Jan 2018 08:20:23 +0000 (09:20 +0100)
- No change in functionality. This is used in a subsequent
  patch for extending TLS1.2 support with cryptoapicert

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1516468294-32635-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16304.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry-picked with 2.4/0.9.8 amendments from commit
 9e272106029a41b2110c10334ba8cae0f4afb1b4)

src/openvpn/openssl_compat.h

index 9f1e92a1801d9d52b56f55142abb98e4667a2b69..4b338d2d611caf2cc78f067d889cbca2bbb24829 100644 (file)
@@ -670,6 +670,33 @@ SSL_CTX_get_min_proto_version(SSL_CTX *ctx)
 }
 #endif /* SSL_CTX_get_min_proto_version */
 
+#ifndef SSL_CTX_get_max_proto_version
+/** Return the max SSL protocol version currently enabled in the context.
+ *  If no valid version >= TLS1.0 is found, return 0. */
+static inline int
+SSL_CTX_get_max_proto_version(SSL_CTX *ctx)
+{
+    long sslopt = SSL_CTX_get_options(ctx);
+#ifdef SSL_OP_NO_TLSv1_2
+    if (!(sslopt & SSL_OP_NO_TLSv1_2))
+    {
+       return TLS1_2_VERSION;
+    }
+#endif
+#ifdef SSL_OP_NO_TLSv1_1
+    if (!(sslopt & SSL_OP_NO_TLSv1_1))
+    {
+       return TLS1_1_VERSION;
+    }
+#endif
+    if (!(sslopt & SSL_OP_NO_TLSv1))
+    {
+       return TLS1_VERSION;
+    }
+    return 0;
+}
+#endif /* SSL_CTX_get_max_proto_version */
+
 #ifndef SSL_CTX_set_min_proto_version
 /** Mimics SSL_CTX_set_min_proto_version for OpenSSL < 1.1 */
 static inline int