Skip to content

Commit

Permalink
Bug2246422-(refinement of)ServerSideKeygen static SKID
Browse files Browse the repository at this point in the history
This small patch is to refine the previous patch
where the exceptions thrown in CertUtils.java will
not depend on EProfileException.

related to https://bugzilla.redhat.com/show_bug.cgi?id=2246422
  • Loading branch information
ladycfu committed Nov 16, 2023
1 parent 6232c05 commit 8d36876
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions base/server/src/main/java/com/netscape/cmscore/cert/CertUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
import com.netscape.certsrv.logging.AuditEvent;
import com.netscape.certsrv.logging.ILogger;
import com.netscape.certsrv.logging.LogEvent;
import com.netscape.certsrv.profile.EProfileException;
import com.netscape.certsrv.request.IRequest;
import com.netscape.cms.logging.Logger;
import com.netscape.cms.logging.SignedAuditLogger;
Expand Down Expand Up @@ -194,7 +193,7 @@ public static PKCS10 parsePKCS10(Locale locale, String certreq) throws Exception

if (certreq == null) {
logger.error("CertUtils: Missing PKCS #10 request");
throw new EProfileException(CMS.getUserMessage(locale, "CMS_PROFILE_INVALID_REQUEST"));
throw new EBaseException(CMS.getUserMessage(locale, "CMS_PROFILE_INVALID_REQUEST"));
}

logger.debug(certreq);
Expand Down Expand Up @@ -228,7 +227,7 @@ public static PKCS10 parsePKCS10(Locale locale, String certreq) throws Exception

} catch (Exception e) {
logger.error("Unable to parse PKCS #10 request: " + e.getMessage(), e);
throw new EProfileException(CMS.getUserMessage(locale, "CMS_PROFILE_INVALID_REQUEST"), e);
throw new EBaseException(CMS.getUserMessage(locale, "CMS_PROFILE_INVALID_REQUEST"), e);

} finally {
if (sigver) {
Expand All @@ -244,7 +243,7 @@ public static CertReqMsg[] parseCRMF(Locale locale, String certreq) throws Excep

if (certreq == null) {
logger.error("CertUtils: Missing CRMF request");
throw new EProfileException(CMS.getUserMessage(locale, "CMS_PROFILE_INVALID_REQUEST"));
throw new EBaseException(CMS.getUserMessage(locale, "CMS_PROFILE_INVALID_REQUEST"));
}

byte[] data = CertUtil.parseCSR(certreq);
Expand All @@ -268,7 +267,7 @@ public static CertReqMsg[] parseCRMF(Locale locale, String certreq) throws Excep

} catch (Exception e) {
logger.error("Unable to parse CRMF request: " + e.getMessage(), e);
throw new EProfileException(CMS.getUserMessage(locale, "CMS_PROFILE_INVALID_REQUEST"), e);
throw new EBaseException(CMS.getUserMessage(locale, "CMS_PROFILE_INVALID_REQUEST"), e);
}
}

Expand Down Expand Up @@ -572,9 +571,9 @@ public static String getCertType(X509CertImpl cert) throws CertificateParsingExc
}

public static void addExtension(String name, Extension ext, X509CertInfo info)
throws EProfileException {
throws EBaseException {
if (ext == null) {
throw new EProfileException("addExtension: extension '" + name + "' is null");
throw new EBaseException("addExtension: extension '" + name + "' is null");
}
CertificateExtensions exts = null;

Expand All @@ -583,7 +582,7 @@ public static void addExtension(String name, Extension ext, X509CertInfo info)
if (alreadyPresentExtension != null) {
String eName = ext.toString();
logger.error("Duplicate extension: " + eName);
throw new EProfileException(CMS.getUserMessage("CMS_PROFILE_DUPLICATE_EXTENSION", eName));
throw new EBaseException(CMS.getUserMessage("CMS_PROFILE_DUPLICATE_EXTENSION", eName));
}

try {
Expand All @@ -593,7 +592,7 @@ public static void addExtension(String name, Extension ext, X509CertInfo info)
logger.warn("EnrollDefault: " + e.getMessage(), e);
}
if (exts == null) {
throw new EProfileException("extensions not found");
throw new EBaseException("extensions not found");
}
try {
exts.set(name, ext);
Expand Down Expand Up @@ -630,11 +629,11 @@ public static void deleteExtension(String extID, X509CertInfo info) throws Excep
}

public static void replaceExtension(String name, Extension ext, X509CertInfo info)
throws EProfileException {
throws EBaseException {
try {
deleteExtension(name, info);
} catch (Exception e) {
throw new EProfileException(e);
throw new EBaseException(e);
}

addExtension(name, ext, info);
Expand Down

0 comments on commit 8d36876

Please sign in to comment.