hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1793920 - in /httpcomponents/httpcore/trunk/httpcore5/src: main/java/org/apache/hc/core5/ssl/SSLContextBuilder.java test/java/org/apache/hc/core5/ssl/TestSSLContextBuilder.java
Date Thu, 04 May 2017 22:43:15 GMT
Author: ggregory
Date: Thu May  4 22:43:15 2017
New Revision: 1793920

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

Modified:
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/ssl/SSLContextBuilder.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/ssl/TestSSLContextBuilder.java

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/ssl/SSLContextBuilder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/ssl/SSLContextBuilder.java?rev=1793920&r1=1793919&r2=1793920&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/ssl/SSLContextBuilder.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/ssl/SSLContextBuilder.java
Thu May  4 22:43:15 2017
@@ -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;

Modified: httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/ssl/TestSSLContextBuilder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/ssl/TestSSLContextBuilder.java?rev=1793920&r1=1793919&r2=1793920&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/ssl/TestSSLContextBuilder.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/ssl/TestSSLContextBuilder.java
Thu May  4 22:43:15 2017
@@ -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