nifi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcgil...@apache.org
Subject [23/36] incubator-nifi git commit: NIFI-310: Fixed NPE
Date Wed, 04 Feb 2015 18:57:17 GMT
NIFI-310: Fixed NPE


Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/102e3cb0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/102e3cb0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/102e3cb0

Branch: refs/heads/NIFI-250
Commit: 102e3cb093cd7380ffaf5ebff80a8fe64485c22b
Parents: be16371
Author: Mark Payne <markap14@hotmail.com>
Authored: Tue Feb 3 10:37:28 2015 -0500
Committer: Mark Payne <markap14@hotmail.com>
Committed: Tue Feb 3 10:37:28 2015 -0500

----------------------------------------------------------------------
 .../nifi/processors/standard/PostHTTP.java      | 30 ++++++++++++--------
 1 file changed, 18 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/102e3cb0/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PostHTTP.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PostHTTP.java
b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PostHTTP.java
index fd486b0..f8a33bc 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PostHTTP.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PostHTTP.java
@@ -68,6 +68,7 @@ import org.apache.http.conn.HttpClientConnectionManager;
 import org.apache.http.conn.ManagedHttpClientConnection;
 import org.apache.http.conn.socket.ConnectionSocketFactory;
 import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLContextBuilder;
 import org.apache.http.conn.ssl.SSLContexts;
 import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
 import org.apache.http.entity.ContentProducer;
@@ -352,21 +353,26 @@ public class PostHTTP extends AbstractProcessor {
     private SSLContext createSSLContext(final SSLContextService service) throws KeyStoreException,
IOException, NoSuchAlgorithmException, 
         CertificateException, KeyManagementException, UnrecoverableKeyException 
     {
-        final KeyStore truststore  = KeyStore.getInstance(service.getTrustStoreType());
-        try (final InputStream in = new FileInputStream(new File(service.getTrustStoreFile())))
{
-            truststore.load(in, service.getTrustStorePassword().toCharArray());
+        SSLContextBuilder builder = SSLContexts.custom();
+        final String trustFilename = service.getTrustStoreFile();
+        if ( trustFilename != null ) {
+            final KeyStore truststore  = KeyStore.getInstance(service.getTrustStoreType());
+            try (final InputStream in = new FileInputStream(new File(service.getTrustStoreFile())))
{
+                truststore.load(in, service.getTrustStorePassword().toCharArray());
+            }
+            builder = builder.loadTrustMaterial(truststore, new TrustSelfSignedStrategy());
         }
-        
-        final KeyStore keystore  = KeyStore.getInstance(service.getKeyStoreType());
-        try (final InputStream in = new FileInputStream(new File(service.getKeyStoreFile())))
{
-            keystore.load(in, service.getKeyStorePassword().toCharArray());
+
+        final String keyFilename = service.getKeyStoreFile();
+        if ( keyFilename != null ) {
+            final KeyStore keystore  = KeyStore.getInstance(service.getKeyStoreType());
+            try (final InputStream in = new FileInputStream(new File(service.getKeyStoreFile())))
{
+                keystore.load(in, service.getKeyStorePassword().toCharArray());
+            }
+            builder = builder.loadKeyMaterial(keystore, service.getKeyStorePassword().toCharArray());
         }
         
-        SSLContext sslContext = SSLContexts.custom()
-                .loadTrustMaterial(truststore, new TrustSelfSignedStrategy())
-                .loadKeyMaterial(keystore, service.getKeyStorePassword().toCharArray())
-                .build();
-        
+        SSLContext sslContext = builder.build();
         return sslContext;
     }
 


Mime
View raw message