summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2016-04-11 18:18:52 +0200
committerEndi S. Dewata <edewata@redhat.com>2016-04-12 16:27:20 +0200
commit8e291fba835f6640a262e01333aa58cf9bd5220f (patch)
tree86ce2d93290760c078fcf34f7d8d5cd9db0f2246
parent5847a485a16471f6c3a2a7552b719df3aec909df (diff)
downloadpki-8e291fba835f6640a262e01333aa58cf9bd5220f.tar.gz
pki-8e291fba835f6640a262e01333aa58cf9bd5220f.tar.xz
pki-8e291fba835f6640a262e01333aa58cf9bd5220f.zip
Fixed exception handling in CertUtil.
The CertUtil.createLocalCert() has been modified to re-throw the exception instead of ignoring it. https://fedorahosted.org/pki/ticket/1654
-rw-r--r--base/server/cms/src/com/netscape/cms/servlet/csadmin/CertUtil.java25
-rw-r--r--base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java7
2 files changed, 18 insertions, 14 deletions
diff --git a/base/server/cms/src/com/netscape/cms/servlet/csadmin/CertUtil.java b/base/server/cms/src/com/netscape/cms/servlet/csadmin/CertUtil.java
index f4cd82fcc..774ff94e3 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/csadmin/CertUtil.java
+++ b/base/server/cms/src/com/netscape/cms/servlet/csadmin/CertUtil.java
@@ -453,10 +453,20 @@ public class CertUtil {
} else {
keyAlgorithm = config.getString(prefix + certTag + ".keyalgorithm");
}
+
if (!caProvided)
ca = (ICertificateAuthority) CMS.getSubsystem(
ICertificateAuthority.ID);
+
cr = ca.getCertificateRepository();
+
+ if (cr == null) {
+ if (context != null) {
+ context.put("errorString", "Ceritifcate Authority is not ready to serve.");
+ }
+ throw new IOException("Ceritifcate Authority is not ready to serve.");
+ }
+
BigInteger serialNo = cr.getNextSerialNumber();
if (type.equals("selfsign")) {
CMS.debug("Creating local certificate... selfsign cert");
@@ -575,16 +585,13 @@ public class CertUtil {
if (cert != null) {
CMS.debug("CertUtil createSelfSignedCert: got cert signed");
}
- } catch (Exception e) {
- CMS.debug(e);
- CMS.debug("CertUtil createLocalCert() exception caught:" + e.toString());
- }
- if (cr == null) {
- if (context != null) {
- context.put("errorString", "Ceritifcate Authority is not ready to serve.");
- }
- throw new IOException("Ceritifcate Authority is not ready to serve.");
+ } catch (IOException e) {
+ throw e;
+
+ } catch (Exception e) {
+ CMS.debug("Unable to create local certificate: " + e);
+ throw new IOException("Unable to create local certificate: " + e, e);
}
ICertRecord record = null;
diff --git a/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java b/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java
index 7aeee7e9f..e2b014f35 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java
+++ b/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java
@@ -84,7 +84,6 @@ import org.mozilla.jss.crypto.EncryptionAlgorithm;
import org.mozilla.jss.crypto.IVParameterSpec;
import org.mozilla.jss.crypto.IllegalBlockSizeException;
import org.mozilla.jss.crypto.InternalCertificate;
-import org.mozilla.jss.crypto.InvalidKeyFormatException;
import org.mozilla.jss.crypto.KeyGenAlgorithm;
import org.mozilla.jss.crypto.KeyGenerator;
import org.mozilla.jss.crypto.KeyWrapAlgorithm;
@@ -3055,8 +3054,7 @@ public class ConfigurationUtils {
cr.addCertificateRecord(record);
}
- public static int handleCerts(Cert cert) throws IOException, EBaseException, CertificateException,
- NotInitializedException, TokenException, InvalidKeyException {
+ public static int handleCerts(Cert cert) throws Exception {
String certTag = cert.getCertTag();
String subsystem = cert.getSubsystem();
String nickname = cert.getNickname();
@@ -3491,8 +3489,7 @@ public class ConfigurationUtils {
}
public static void createAdminCertificate(String certRequest, String certRequestType, String subject)
- throws InvalidBERException, IOException, InvalidKeyException, InvalidKeyFormatException,
- NoSuchAlgorithmException, SignatureException, NoSuchProviderException, EBaseException {
+ throws Exception {
IConfigStore cs = CMS.getConfigStore();
X509Key x509key = null;
if (certRequestType.equals("crmf")) {