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

markt-asf 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 420ba5c6c6 SocketException been observed as well as 
SSLHandshakeException
420ba5c6c6 is described below

commit 420ba5c6c6447e055703fa6845eb878dcaad5139
Author: Mark Thomas <[email protected]>
AuthorDate: Thu Jun 18 08:49:21 2026 +0100

    SocketException been observed as well as SSLHandshakeException
---
 .../tomcat/util/net/TestSslHandshakeFailure.java   | 24 +++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/test/org/apache/tomcat/util/net/TestSslHandshakeFailure.java 
b/test/org/apache/tomcat/util/net/TestSslHandshakeFailure.java
index cd372446cd..0b0d49d69b 100644
--- a/test/org/apache/tomcat/util/net/TestSslHandshakeFailure.java
+++ b/test/org/apache/tomcat/util/net/TestSslHandshakeFailure.java
@@ -17,6 +17,7 @@
 
 package org.apache.tomcat.util.net;
 
+import java.net.SocketException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -25,6 +26,7 @@ import javax.net.ssl.HttpsURLConnection;
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLHandshakeException;
 
+import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameter;
@@ -57,7 +59,7 @@ public class TestSslHandshakeFailure extends TomcatBaseTest {
     @Parameter(2)
     public String sslImplementationName;
 
-    @Test(expected = SSLHandshakeException.class)
+    @Test
     public void testMissingClientCertificate() throws Exception {
         Tomcat tomcat = getTomcatInstance();
 
@@ -76,8 +78,24 @@ public class TestSslHandshakeFailure extends TomcatBaseTest {
         sc.init(null, TesterSupport.getTrustManagers(), null);
         HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
 
-        getUrl("https://localhost:"; + getPort() + "/");
-
+        Throwable actual = null;
+        try {
+            getUrl("https://localhost:"; + getPort() + "/");
+        } catch (Throwable t) {
+            actual = t;
+        }
+
+        /*
+         * SSLHandshakeException expected but SocketException has been observed
+         */
+        Assert.assertNotNull("No exception was thrown when 
SSLHandshakeException was expected", actual);
+
+        if (actual instanceof SSLHandshakeException || actual instanceof 
SocketException) {
+            // Tests passes = NO-OP
+        } else {
+            actual.printStackTrace();
+            Assert.fail("Unexpected exception [" + actual.getClass() + ": " + 
actual.getMessage() + "].");
+        }
     }
 
 }


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

Reply via email to