[Pki-devel] [PATCH] 522 Fixed NPE in client-cert-import.

Endi Sukma Dewata edewata at redhat.com
Fri Aug 29 02:44:47 UTC 2014


The client-cert-import command has been modified to propertly
initialize the CLI environment to avoid a null pointer exception.

Ticket #1126

-- 
Endi S. Dewata
-------------- next part --------------
From 24e7a3bd7b2f24f4b80bd8b4c70621ea2c760c8a Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata at redhat.com>
Date: Thu, 28 Aug 2014 22:13:26 -0400
Subject: [PATCH] Fixed NPE in client-cert-import.

The client-cert-import command has been modified to propertly
initialize the CLI environment to avoid a null pointer exception.

Ticket #1126
---
 base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java       | 2 +-
 .../src/com/netscape/cmstools/client/ClientCertImportCLI.java    | 9 +++++++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java b/base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java
index 186c9827eb311f7221bf8957149c8b06329d34cc..e7097e8cae952fac075cb8ac9386feb5d74be789 100644
--- a/base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java
@@ -489,7 +489,7 @@ public class MainCLI extends CLI {
             System.out.println();
         }
 
-        // Do not call CryptoManager.initialize() on client-init
+        // Do not call CryptoManager.initialize() on client-init and client-cert-import
         // because otherwise the database will be locked.
         String command = cmdArgs[0];
         if (!command.equals("client-init") && !command.equals("client-cert-import")) {
diff --git a/base/java-tools/src/com/netscape/cmstools/client/ClientCertImportCLI.java b/base/java-tools/src/com/netscape/cmstools/client/ClientCertImportCLI.java
index e5b07b3e8d4f27a2a4b543913b44680eae8cb2cf..90e3d0a3e8c37ca22b177aab6f19703c225e7b2a 100644
--- a/base/java-tools/src/com/netscape/cmstools/client/ClientCertImportCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/client/ClientCertImportCLI.java
@@ -87,8 +87,6 @@ public class ClientCertImportCLI extends CLI {
             System.exit(-1);
         }
 
-        client = parent.getClient();
-
         byte[] bytes = null;
 
         String certPath = cmd.getOptionValue("cert");
@@ -110,7 +108,14 @@ public class ClientCertImportCLI extends CLI {
             isCACert = true;
 
         } else if (importFromCAServer) {
+
+            // late initialization
+            MainCLI mainCLI = (MainCLI)parent.parent;
+            mainCLI.init();
+
+            client = mainCLI.getClient();
             ClientConfig config = client.getConfig();
+
             String caServerURI = "http://" + config.getServerURI().getHost() + ":8080/ca";
 
             if (verbose) System.out.println("Downloading CA certificate from " + caServerURI + ".");
-- 
1.8.4.2



More information about the Pki-devel mailing list