hc-commits mailing list archives

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

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk@1793920 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/96b9e847
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/96b9e847
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/96b9e847

Branch: refs/heads/trunk
Commit: 96b9e847ae1106cc5e316af854ed192e6bbda657
Parents: 1484c67
Author: Gary D. Gregory <ggregory@apache.org>
Authored: Thu May 4 22:43:15 2017 +0000
Committer: Gary D. Gregory <ggregory@apache.org>
Committed: Thu May 4 22:43:15 2017 +0000

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


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/96b9e847/httpcore5/src/main/java/org/apache/hc/core5/ssl/SSLContextBuilder.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/ssl/SSLContextBuilder.java b/httpcore5/src/main/java/org/apache/hc/core5/ssl/SSLContextBuilder.java
index 5797fd2..0b5cd78 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/ssl/SSLContextBuilder.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/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;
@@ -118,6 +119,11 @@ public class SSLContextBuilder {
         return this;
     }
 
+    public SSLContextBuilder setProvider(final String name) {
+        this.provider = Security.getProvider(name);
+        return this;
+    }
+
     public SSLContextBuilder setSecureRandom(final SecureRandom secureRandom) {
         this.secureRandom = secureRandom;
         return this;

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/96b9e847/httpcore5/src/test/java/org/apache/hc/core5/ssl/TestSSLContextBuilder.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/ssl/TestSSLContextBuilder.java b/httpcore5/src/test/java/org/apache/hc/core5/ssl/TestSSLContextBuilder.java
index 5ceeaa9..38b1a74 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/ssl/TestSSLContextBuilder.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/ssl/TestSSLContextBuilder.java
@@ -623,4 +623,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