changeset 51905:d5138f8da1ba

8207223: SSL Handshake failures are reported with more generic SSLException Reviewed-by: xuelei
author weijun
date Sat, 21 Jul 2018 21:46:42 +0800
parents b65916c52e3c
children 7efacf6d4cc6
files src/java.base/share/classes/sun/security/ssl/Alert.java
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/sun/security/ssl/Alert.java	Fri Jul 20 18:03:23 2018 -0400
+++ b/src/java.base/share/classes/sun/security/ssl/Alert.java	Sat Jul 21 21:46:42 2018 +0800
@@ -31,6 +31,7 @@
 import java.util.Locale;
 import javax.net.ssl.SSLException;
 import javax.net.ssl.SSLHandshakeException;
+import javax.net.ssl.SSLProtocolException;
 
 /**
  * SSL/(D)TLS Alter description
@@ -121,8 +122,11 @@
             reason = (cause != null) ? cause.getMessage() : "";
         }
 
-        SSLException ssle = handshakeOnly ?
-                new SSLHandshakeException(reason) : new SSLException(reason);
+        SSLException ssle = (this == UNEXPECTED_MESSAGE) ?
+                new SSLProtocolException(reason) :
+                (handshakeOnly ?
+                        new SSLHandshakeException(reason) :
+                        new SSLException(reason));
         if (cause != null) {
             ssle.initCause(cause);
         }