hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1645437 - /httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/ssl/SSLContextBuilder.java
Date Sun, 14 Dec 2014 11:17:30 GMT
Author: olegk
Date: Sun Dec 14 11:17:30 2014
New Revision: 1645437

URL: http://svn.apache.org/r1645437
Log:
HTTPCLIENT-1587: added protected method that can be overwritten by a subclass in order perform
additional trust / key material validation

Modified:
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/ssl/SSLContextBuilder.java

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/ssl/SSLContextBuilder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/ssl/SSLContextBuilder.java?rev=1645437&r1=1645436&r2=1645437&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/ssl/SSLContextBuilder.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/ssl/SSLContextBuilder.java
Sun Dec 14 11:17:30 2014
@@ -43,6 +43,7 @@ import java.security.SecureRandom;
 import java.security.UnrecoverableKeyException;
 import java.security.cert.CertificateException;
 import java.security.cert.X509Certificate;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.LinkedHashSet;
 import java.util.Map;
@@ -254,13 +255,21 @@ public class SSLContextBuilder {
         return loadKeyMaterial(url, storePassword, keyPassword, null);
     }
 
+    protected void initSSLContext(
+            final SSLContext sslcontext,
+            final Collection<KeyManager> keyManagers,
+            final Collection<TrustManager> trustManagers,
+            final SecureRandom secureRandom) throws KeyManagementException {
+        sslcontext.init(
+                !keyManagers.isEmpty() ? keyManagers.toArray(new KeyManager[keyManagers.size()])
: null,
+                !trustManagers.isEmpty() ? trustManagers.toArray(new TrustManager[trustManagers.size()])
: null,
+                secureRandom);
+    }
+
     public SSLContext build() throws NoSuchAlgorithmException, KeyManagementException {
         final SSLContext sslcontext = SSLContext.getInstance(
                 this.protocol != null ? this.protocol : TLS);
-        sslcontext.init(
-                !keymanagers.isEmpty() ? keymanagers.toArray(new KeyManager[keymanagers.size()])
: null,
-                !trustmanagers.isEmpty() ? trustmanagers.toArray(new TrustManager[trustmanagers.size()])
: null,
-                secureRandom);
+        initSSLContext(sslcontext, keymanagers, trustmanagers, secureRandom);
         return sslcontext;
     }
 



Mime
View raw message