Skip to content

Commit

Permalink
Troubleshooting improvement for ConfigurationUtils.handleCerts().
Browse files Browse the repository at this point in the history
To help troubleshooting, the ConfigurationUtils.handleCerts()
has been modified to throw the exception instead of returning an
integer.

https://fedorahosted.org/pki/ticket/2463
  • Loading branch information
edewata committed Oct 28, 2016
1 parent 443dcb1 commit 50559c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
Expand Up @@ -3162,15 +3162,15 @@ public static void loadCert(IConfigStore config, Cert cert) throws Exception {
cr.addCertificateRecord(record);
}

public static int handleCerts(Cert cert) throws Exception {
public static void handleCerts(Cert cert) throws Exception {
String certTag = cert.getCertTag();
String subsystem = cert.getSubsystem();
String nickname = cert.getNickname();
IConfigStore config = CMS.getConfigStore();

boolean enable = config.getBoolean(PCERT_PREFIX + certTag + ".enable", true);
if (!enable)
return 0;
return;

CMS.debug("handleCerts(): for cert tag '" + cert.getCertTag() + "' using cert type '" + cert.getType() + "'");
String b64 = cert.getCert();
Expand All @@ -3190,7 +3190,7 @@ public static int handleCerts(Cert cert) throws Exception {

if (findCertificate(tokenname, nickname)) {
if (!certTag.equals("sslserver"))
return 0;
return;
}
X509CertImpl impl = CertUtil.createLocalCert(config, x509key,
PCERT_PREFIX, certTag, cert.getType(), null);
Expand Down Expand Up @@ -3291,7 +3291,7 @@ public static int handleCerts(Cert cert) throws Exception {

} else {
CMS.debug("handleCerts(): b64 not set");
return 1;
throw new PKIException("Missing " + certTag + " certificate to import");
}

} else {
Expand Down Expand Up @@ -3321,7 +3321,7 @@ public static int handleCerts(Cert cert) throws Exception {
CryptoUtil.importUserCertificate(impl, nickname, false);
} catch (Exception ee) {
CMS.debug("handleCerts(): Failed to import user certificate." + ee.toString());
return 1;
throw new Exception("Unable to import " + certTag + " certificate: " + ee, ee);
}
}

Expand All @@ -3339,7 +3339,6 @@ public static int handleCerts(Cert cert) throws Exception {
CryptoUtil.trustCertByNickname(NickName);
CMS.reinit(ICertificateAuthority.ID);
}
return 0;
}

public static void setCertPermissions(String tag) throws EBaseException, NotInitializedException,
Expand Down
Expand Up @@ -195,18 +195,14 @@ public void configure(ConfigurationRequest data, ConfigurationResponse response)
}

for (Cert cert : certs) {
int ret;
try {
CMS.debug("Processing '" + cert.getCertTag() + "' certificate:");
ret = ConfigurationUtils.handleCerts(cert);
ConfigurationUtils.handleCerts(cert);
ConfigurationUtils.setCertPermissions(cert.getCertTag());
CMS.debug("Processed '" + cert.getCertTag() + "' certificate.");
} catch (Exception e) {
CMS.debug(e);
throw new PKIException("Error in configuring system certificates" + e, e);
}
if (ret != 0) {
throw new PKIException("Error in configuring system certificates");
throw new PKIException("Error in configuring system certificates: " + e, e);
}
}
response.setSystemCerts(SystemCertDataFactory.create(certs));
Expand Down

0 comments on commit 50559c3

Please sign in to comment.