Do not run public suffix test on simple host names (non DNS names)
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1631106 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
66a1b7055c
commit
4c9577a08f
|
@ -173,7 +173,7 @@ public final class DefaultHostnameVerifier implements HostnameVerifier {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (publicSuffixMatcher != null) {
|
||||
if (publicSuffixMatcher != null && host.contains(".")) {
|
||||
String domainRoot = publicSuffixMatcher.getDomainRoot(identity);
|
||||
if (domainRoot == null) {
|
||||
// Public domain
|
||||
|
|
|
@ -109,6 +109,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()
|
||||
|
@ -178,6 +202,8 @@ public class TestSSLSocketFactory {
|
|||
|
||||
};
|
||||
|
||||
|
||||
|
||||
this.server = ServerBootstrap.bootstrap()
|
||||
.setServerInfo(LocalServerTestBase.ORIGIN)
|
||||
.setSslContext(SSLTestContexts.createServerSSLContext())
|
||||
|
|
Loading…
Reference in New Issue