Hi Mark,
Am 08.03.23 um 20:15 schrieb ma...@apache.org:
...
diff --git a/test/org/apache/tomcat/websocket/TestWsWebSocketContainerSSL.java
b/test/org/apache/tomcat/websocket/TestWsWebSocketContainerSSL.java
new file mode 100644
index 0000000000..eb44ac6aed
--- /dev/null
+++ b/test/org/apache/tomcat/websocket/TestWsWebSocketContainerSSL.java
@@ -0,0 +1,76 @@
+/*
+ * 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.websocket;
+
+import java.net.URI;
+import java.util.Queue;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import javax.websocket.ClientEndpointConfig;
+import javax.websocket.ContainerProvider;
+import javax.websocket.Session;
+import javax.websocket.WebSocketContainer;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.servlets.DefaultServlet;
+import org.apache.catalina.startup.Tomcat;
+import org.apache.tomcat.util.net.TesterSupport;
+import org.apache.tomcat.websocket.TesterMessageCountClient.BasicText;
+import
org.apache.tomcat.websocket.TesterMessageCountClient.TesterProgrammaticEndpoint;
+
+public class TestWsWebSocketContainerSSL extends WebSocketBaseTest {
+
+ private static final String MESSAGE_STRING_1 = "qwerty";
+
+ @Test
+ public void testConnectToServerEndpointSSL() throws Exception {
+
+ Tomcat tomcat = getTomcatInstance();
+ // No file system docBase required
+ Context ctx = tomcat.addContext("", null);
+ ctx.addApplicationListener(TesterEchoServer.Config.class.getName());
+ Tomcat.addServlet(ctx, "default", new DefaultServlet());
+ ctx.addServletMappingDecoded("/", "default");
+
+ TesterSupport.initSsl(tomcat);
+
+ tomcat.start();
+
+ WebSocketContainer wsContainer =
ContainerProvider.getWebSocketContainer();
+ ClientEndpointConfig clientEndpointConfig =
ClientEndpointConfig.Builder.create().build();
+
clientEndpointConfig.getUserProperties().put(org.apache.tomcat.websocket.Constants.SSL_TRUSTSTORE_PROPERTY,
+ TesterSupport.CA_JKS);
+ Session wsSession =
wsContainer.connectToServer(TesterProgrammaticEndpoint.class,
clientEndpointConfig,
+ new URI("wss://localhost" + ":" + getPort() +
TesterEchoServer.Config.PATH_ASYNC));
+ CountDownLatch latch = new CountDownLatch(1);
+ BasicText handler = new BasicText(latch);
+ wsSession.addMessageHandler(handler);
+ wsSession.getBasicRemote().sendText(MESSAGE_STRING_1);
+
+ boolean latchResult = handler.getLatch().await(10, TimeUnit.SECONDS);
+
+ Assert.assertTrue(latchResult);
+
+ Queue<String> messages = handler.getMessages();
+ Assert.assertEquals(1, messages.size());
+ Assert.assertEquals(MESSAGE_STRING_1, messages.peek());
+ }
+}
...
this new test fails for TC 8.5.88 with Java 1.7.0 and tcnative with
OpenSSL 3.x.
Not failing with newer JVM version or JSSE.
tcnative is 1.2.36 OpenSSL 3.0.8, tcnative 2.0.3 build with OpenSSL
3.0.8 or OpenSSL 3.1.0beta1. Using 1.2.36 with OpenSSL 1.1.1t is not
failing.
Error output is:
Testsuite: org.apache.tomcat.websocket.TestWsWebSocketContainerSSL
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.853 sec
------------- Standard Error -----------------
17-Apr-2023 00:28:31.122 INFO [main]
org.apache.catalina.startup.LoggingBaseTest.setUp Starting test case
[testConnectToServerEndpointSSL]
17-Apr-2023 00:28:31.506 INFO [main]
org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded
Apache Tomcat Native library [1.2.36] using APR version [1.7.2sp1].
17-Apr-2023 00:28:31.506 INFO [main]
org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR
capabilities: IPv6 [true], sendfile [true], accept filters [false],
random [true], UDS [{4}].
17-Apr-2023 00:28:31.506 INFO [main]
org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL
configuration: useAprConnector [false], useOpenSSL [true]
17-Apr-2023 00:28:31.514 INFO [main]
org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL
successfully initialized [OpenSSL 3.0.8 7 Feb 2023]
17-Apr-2023 00:28:32.406 INFO [main]
org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler
["https-openssl-nio-127.0.0.1-auto-1"]
17-Apr-2023 00:28:32.652 INFO [main]
org.apache.tomcat.util.net.AbstractEndpoint.logCertificate Connector
[https-openssl-nio-127.0.0.1-auto-1], TLS virtual host [_default_],
certificate type [UNDEFINED] configured from
[/path/to/my/test/org/apache/tomcat/util/net/localhost-rsa.jks] using
alias [tomcat] and with trust store
[path/to/my/test/org/apache/tomcat/util/net/ca.jks]
17-Apr-2023 00:28:32.743 INFO [main]
org.apache.catalina.core.StandardService.startInternal Starting service
[Tomcat]
17-Apr-2023 00:28:32.744 INFO [main]
org.apache.catalina.core.StandardEngine.startInternal Starting Servlet
engine: [Apache Tomcat/8.5.88]
17-Apr-2023 00:28:33.187 INFO [main]
org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler
["https-openssl-nio-127.0.0.1-auto-1-36755"]
17-Apr-2023 00:28:33.615 INFO [main]
org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler
["https-openssl-nio-127.0.0.1-auto-1-36755"]
17-Apr-2023 00:28:33.626 INFO [main]
org.apache.catalina.core.StandardService.stopInternal Stopping service
[Tomcat]
17-Apr-2023 00:28:33.647 INFO [main]
org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler
["https-openssl-nio-127.0.0.1-auto-1-36755"]
17-Apr-2023 00:28:33.690 INFO [main]
org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler
["https-openssl-nio-127.0.0.1-auto-1-36755"]
------------- ---------------- ---------------
Testcase: testConnectToServerEndpointSSL took 2.777 sec
Caused an ERROR
The HTTP request to initiate the WebSocket connection to
[wss://localhost:36755/echoAsync] failed
javax.websocket.DeploymentException: The HTTP request to initiate the
WebSocket connection to [wss://localhost:36755/echoAsync] failed
at
org.apache.tomcat.websocket.WsWebSocketContainer.connectToServerRecursive(WsWebSocketContainer.java:428)
at
org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:170)
at
org.apache.tomcat.websocket.TestWsWebSocketContainerSSL.testConnectToServerEndpointSSL(TestWsWebSocketContainerSSL.java:61)
Caused by: java.util.concurrent.ExecutionException:
javax.net.ssl.SSLException: Received fatal alert: internal_error
at
org.apache.tomcat.websocket.AsyncChannelWrapperSecure$WrapperFuture.get(AsyncChannelWrapperSecure.java:489)
at
org.apache.tomcat.websocket.WsWebSocketContainer.connectToServerRecursive(WsWebSocketContainer.java:320)
Caused by: javax.net.ssl.SSLException: Received fatal alert: internal_error
at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
at sun.security.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1639)
at sun.security.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1607)
at
sun.security.ssl.SSLEngineImpl.recvAlert(SSLEngineImpl.java:1776)
at
sun.security.ssl.SSLEngineImpl.readRecord(SSLEngineImpl.java:1068)
at
sun.security.ssl.SSLEngineImpl.readNetRecord(SSLEngineImpl.java:890)
at sun.security.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:764)
at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:624)
at
org.apache.tomcat.websocket.AsyncChannelWrapperSecure$WebSocketSslHandshakeThread.run(AsyncChannelWrapperSecure.java:374)
Best regards,
Rainer
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org