[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Pki-devel] [PATCH] 637 Fixed ObjectNotFoundException in PKCS12Export.



The PKCS12Export has been fixed to handle ObjectNotFoundException
when exporting certificates without private keys.

https://fedorahosted.org/pki/ticket/1506

--
Endi S. Dewata
From 4f4addd2d02fcde458cb5d169f399fdf1ff68ab6 Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata redhat com>
Date: Mon, 20 Jul 2015 22:03:17 +0200
Subject: [PATCH] Fixed ObjectNotFoundException in PKCS12Export.

The PKCS12Export has been fixed to handle ObjectNotFoundException
when exporting certificates without private keys.

https://fedorahosted.org/pki/ticket/1506
---
 base/java-tools/src/com/netscape/cmstools/PKCS12Export.java | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/base/java-tools/src/com/netscape/cmstools/PKCS12Export.java b/base/java-tools/src/com/netscape/cmstools/PKCS12Export.java
index 77e6b7cb842d1669a44c5652ee5b8f724306e107..b8999fe99f57af644643011345323484c7b6e4ac 100644
--- a/base/java-tools/src/com/netscape/cmstools/PKCS12Export.java
+++ b/base/java-tools/src/com/netscape/cmstools/PKCS12Export.java
@@ -224,17 +224,17 @@ public class PKCS12Export {
         for (int i = 0; i < certs.length; i++) {
             String nickname = certs[i].getNickname();
             debug(" * Certificate: " + nickname);
-            org.mozilla.jss.crypto.PrivateKey prikey = cm.findPrivKeyByCert(certs[i]);
+            try {
+                org.mozilla.jss.crypto.PrivateKey prikey = cm.findPrivKeyByCert(certs[i]);
 
-            if (prikey == null) {
-                debug("   Private key does not exist");
-                addCertBag(certs[i], null, safeContents);
-
-            } else {
                 debug("   Private key exists");
                 byte localKeyId[] =
                         addCertBag(certs[i], nickname, safeContents);
                 addKeyBag(prikey, certs[i], password, localKeyId, encSafeContents);
+
+            } catch (org.mozilla.jss.crypto.ObjectNotFoundException e) {
+                debug("   Private key does not exist");
+                addCertBag(certs[i], null, safeContents);
             }
         }
 
-- 
2.4.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]