JDK-8231810 : javax/net/ssl/templates/SSLSocketSSLEngineTemplate.java fails intermittently with "java.lang.Exception: Unexpected EOF"
  • Type: Bug
  • Component: security-libs
  • Sub-Component: javax.net.ssl
  • Affected Version: 11,14
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2019-10-03
  • Updated: 2024-02-23
  • Resolved: 2019-12-11
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 13 JDK 14 JDK 8 Other
11.0.7-oracleFixed 13.0.4Fixed 14 b27Fixed 8u261Fixed openjdk8u272Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Sub Tasks
JDK-8235255 :  
Description
Test:
javax/net/ssl/templates/SSLSocketSSLEngineTemplate.java

Log:
command: main SSLSocketSSLEngineTemplate
reason: User specified action: run main/othervm SSLSocketSSLEngineTemplate 
Mode: othervm [/othervm specified]
elapsed time (seconds): 3.024
----------configuration:(0/0)----------
----------System.out:(79/2182)----------
Testing SSLv3
-------------------------------------
Testing SSLv3 for direct buffers ...
================
The format of the SSLEngineResult is: 
	"getStatus() / getHandshakeStatus()" +
	"bytesConsumed() / bytesProduced()"

server unwrap: OK/NEED_TASK, 179/0 bytes
	running delegated task...
	new HandshakeStatus: NEED_WRAP
----
server wrap: OK/NEED_UNWRAP, 0/716 bytes
================
server unwrap: OK/NEED_TASK, 42/0 bytes
	running delegated task...
	new HandshakeStatus: NEED_UNWRAP
----
server wrap: OK/NEED_UNWRAP, 0/0 bytes
================
server unwrap: OK/NEED_UNWRAP, 6/0 bytes
----
server wrap: OK/NEED_UNWRAP, 0/0 bytes
================
server unwrap: OK/NEED_WRAP, 53/0 bytes
----
server wrap: OK/NEED_WRAP, 0/727 bytes
================
server unwrap: BUFFER_UNDERFLOW/NEED_WRAP, 0/0 bytes
----
server wrap: OK/NEED_WRAP, 0/6 bytes
================
server unwrap: BUFFER_UNDERFLOW/NEED_WRAP, 0/0 bytes
----
server wrap: OK/FINISHED, 0/53 bytes
	...ready for application data
================
server unwrap: OK/NOT_HANDSHAKING, 85/49 bytes
----
server wrap: OK/NOT_HANDSHAKING, 30/69 bytes
================
server unwrap: BUFFER_UNDERFLOW/NEED_WRAP, 0/0 bytes
----
server wrap: CLOSED/NOT_HANDSHAKING, 0/37 bytes
================
server unwrap: CLOSED/NOT_HANDSHAKING, 37/0 bytes
----
server wrap: CLOSED/NOT_HANDSHAKING, 0/0 bytes
---------------------------------------
Testing SSLv3 for indirect buffers ...
================
server unwrap: OK/NEED_TASK, 923/0 bytes
	running delegated task...
	new HandshakeStatus: NEED_WRAP
----
server wrap: OK/NEED_WRAP, 0/776 bytes
================
server unwrap: OK/NEED_WRAP, 0/0 bytes
----
server wrap: OK/NEED_WRAP, 0/6 bytes
================
server unwrap: OK/NEED_WRAP, 0/0 bytes
----
server wrap: OK/NEED_UNWRAP, 0/53 bytes
================
server unwrap: OK/NEED_UNWRAP, 6/0 bytes
----
server wrap: OK/NEED_UNWRAP, 0/0 bytes
================
server unwrap: OK/FINISHED, 53/0 bytes
	...ready for application data
----
server wrap: OK/NOT_HANDSHAKING, 30/69 bytes
Need to read more from client
================
server unwrap: OK/NOT_HANDSHAKING, 85/49 bytes
----
server wrap: OK/NOT_HANDSHAKING, 0/0 bytes
================
----------System.err:(14/866)----------
java.lang.Exception: Unexpected EOF
	at SSLSocketSSLEngineTemplate.runTest(SSLSocketSSLEngineTemplate.java:264)
	at SSLSocketSSLEngineTemplate.main(SSLSocketSSLEngineTemplate.java:164)
	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:564)
	at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
	at java.base/java.lang.Thread.run(Thread.java:830)

JavaTest Message: Test threw exception: java.lang.Exception: Unexpected EOF
JavaTest Message: shutting down test

