hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1631106 - in /httpcomponents/httpclient/trunk/httpclient/src: main/java/org/apache/http/conn/ssl/DefaultHostnameVerifier.java test/java/org/apache/http/conn/ssl/TestSSLSocketFactory.java
Date Sat, 11 Oct 2014 20:01:33 GMT
Author: olegk
Date: Sat Oct 11 20:01:33 2014
New Revision: 1631106

URL: http://svn.apache.org/r1631106
Log:
Do not run public suffix test on simple host names (non DNS names)

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

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/DefaultHostnameVerifier.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/DefaultHostnameVerifier.java?rev=1631106&r1=1631105&r2=1631106&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/DefaultHostnameVerifier.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/DefaultHostnameVerifier.java
Sat Oct 11 20:01:33 2014
@@ -173,7 +173,7 @@ public final class DefaultHostnameVerifi
             return false;
         }
 
-        if (publicSuffixMatcher != null) {
+        if (publicSuffixMatcher != null && host.contains(".")) {
             String domainRoot = publicSuffixMatcher.getDomainRoot(identity);
             if (domainRoot == null) {
                 // Public domain

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=1631106&r1=1631105&r2=1631106&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
Sat Oct 11 20:01:33 2014
@@ -110,6 +110,30 @@ public class TestSSLSocketFactory {
     }
 
     @Test
+    public void testBasicDefaultHostnameVerifier() throws Exception {
+        this.server = ServerBootstrap.bootstrap()
+                .setServerInfo(LocalServerTestBase.ORIGIN)
+                .setSslContext(SSLTestContexts.createServerSSLContext())
+                .create();
+        this.server.start();
+
+        final HttpContext context = new BasicHttpContext();
+        final SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
+                SSLTestContexts.createClientSSLContext(), SSLConnectionSocketFactory.getDefaultHostnameVerifier());
+        final Socket socket = socketFactory.createSocket(context);
+        final InetSocketAddress remoteAddress = new InetSocketAddress("localhost", this.server.getLocalPort());
+        final HttpHost target = new HttpHost("localhost", this.server.getLocalPort(), "https");
+        final SSLSocket sslSocket = (SSLSocket) socketFactory.connectSocket(0, socket, target,
remoteAddress, null, context);
+        try {
+            final SSLSession sslsession = sslSocket.getSession();
+
+            Assert.assertNotNull(sslsession);
+        } finally {
+            sslSocket.close();
+        }
+    }
+
+    @Test
     public void testClientAuthSSL() throws Exception {
         this.server = ServerBootstrap.bootstrap()
                 .setServerInfo(LocalServerTestBase.ORIGIN)
@@ -178,6 +202,8 @@ public class TestSSLSocketFactory {
 
         };
 
+
+
         this.server = ServerBootstrap.bootstrap()
                 .setServerInfo(LocalServerTestBase.ORIGIN)
                 .setSslContext(SSLTestContexts.createServerSSLContext())



Mime
View raw message