[java-support] 02/04: OSJ-300: Deprecation of HttpClient X509HostnameVerifier interface

Brent Putman putmanb at georgetown.edu
Wed Feb 19 17:18:25 EST 2020


This is an automated email from the git hooks/post-receive script.

putmanb pushed a commit to branch master
in repository java-support.

View the commit online:
http://git.shibboleth.net/view/?p=java-support.git;a=commit;h=ba99ca1e2eabe12a0f9415fc66bf99d0b355e4b8

commit ba99ca1e2eabe12a0f9415fc66bf99d0b355e4b8
Author: Brent Putman <putmanb at georgetown.edu>
AuthorDate: Wed Feb 19 15:54:13 2020 -0500

    OSJ-300: Deprecation of HttpClient X509HostnameVerifier interface
    
    Swap use of old deprecated verifier impls for the new ones.
---
 .../java/support/httpclient/HttpClientSupport.java          |  8 ++++----
 .../utilities/java/support/httpclient/TLSSocketFactory.java | 13 +++++++------
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/main/java/net/shibboleth/utilities/java/support/httpclient/HttpClientSupport.java b/src/main/java/net/shibboleth/utilities/java/support/httpclient/HttpClientSupport.java
index d5dcb3b..c84c5ef 100644
--- a/src/main/java/net/shibboleth/utilities/java/support/httpclient/HttpClientSupport.java
+++ b/src/main/java/net/shibboleth/utilities/java/support/httpclient/HttpClientSupport.java
@@ -40,8 +40,8 @@ import org.apache.http.HttpEntity;
 import org.apache.http.ParseException;
 import org.apache.http.client.protocol.HttpClientContext;
 import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
-import org.apache.http.conn.ssl.AllowAllHostnameVerifier;
-import org.apache.http.conn.ssl.StrictHostnameVerifier;
+import org.apache.http.conn.ssl.DefaultHostnameVerifier;
+import org.apache.http.conn.ssl.NoopHostnameVerifier;
 import org.apache.http.entity.ContentType;
 import org.apache.http.protocol.HTTP;
 import org.apache.http.util.CharArrayBuffer;
@@ -72,7 +72,7 @@ public final class HttpClientSupport {
      */
     @Nonnull public static LayeredConnectionSocketFactory buildStrictTLSSocketFactory() {
         return new TLSSocketFactoryBuilder()
-            .setHostnameVerifier(new StrictHostnameVerifier())
+            .setHostnameVerifier(new DefaultHostnameVerifier())
             .build();
     }
     
@@ -85,7 +85,7 @@ public final class HttpClientSupport {
     @Nonnull public static LayeredConnectionSocketFactory buildNoTrustTLSSocketFactory() {
         return new TLSSocketFactoryBuilder()
             .setTrustManagers(Collections.<TrustManager>singletonList(buildNoTrustX509TrustManager()))
-            .setHostnameVerifier(new AllowAllHostnameVerifier())
+            .setHostnameVerifier(new NoopHostnameVerifier())
             .build();
     }
     
diff --git a/src/main/java/net/shibboleth/utilities/java/support/httpclient/TLSSocketFactory.java b/src/main/java/net/shibboleth/utilities/java/support/httpclient/TLSSocketFactory.java
index 89f1c9c..29d7567 100644
--- a/src/main/java/net/shibboleth/utilities/java/support/httpclient/TLSSocketFactory.java
+++ b/src/main/java/net/shibboleth/utilities/java/support/httpclient/TLSSocketFactory.java
@@ -40,8 +40,9 @@ import net.shibboleth.utilities.java.support.primitive.StringSupport;
 
 import org.apache.http.HttpHost;
 import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
-import org.apache.http.conn.ssl.AllowAllHostnameVerifier;
-import org.apache.http.conn.ssl.StrictHostnameVerifier;
+import org.apache.http.conn.ssl.DefaultHostnameVerifier;
+import org.apache.http.conn.ssl.NoopHostnameVerifier;
+import org.apache.http.conn.util.PublicSuffixMatcher;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.util.Args;
 import org.slf4j.Logger;
@@ -58,8 +59,8 @@ import org.slf4j.LoggerFactory;
  * </p>
  *
  * <ul>
- *   <li>Factory hostname verifier defaults to {@link StrictHostnameVerifier} rather than 
- *       {@link BrowserCompatHostnameVerifier}</li>
+ *   <li>Factory hostname verifier defaults to {@link DefaultHostnameVerifier} without a
+ *   configured {@link PublicSuffixMatcher}.</li>
  *   <li>Per-request specification of enabled TLS protocols and cipher suites via {@link HttpContext} attributes.</li>
  *   <li>Per-request specification of hostname verifier via {@link HttpContext} attribute.</li>
  * </ul>
@@ -88,10 +89,10 @@ public class TLSSocketFactory implements LayeredConnectionSocketFactory {
     @Nonnull @NotEmpty public static final String SSLV2 = "SSLv2";
 
     /** Hostname verifier which passes all hostnames. */
-    @Nonnull public static final HostnameVerifier ALLOW_ALL_HOSTNAME_VERIFIER = new AllowAllHostnameVerifier();
+    @Nonnull public static final HostnameVerifier ALLOW_ALL_HOSTNAME_VERIFIER = new NoopHostnameVerifier();
 
     /** Hostname verifier which implements a strict policy. */
-    @Nonnull public static final HostnameVerifier STRICT_HOSTNAME_VERIFIER = new StrictHostnameVerifier();
+    @Nonnull public static final HostnameVerifier STRICT_HOSTNAME_VERIFIER = new DefaultHostnameVerifier();
     
     /** Logger. */
     @Nonnull private final Logger log = LoggerFactory.getLogger(TLSSocketFactory.class);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list