hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1471292 - in /httpcomponents/httpclient/trunk: RELEASE_NOTES.txt httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java httpclient/src/test/java/org/apache/http/conn/ssl/TestSSLSocketFactory.java
Date Wed, 24 Apr 2013 08:42:29 GMT
Author: olegk
Date: Wed Apr 24 08:42:29 2013
New Revision: 1471292

URL: http://svn.apache.org/r1471292
Log:
HTTPCLIENT-1346: Ensure propagation of SSL handshake exceptions
Contributed by Pasi Eronen <pe at iki.fi>

Modified:
    httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/TestSSLSocketFactory.java

Modified: httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/RELEASE_NOTES.txt?rev=1471292&r1=1471291&r2=1471292&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpclient/trunk/RELEASE_NOTES.txt Wed Apr 24 08:42:29 2013
@@ -1,6 +1,9 @@
 Changes since release 4.3 BETA1
 -------------------
 
+* [HTTPCLIENT-1346] Ensure propagation of SSL handshake exceptions.
+  Contributed by Pasi Eronen <pe at iki.fi>
+
 * [HTTPCLIENT-1343] SSLSocketFactory optional parameters for supported SSL protocols and
cipher 
   suites. 
   Contributed by Oleg Kalnichevski <olegk at apache.org>

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java?rev=1471292&r1=1471291&r2=1471292&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java
Wed Apr 24 08:42:29 2013
@@ -562,7 +562,9 @@ public class SSLSocketFactory implements
         }
         // Setup SSL layering if necessary
         if (sock instanceof SSLSocket) {
-            verifyHostname((SSLSocket) sock, host.getHostName());
+            final SSLSocket sslsock = (SSLSocket) sock;
+            sslsock.startHandshake();
+            verifyHostname(sslsock, host.getHostName());
         } else {
             sock = createLayeredSocket(sock, host.getHostName(), remoteAddress.getPort(),
context);
         }
@@ -574,14 +576,15 @@ public class SSLSocketFactory implements
             final String target,
             final int port,
             final HttpContext context) throws IOException, UnknownHostException {
-        final SSLSocket sslSocket = (SSLSocket) this.socketfactory.createSocket(
+        final SSLSocket sslsock = (SSLSocket) this.socketfactory.createSocket(
                 socket,
                 target,
                 port,
                 true);
-        internalPrepareSocket(sslSocket);
-        verifyHostname(sslSocket, target);
-        return sslSocket;
+        internalPrepareSocket(sslsock);
+        sslsock.startHandshake();
+        verifyHostname(sslsock, target);
+        return sslsock;
     }
 
     private void verifyHostname(final SSLSocket sslsock, final String hostname) throws IOException
{

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/TestSSLSocketFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/TestSSLSocketFactory.java?rev=1471292&r1=1471291&r2=1471292&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/TestSSLSocketFactory.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/TestSSLSocketFactory.java
Wed Apr 24 08:42:29 2013
@@ -39,6 +39,7 @@ import javax.net.ssl.KeyManager;
 import javax.net.ssl.KeyManagerFactory;
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLException;
+import javax.net.ssl.SSLHandshakeException;
 import javax.net.ssl.SSLPeerUnverifiedException;
 import javax.net.ssl.SSLSession;
 import javax.net.ssl.SSLSocket;
@@ -156,7 +157,7 @@ public class TestSSLSocketFactory extend
         Assert.assertTrue(hostVerifier.isFired());
     }
 
-    @Test(expected=SSLPeerUnverifiedException.class)
+    @Test(expected=SSLHandshakeException.class)
     public void testSSLTrustVerification() throws Exception {
         final HttpHost host = new HttpHost("localhost", 443, "https");
         final HttpContext context = new BasicHttpContext();



Mime
View raw message