[java-openws COMMIT] /branches/REL_1/src/main/java/org/opensaml/ws/soap/client/http/TLSProtocolSocketFactory.java

noreply at shibboleth.net noreply at shibboleth.net
Mon Sep 28 20:52:37 EDT 2015


Author: putmanb
Date: Mon Sep 28 20:52:37 2015
New Revision: 482

URL: http://svn.shibboleth.net/view/java-openws?rev=482&view=rev
Log:
JOWS-47: TLSProtocolSocketFactory should not verify hostname from SSLSession getPeerHost()

Make the deprecated method behave as much as possible like the original under certain error conditions.

Modified:
    branches/REL_1/src/main/java/org/opensaml/ws/soap/client/http/TLSProtocolSocketFactory.java

Modified: branches/REL_1/src/main/java/org/opensaml/ws/soap/client/http/TLSProtocolSocketFactory.java
URL: http://svn.shibboleth.net/view/java-openws/branches/REL_1/src/main/java/org/opensaml/ws/soap/client/http/TLSProtocolSocketFactory.java?rev=482&r1=481&r2=482&view=diff
==============================================================================
--- branches/REL_1/src/main/java/org/opensaml/ws/soap/client/http/TLSProtocolSocketFactory.java	(original)
+++ branches/REL_1/src/main/java/org/opensaml/ws/soap/client/http/TLSProtocolSocketFactory.java	Mon Sep 28 20:52:37 2015
@@ -217,6 +217,10 @@
      * @deprecated Use instead {@link #verifyHostname(Socket, String)
      */
     protected void verifyHostname(Socket socket) throws SSLException {
+        if (hostnameVerifier == null) {
+            return;
+        }
+        
         if (!(socket instanceof SSLSocket)) {
             return;
         }
@@ -225,7 +229,15 @@
         
         try {
             SSLSession sslSession = sslSocket.getSession();
+            if (!sslSession.isValid()) {
+                throw new SSLException("SSLSession was invalid: Likely implicit handshake failure: " 
+                        + "Set system property javax.net.debug=all for details");
+            }
+            
             verifyHostname(sslSocket, sslSession.getPeerHost());
+        } catch (SSLException e) {
+            cleanUpFailedSocket(sslSocket);
+            throw e;
         } catch (Throwable t) {
             // Make sure we close the socket on any kind of Exception, RuntimeException or Error.
             cleanUpFailedSocket(sslSocket);



More information about the commits mailing list