This is an automated email from the ASF dual-hosted git repository.

markt-asf pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new 763d4be0d0 OpenSSL 4 is OpenSSL 3 or later
763d4be0d0 is described below

commit 763d4be0d0f2c35205bd4bbf1b12ced38a3c4eb7
Author: Mark Thomas <[email protected]>
AuthorDate: Tue Nov 3 14:29:38 2026 +0000

    OpenSSL 4 is OpenSSL 3 or later
---
 .../tomcat/util/net/openssl/OpenSSLStatus.java     |  4 +-
 .../tomcat/util/net/openssl/TestOpenSSLStatus.java | 81 ++++++++++++++++++++++
 2 files changed, 83 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/openssl/OpenSSLStatus.java 
b/java/org/apache/tomcat/util/net/openssl/OpenSSLStatus.java
index c276d8de9a..bfb1447d35 100644
--- a/java/org/apache/tomcat/util/net/openssl/OpenSSLStatus.java
+++ b/java/org/apache/tomcat/util/net/openssl/OpenSSLStatus.java
@@ -222,12 +222,12 @@ public class OpenSSLStatus {
     }
 
     /**
-     * Checks if running with OpenSSL 3.0 or later.
+     * Checks if running with OpenSSL 3.0 or later. This includes OpenSSL 4.0 
or later.
      *
      * @return true if running with OpenSSL 3.0+
      */
     public static boolean isOpenSSL3() {
-        return Name.OPENSSL3.equals(name);
+        return Name.OPENSSL3.equals(name) || Name.OPENSSL4.equals(name);
     }
 
     /**
diff --git a/test/org/apache/tomcat/util/net/openssl/TestOpenSSLStatus.java 
b/test/org/apache/tomcat/util/net/openssl/TestOpenSSLStatus.java
new file mode 100644
index 0000000000..e39501d347
--- /dev/null
+++ b/test/org/apache/tomcat/util/net/openssl/TestOpenSSLStatus.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomcat.util.net.openssl;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.tomcat.util.net.openssl.OpenSSLStatus.Name;
+
+public class TestOpenSSLStatus {
+
+    private Name originalName;
+
+    @Before
+    public void saveName() {
+        originalName = OpenSSLStatus.getName();
+    }
+
+    @After
+    public void restoreName() {
+        OpenSSLStatus.setName(originalName);
+    }
+
+
+    /*
+     * OpenSSL 3.0 or later means 3.0, 4.0 and any later release. A library 
that is identified as OpenSSL 4 is also
+     * OpenSSL 3.0 or later.
+     */
+    @Test
+    public void testOpenSSL3() {
+        OpenSSLStatus.setName(Name.OPENSSL3);
+
+        Assert.assertTrue(OpenSSLStatus.isOpenSSL3());
+        Assert.assertFalse(OpenSSLStatus.isOpenSSL4());
+    }
+
+
+    @Test
+    public void testOpenSSL4() {
+        OpenSSLStatus.setName(Name.OPENSSL4);
+
+        Assert.assertTrue(OpenSSLStatus.isOpenSSL3());
+        Assert.assertTrue(OpenSSLStatus.isOpenSSL4());
+    }
+
+
+    @Test
+    public void testOpenSSLBefore3() {
+        OpenSSLStatus.setName(Name.OPENSSL);
+
+        Assert.assertFalse(OpenSSLStatus.isOpenSSL3());
+        Assert.assertFalse(OpenSSLStatus.isOpenSSL4());
+    }
+
+
+    @Test
+    public void testOtherLibraries() {
+        for (Name other : new Name[] { Name.LIBRESSL, Name.BORINGSSL, 
Name.UNKNOWN }) {
+            OpenSSLStatus.setName(other);
+
+            Assert.assertFalse(other.name(), OpenSSLStatus.isOpenSSL3());
+            Assert.assertFalse(other.name(), OpenSSLStatus.isOpenSSL4());
+        }
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to