hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1790053 - in /httpcomponents/httpcore/branches/4.4.x: RELEASE_NOTES.txt httpcore/src/main/java/org/apache/http/ssl/SSLContextBuilder.java httpcore/src/test/java/org/apache/http/ssl/TestSSLContextBuilder.java
Date Mon, 03 Apr 2017 22:13:57 GMT
Author: ggregory
Date: Mon Apr  3 22:13:57 2017
New Revision: 1790053

URL: http://svn.apache.org/viewvc?rev=1790053&view=rev
Log:
[HTTPCORE-450] Add a Provider parameter in SSLContextBuilder.

Modified:
    httpcomponents/httpcore/branches/4.4.x/RELEASE_NOTES.txt
    httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/ssl/SSLContextBuilder.java
    httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/ssl/TestSSLContextBuilder.java

Modified: httpcomponents/httpcore/branches/4.4.x/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.4.x/RELEASE_NOTES.txt?rev=1790053&r1=1790052&r2=1790053&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.4.x/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpcore/branches/4.4.x/RELEASE_NOTES.txt Mon Apr  3 22:13:57 2017
@@ -1,3 +1,15 @@
+Release 4.4.7
+-------------------
+
+This is a maintenance release that fixes a number of issues discovered since 4.4.6.
+
+Changelog
+-------------------
+
+* HTTPCORE-450: Add a Provider parameter in SSLContextBuilder.
+  Contributed by lujianbo <387852424 at qq dot com>, Gary Gregory <ggregory at apache.org>
+
+
 Release 4.4.6
 -------------------
 

Modified: httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/ssl/SSLContextBuilder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/ssl/SSLContextBuilder.java?rev=1790053&r1=1790052&r2=1790053&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/ssl/SSLContextBuilder.java
(original)
+++ httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/ssl/SSLContextBuilder.java
Mon Apr  3 22:13:57 2017
@@ -39,6 +39,7 @@ import java.security.KeyStoreException;
 import java.security.NoSuchAlgorithmException;
 import java.security.Principal;
 import java.security.PrivateKey;
+import java.security.Provider;
 import java.security.SecureRandom;
 import java.security.UnrecoverableKeyException;
 import java.security.cert.CertificateException;
@@ -80,6 +81,7 @@ public class SSLContextBuilder {
     private final Set<KeyManager> keymanagers;
     private final Set<TrustManager> trustmanagers;
     private SecureRandom secureRandom;
+    private Provider provider;
 
     public static SSLContextBuilder create() {
         return new SSLContextBuilder();
@@ -101,6 +103,11 @@ public class SSLContextBuilder {
         return this;
     }
 
+    public SSLContextBuilder setProvider(final Provider provider) {
+        this.provider = provider;
+        return this;
+    }
+
     public SSLContextBuilder loadTrustMaterial(
             final KeyStore truststore,
             final TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException
{
@@ -266,8 +273,13 @@ public class SSLContextBuilder {
     }
 
     public SSLContext build() throws NoSuchAlgorithmException, KeyManagementException {
-        final SSLContext sslcontext = SSLContext.getInstance(
-                this.protocol != null ? this.protocol : TLS);
+        final SSLContext sslcontext;
+        final String protocolStr = this.protocol != null ? this.protocol : TLS;
+        if (this.provider != null) {
+            sslcontext = SSLContext.getInstance(protocolStr, this.provider);
+        } else {
+            sslcontext = SSLContext.getInstance(protocolStr);
+        }
         initSSLContext(sslcontext, keymanagers, trustmanagers, secureRandom);
         return sslcontext;
     }

Modified: httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/ssl/TestSSLContextBuilder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/ssl/TestSSLContextBuilder.java?rev=1790053&r1=1790052&r2=1790053&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/ssl/TestSSLContextBuilder.java
(original)
+++ httpcomponents/httpcore/branches/4.4.x/httpcore/src/test/java/org/apache/http/ssl/TestSSLContextBuilder.java
Mon Apr  3 22:13:57 2017
@@ -37,6 +37,7 @@ import java.net.SocketException;
 import java.net.URL;
 import java.security.KeyStore;
 import java.security.Principal;
+import java.security.Security;
 import java.security.UnrecoverableKeyException;
 import java.security.cert.CertificateException;
 import java.security.cert.X509Certificate;
@@ -618,4 +619,16 @@ public class TestSSLContextBuilder {
         }
     }
 
+    @Test
+    public void testBuildWithProvider() throws Exception {
+        final URL resource1 = getClass().getResource("/test-server.keystore");
+        final String storePassword = "nopassword";
+        final String keyPassword = "nopassword";
+        final SSLContext sslContext=SSLContextBuilder.create()
+                .setProvider(Security.getProvider("SunJSSE"))
+                .loadKeyMaterial(resource1, storePassword.toCharArray(), keyPassword.toCharArray())
+                .build();
+        Assert.assertTrue(sslContext.getProvider().getName().equals("SunJSSE"));
+    }
+
 }



Mime
View raw message