mirror of
https://github.com/apache/httpcomponents-client.git
synced 2025-02-09 11:35:30 +00:00
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 @@ private static boolean matchIdentity(final String host, final String identity,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (publicSuffixMatcher != null) {
|
if (publicSuffixMatcher != null && host.contains(".")) {
|
||||||
String domainRoot = publicSuffixMatcher.getDomainRoot(identity);
|
String domainRoot = publicSuffixMatcher.getDomainRoot(identity);
|
||||||
if (domainRoot == null) {
|
if (domainRoot == null) {
|
||||||
// Public domain
|
// Public domain
|
||||||
|
@ -109,6 +109,30 @@ public void testBasicSSL() throws Exception {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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
|
@Test
|
||||||
public void testClientAuthSSL() throws Exception {
|
public void testClientAuthSSL() throws Exception {
|
||||||
this.server = ServerBootstrap.bootstrap()
|
this.server = ServerBootstrap.bootstrap()
|
||||||
@ -178,6 +202,8 @@ public String chooseAlias(
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.server = ServerBootstrap.bootstrap()
|
this.server = ServerBootstrap.bootstrap()
|
||||||
.setServerInfo(LocalServerTestBase.ORIGIN)
|
.setServerInfo(LocalServerTestBase.ORIGIN)
|
||||||
.setSslContext(SSLTestContexts.createServerSSLContext())
|
.setSslContext(SSLTestContexts.createServerSSLContext())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user