JDK-8211787 : javax/net/ssl/TLSCommon/TLSTest.java throws java.net.SocketTimeoutException: Read timed out
  • Type: Bug
  • Component: security-libs
  • Sub-Component: javax.net.ssl
  • Affected Version: 12
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris
  • CPU: sparc_64
  • Submitted: 2018-10-05
  • Updated: 2021-03-05
  • Resolved: 2018-11-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 12 JDK 8 Other
11.0.3-oracleFixed 12 b21Fixed 8u301Fixed openjdk8u272Resolved
Description
RULE: javax/net/ssl/TLSCommon/TLSTest.java

command: main TLSTest TLSv1.3 rsa_pss_pss_sha512 TLS_AES_256_GCM_SHA384
reason: User specified action: run main/othervm TLSTest TLSv1.3 rsa_pss_pss_sha512 TLS_AES_256_GCM_SHA384 
Mode: othervm [/othervm specified]
elapsed time (seconds): 45.225
----------configuration:(0/0)----------
----------System.out:(27/1938)----------
Server listining on port: 45255
javax.net.ssl.SSLProtocolException: Read timed out
	at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:126)
	at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:321)
	at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:264)
	at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:259)
	at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:137)
	at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1151)
	at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1062)
	at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:402)
	at java.base/sun.security.ssl.SSLSocketImpl.ensureNegotiated(SSLSocketImpl.java:716)
	at java.base/sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:799)
	at java.base/sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:758)
	at TLSTest$Server.doServerSide(TLSTest.java:225)
	at TLSTest$Server.run(TLSTest.java:247)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:835)
Caused by: java.net.SocketTimeoutException: Read timed out
	at java.base/java.net.SocketInputStream.socketRead0(Native Method)
	at java.base/java.net.SocketInputStream.socketRead(SocketInputStream.java:115)
	at java.base/java.net.SocketInputStream.read(SocketInputStream.java:168)
	at java.base/java.net.SocketInputStream.read(SocketInputStream.java:140)
	at java.base/sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:448)
	at java.base/sun.security.ssl.SSLSocketInputRecord.decode(SSLSocketInputRecord.java:165)
	at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:108)
	... 11 more
----------System.err:(26/1902)----------
javax.net.ssl.SSLProtocolException: Received fatal alert: unexpected_message
	at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:126)
	at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:117)
	at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:308)
	at java.base/sun.security.ssl.Alert$AlertConsumer.consume(Alert.java:279)
	at java.base/sun.security.ssl.TransportContext.dispatch(TransportContext.java:181)
	at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:164)
	at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1151)
	at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1062)
	at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:402)
	at java.base/sun.security.ssl.SSLSocketImpl.ensureNegotiated(SSLSocketImpl.java:716)
	at java.base/sun.security.ssl.SSLSocketImpl$AppOutputStream.write(SSLSocketImpl.java:969)
	at java.base/sun.security.ssl.SSLSocketImpl$AppOutputStream.write(SSLSocketImpl.java:941)
	at TLSTest$Client.doClientSide(TLSTest.java:287)
	at TLSTest.main(TLSTest.java:156)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
	at java.base/java.lang.Thread.run(Thread.java:835)

JavaTest Message: Test threw exception: javax.net.ssl.SSLProtocolException: Received fatal alert: unexpected_message
JavaTest Message: shutting down test

STATUS:Failed.`main' threw exception: javax.net.ssl.SSLProtocolException: Received fatal alert: unexpected_message
Comments
It looks like a Test issue. It sets setSoTimeout(5000) with wrong socket. It is supposed to set with ServerSocket but by mistake set with the socket created from server accept() which cause the SocketTimeoutException from socket stream read() after specified seconds. Sample fix, sslServerSocket.setEnabledCipherSuites(new String[]{this.cipher}); sslServerSocket.setEnabledProtocols(new String[]{tlsProtocol}); // FOLLOWING 2 lines is correct way to set the necessary properties sslServerSocket.setNeedClientAuth(false); sslServerSocket.setSoTimeout(10000); /* * Signal Client, the server is ready to accept client request. */ latch.countDown(); try (SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept()) { // FOLLOWING 2 lines are wrong way to set the properties for server. Remove these 2 lines. sslSocket.setNeedClientAuth(false); sslSocket.setSoTimeout(5000);
05-02-2020

Fix Request This fixes the intermittent false bug failure in 11u. It is important to have it in 11u (I see it is in 11.0.3-oracle). Patch applies cleanly to 11u and passes the affected test.
19-02-2019