hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject [37/50] httpcomponents-core git commit: [HTTPCORE-450] Add a Provider parameter in SSLContextBuilder. Add SSLContextBuilder.setProvider(String).
Date Tue, 09 May 2017 20:02:03 GMT
[HTTPCORE-450] Add a Provider parameter in SSLContextBuilder. Add SSLContextBuilder.setProvider(String).

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.4.x@1793914
13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/c5295f7e
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/c5295f7e
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/c5295f7e

Branch: refs/heads/4.4.x
Commit: c5295f7e14a52abd331d092791e5d7c0fb74446e
Parents: 3592c32
Author: Gary D. Gregory <ggregory@apache.org>
Authored: Thu May 4 22:30:05 2017 +0000
Committer: Gary D. Gregory <ggregory@apache.org>
Committed: Thu May 4 22:30:05 2017 +0000

----------------------------------------------------------------------
 .../java/org/apache/http/ssl/SSLContextBuilder.java     |  6 ++++++
 .../java/org/apache/http/ssl/TestSSLContextBuilder.java | 12 ++++++++++++
 2 files changed, 18 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/c5295f7e/httpcore/src/main/java/org/apache/http/ssl/SSLContextBuilder.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/ssl/SSLContextBuilder.java b/httpcore/src/main/java/org/apache/http/ssl/SSLContextBuilder.java
index 87c5470..70ed1f4 100644
--- a/httpcore/src/main/java/org/apache/http/ssl/SSLContextBuilder.java
+++ b/httpcore/src/main/java/org/apache/http/ssl/SSLContextBuilder.java
@@ -41,6 +41,7 @@ import java.security.Principal;
 import java.security.PrivateKey;
 import java.security.Provider;
 import java.security.SecureRandom;
+import java.security.Security;
 import java.security.UnrecoverableKeyException;
 import java.security.cert.CertificateException;
 import java.security.cert.X509Certificate;
@@ -122,6 +123,11 @@ public class SSLContextBuilder {
         return this;
     }
 
+    public SSLContextBuilder setProvider(final String name) {
+        this.provider = Security.getProvider(name);
+        return this;
+    }
+
     public SSLContextBuilder loadTrustMaterial(
             final KeyStore truststore,
             final TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException
{

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/c5295f7e/httpcore/src/test/java/org/apache/http/ssl/TestSSLContextBuilder.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/ssl/TestSSLContextBuilder.java b/httpcore/src/test/java/org/apache/http/ssl/TestSSLContextBuilder.java
index ae132f0..b789fcf 100644
--- a/httpcore/src/test/java/org/apache/http/ssl/TestSSLContextBuilder.java
+++ b/httpcore/src/test/java/org/apache/http/ssl/TestSSLContextBuilder.java
@@ -631,4 +631,16 @@ public class TestSSLContextBuilder {
         Assert.assertTrue(sslContext.getProvider().getName().equals("SunJSSE"));
     }
 
+    @Test
+    public void testBuildWithProviderName() throws Exception {
+        final URL resource1 = getClass().getResource("/test-server.keystore");
+        final String storePassword = "nopassword";
+        final String keyPassword = "nopassword";
+        final SSLContext sslContext=SSLContextBuilder.create()
+                .setProvider("SunJSSE")
+                .loadKeyMaterial(resource1, storePassword.toCharArray(), keyPassword.toCharArray())
+                .build();
+        Assert.assertTrue(sslContext.getProvider().getName().equals("SunJSSE"));
+    }
+
 }


Mime
View raw message