hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1789754 - in /httpcomponents/httpcore/trunk: RELEASE_NOTES.txt httpcore5/src/main/java/org/apache/hc/core5/ssl/SSLContextBuilder.java httpcore5/src/test/java/org/apache/hc/core5/ssl/TestSSLContextBuilder.java
Date Fri, 31 Mar 2017 22:10:04 GMT
Author: ggregory
Date: Fri Mar 31 22:10:04 2017
New Revision: 1789754

URL: http://svn.apache.org/viewvc?rev=1789754&view=rev
Log:
[HTTPCORE-450] Add a Provider parameter in SSLContextBuilder. Contributed by lujianbo <387852424
at qq dot com>, Gary Gregory <ggregory at apache.org>

Modified:
    httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
    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/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt?rev=1789754&r1=1789753&r2=1789754&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpcore/trunk/RELEASE_NOTES.txt Fri Mar 31 22:10:04 2017
@@ -1,3 +1,17 @@
+Release 5.0-ALPHA3
+-------------------
+
+This is a major release that renders HttpCore API incompatible with the stable 4.x branch
+and upgrades HTTP/1.1 and HTTP/2 protocol conformance to the requirements and recommendations
+of the latest protocol specification.
+
+Changelog
+-------------------
+
+* HTTPCORE-450: Add a Provider parameter in SSLContextBuilder.
+  Contributed by lujianbo <387852424 at qq dot com>, Gary Gregory <ggregory at apache.org>
+
+
 Release 5.0-ALPHA2
 -------------------
 

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=1789754&r1=1789753&r2=1789754&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
Fri Mar 31 22:10:04 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;
@@ -81,6 +82,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();
@@ -97,6 +99,11 @@ public class SSLContextBuilder {
         return this;
     }
 
+    public SSLContextBuilder setProvider(final Provider provider) {
+        this.provider = provider;
+        return this;
+    }
+
     public SSLContextBuilder setSecureRandom(final SecureRandom secureRandom) {
         this.secureRandom = secureRandom;
         return this;
@@ -267,8 +274,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/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=1789754&r1=1789753&r2=1789754&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
Fri Mar 31 22:10:04 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;
@@ -610,4 +611,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