java
protocol_error
ai_generated
true
javax.net.ssl.SSLException: closing inbound before receiving peer's close_notify
ID: java/ssl-exception-closed-ssl-socket
85%Fix Rate
88%Confidence
1Evidence
2023-08-15First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| Java 8 | active | — | — | — |
| Java 11 | active | — | — | — |
| Java 17 | active | — | — | — |
| Java 21 | active | — | — | — |
Root Cause
The SSL/TLS connection is being closed by the client or server without exchanging the proper close_notify alert, violating the TLS protocol specification.
generic中文
SSL/TLS 连接在未交换正确的 close_notify 警报的情况下被客户端或服务器关闭,违反了 TLS 协议规范。
Official Documentation
https://docs.oracle.com/en/java/javase/17/docs/api/java.base/javax/net/ssl/SSLException.htmlWorkarounds
-
85% success Add system property -Djdk.tls.acknowledgeCloseNotify=true to allow graceful handling of missing close_notify messages.
Add system property -Djdk.tls.acknowledgeCloseNotify=true to allow graceful handling of missing close_notify messages.
-
90% success Ensure the server sends a proper close_notify alert before closing the socket. In Java, use SSLSocket.close() which automatically sends close_notify, not Socket.close().
Ensure the server sends a proper close_notify alert before closing the socket. In Java, use SSLSocket.close() which automatically sends close_notify, not Socket.close().
-
75% success Catch the SSLException in the client code and treat it as a normal connection termination without retrying.
Catch the SSLException in the client code and treat it as a normal connection termination without retrying.
中文步骤
Add system property -Djdk.tls.acknowledgeCloseNotify=true to allow graceful handling of missing close_notify messages.
Ensure the server sends a proper close_notify alert before closing the socket. In Java, use SSLSocket.close() which automatically sends close_notify, not Socket.close().
Catch the SSLException in the client code and treat it as a normal connection termination without retrying.
Dead Ends
Common approaches that don't work:
-
Set javax.net.ssl.trustStore system property to a custom truststore
90% fail
This error is not related to truststore configuration; changing trust stores does not affect TLS close_notify handshake behavior.
-
Increase SSL socket timeout using setSoTimeout()
85% fail
Timeout settings do not control TLS shutdown behavior; the error occurs even with ample timeouts.
-
Disable SSL verification entirely with a custom TrustManager
95% fail
Disabling verification bypasses certificate checks but does not fix the protocol-level close_notify violation.