This is an automated email from the ASF dual-hosted git repository. remm pushed a commit to branch 10.1.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push: new b225c69cb0 Propagate OpenSSL variant identification b225c69cb0 is described below commit b225c69cb07846bd0952a1378cec505733fc6c44 Author: remm <r...@apache.org> AuthorDate: Mon Oct 7 09:38:10 2024 +0200 Propagate OpenSSL variant identification This could be used to cleanup the testsuite behavior by skipping some tests for some unsupported combinations (for example with renegotiation). --- .../tomcat/util/net/openssl/OpenSSLStatus.java | 30 ++++++++++++++++++++++ .../util/net/openssl/panama/OpenSSLLibrary.java | 9 +++++++ .../util/openssl/openssl_h_Compatibility.java | 4 ++- 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/java/org/apache/tomcat/util/net/openssl/OpenSSLStatus.java b/java/org/apache/tomcat/util/net/openssl/OpenSSLStatus.java index ae190beff0..daf346d5b8 100644 --- a/java/org/apache/tomcat/util/net/openssl/OpenSSLStatus.java +++ b/java/org/apache/tomcat/util/net/openssl/OpenSSLStatus.java @@ -20,12 +20,21 @@ package org.apache.tomcat.util.net.openssl; * Holds OpenSSL status without the need to load other classes. */ public class OpenSSLStatus { + + /** + * OpenSSL library variant that has been identified + */ + public enum Name { + OPENSSL, OPENSSL3, LIBRESSL, BORINGSSL, UNKNOWN + } + private static volatile boolean libraryInitialized = false; private static volatile boolean initialized = false; private static volatile boolean available = false; private static volatile boolean useOpenSSL = true; private static volatile boolean instanceCreated = false; private static volatile long version = 0; + private static volatile Name name = Name.UNKNOWN; public static boolean isLibraryInitialized() { @@ -82,4 +91,25 @@ public class OpenSSLStatus { OpenSSLStatus.version = version; } + /** + * @return the library name + */ + public static Name getName() { + return name; + } + + /** + * @param name the name to set + */ + public static void setName(Name name) { + OpenSSLStatus.name = name; + } + + /** + * @return true if running with OpenSSL 3.0+ + */ + public static boolean isOpenSSL3() { + return Name.OPENSSL3.equals(name); + } + } diff --git a/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLLibrary.java b/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLLibrary.java index 17204fd274..e6320133bb 100644 --- a/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLLibrary.java +++ b/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLLibrary.java @@ -182,6 +182,15 @@ public class OpenSSLLibrary { initLibrary(); OpenSSLStatus.setVersion(OpenSSL_version_num()); + if (openssl_h_Compatibility.OPENSSL3) { + OpenSSLStatus.setName(OpenSSLStatus.Name.OPENSSL3); + } else if (openssl_h_Compatibility.OPENSSL) { + OpenSSLStatus.setName(OpenSSLStatus.Name.OPENSSL); + } else if (openssl_h_Compatibility.LIBRESSL) { + OpenSSLStatus.setName(OpenSSLStatus.Name.LIBRESSL); + } else if (openssl_h_Compatibility.BORINGSSL) { + OpenSSLStatus.setName(OpenSSLStatus.Name.BORINGSSL); + } // OpenSSL 3 onwards uses providers diff --git a/java/org/apache/tomcat/util/openssl/openssl_h_Compatibility.java b/java/org/apache/tomcat/util/openssl/openssl_h_Compatibility.java index 29f39f0481..ba78a3ef92 100644 --- a/java/org/apache/tomcat/util/openssl/openssl_h_Compatibility.java +++ b/java/org/apache/tomcat/util/openssl/openssl_h_Compatibility.java @@ -29,12 +29,14 @@ import static org.apache.tomcat.util.openssl.openssl_h.SSL_get1_peer_certificate */ public class openssl_h_Compatibility { + public static final boolean OPENSSL; public static final boolean OPENSSL3; public static final boolean BORINGSSL; public static final boolean LIBRESSL; static { String versionString = OpenSSL_version(0).getString(0); - OPENSSL3 = versionString.contains("OpenSSL") && OpenSSL_version_num() >= 0x3000000fL; + OPENSSL = versionString.contains("OpenSSL"); + OPENSSL3 = OPENSSL && OpenSSL_version_num() >= 0x3000000fL; BORINGSSL = versionString.contains("BoringSSL"); LIBRESSL = versionString.contains("LibreSSL"); } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org