STATUS:Failed.`main' threw exception: java.lang.Exception: Unexpected EOF
Comments
Fix request (13u) Requesting backport to 13u for parity with 11u, applies cleanly.
01-06-2020

11u Review thread: https://mail.openjdk.java.net/pipermail/jdk-updates-dev/2020-March/002736.html
12-03-2020

jdk11 downport request I would like to have the fix in openjdk11 as well, because it is in Oracle JDK 11.0.7. The patch does not apply because the change to test/jdk/ProblemList.txt does not apply (but it is not needed). The downport of this change is needed also for the openjdk11 downport of https://bugs.openjdk.java.net/browse/JDK-8234724 .
12-03-2020

URL: https://hg.openjdk.java.net/jdk/jdk/rev/dcf8e70d78d5 User: jjiang Date: 2019-12-11 03:30:44 +0000
11-12-2019

It appears that before the server socket tried to read the notify_close alert, the client socket was already closed.
09-12-2019

Running the test for TLSv1.3 only in a loop could reproduce this issue. According to the below debug outputs, the server side didn't receive the expected close_notify, though the client side alerted it. javax.net.ssl|DEBUG|0E|ClientThread|2019-12-06 15:16:20.377 CST|SSLSocketOutputRecord.java:72|WRITE: TLS13 alert(close_notify), length = 2 javax.net.ssl|DEBUG|0E|ClientThread|2019-12-06 15:16:20.377 CST|SSLCipher.java:2063|Plaintext before ENCRYPTION ( 0000: 01 00 15 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0010: 00 00 00 ... ) javax.net.ssl|DEBUG|0E|ClientThread|2019-12-06 15:16:20.378 CST|SSLSocketOutputRecord.java:86|Raw write ( 0000: 17 03 03 00 23 59 E0 B2 BC A9 95 2A BC 3F 1B 7D ....#Y.....*.?.. 0010: 18 E5 5D 86 76 DD 78 5A C0 0F F0 6B 54 A1 16 E0 ..].v.xZ...kT... 0020: F1 FF 52 40 70 B4 D4 E9 ..R@p... ) javax.net.ssl|DEBUG|0E|ClientThread|2019-12-06 15:16:20.381 CST|SSLSocketImpl.java:1718|close the SSL connection (passive) javax.net.ssl|DEBUG|0D|MainThread|2019-12-06 15:16:20.381 CST|SSLEngineInputRecord.java:177|Raw read ( 0000: 17 03 03 00 23 69 85 9F C8 2A 2B AA 8B 54 65 38 ....#i...*+..Te8 0010: 88 28 C6 54 01 2A 46 E0 14 6C F1 B0 F5 FF 70 18 .(.T.*F..l....p. 0020: 90 C3 39 D0 5D BC C1 E3 17 03 03 00 23 59 E0 B2 ..9.].......#Y.. 0030: BC A9 95 2A BC 3F 1B 7D 18 E5 5D 86 76 DD 78 5A ...*.?....].v.xZ 0040: C0 0F F0 6B 54 A1 16 E0 F1 FF 52 40 70 B4 D4 E9 ...kT.....R@p... ) javax.net.ssl|DEBUG|0D|MainThread|2019-12-06 15:16:20.381 CST|SSLEngineInputRecord.java:214|READ: TLSv1.2 application_data, length = 35 javax.net.ssl|DEBUG|0D|MainThread|2019-12-06 15:16:20.381 CST|SSLCipher.java:1958|Plaintext after DECRYPTION ( 0000: 01 5A .Z ) javax.net.ssl|DEBUG|0D|MainThread|2019-12-06 15:16:20.382 CST|Alert.java:238|Received alert message ( "Alert": { "level" : "warning", "description": "user_canceled" } ) server unwrap: OK/NOT_HANDSHAKING, 40/0 bytes ---- server wrap: CLOSED/NOT_HANDSHAKING, 0/0 bytes ================ java.lang.Exception: Unexpected EOF at SSLSocketSSLEngineTemplate.runTest(SSLSocketSSLEngineTemplate.java:263) at SSLSocketSSLEngineTemplate.main(SSLSocketSSLEngineTemplate.java:159) 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:564) at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127) at java.base/java.lang.Thread.run(Thread.java:832) The attached SSLSocketSSLEngineTemplate.log contains the full debug logs.
08-12-2019

[~jjiang] This is failing fairly consistently now - I think we should add it to the ProblemList if you don't have a fix soon.
03-12-2019