#1376 Misleading exception message in EnrollProfile
Closed: Invalid None Opened 9 years ago by edewata.

Under certain circumstances the EnrollProfile might throw an EProfileException with a message saying "Invalid Request" whereas the actual error may be something completely different, thus misleading the investigation of the actual error and delaying the resolution.

In the following example the actual error is NoSuchTokenException:
https://www.redhat.com/archives/freeipa-users/2015-May/msg00195.html

[11/May/2015:20:38:49][http-9180-1]: EnrollProfile: parsePKCS10:
signature verification enabled
[11/May/2015:20:38:49][http-9180-1]: EnrollProfile: parsePKCS10
org.mozilla.jss.NoSuchTokenException
[11/May/2015:20:38:49][http-9180-1]: EnrollProfile: parsePKCS10
restoring thread token
Invalid Request
        at
com.netscape.cms.profile.common.EnrollProfile.parsePKCS10(EnrollProfile.java:953)
        at
...

Here is the code:

try {
    cm = CryptoManager.getInstance();
    sigver = CMS.getConfigStore().getBoolean("ca.requestVerify.enabled", true);
    if (sigver) {
        CMS.debug("EnrollProfile: parsePKCS10: signature verification enabled");
        String tokenName = CMS.getConfigStore().getString("ca.requestVerify.token",
            "Internal Key Storage Token");
        savedToken = cm.getThreadToken();
        CryptoToken signToken = cm.getTokenByName(tokenName);
        CMS.debug("EnrollProfile: parsePKCS10 setting thread token");
        cm.setThreadToken(signToken);
        pkcs10 = new PKCS10(data);
    } else {
        CMS.debug("EnrollProfile: parsePKCS10: signature verification disabled");
        pkcs10 = new PKCS10(data, sigver);
    }
} catch (Exception e) {
    CMS.debug("EnrollProfile: parsePKCS10 " + e.toString());
    throw new EProfileException(
        CMS.getUserMessage(locale, "CMS_PROFILE_INVALID_REQUEST"));
} finally {
    if (sigver) {
        CMS.debug("EnrollProfile: parsePKCS10 restoring thread token");
        cm.setThreadToken(savedToken);
    }
}

Possible solutions:
1. The message should be changed into "Parsing Error" or just "Error" instead of "Invalid Request".
2. The EProfileException should be chained to the original exception so the cause will appear in the stack trace.
3. Do not catch JSS exceptions and let them be handled by the caller.
4. Fix similar issues in EnrollProfile.

Proposed milestone: 9.0.x


Metadata Update from @edewata:
- Issue set to the milestone: 9.0

7 years ago

Dogtag PKI is moving from Pagure issues to GitHub issues. This means that existing or new
issues will be reported and tracked through Dogtag PKI's GitHub Issue tracker.

This issue has been cloned to GitHub and is available here:
https://github.com/dogtagpki/pki/issues/1938

If you want to receive further updates on the issue, please navigate to the
GitHub issue and click on Subscribe button.

Thank you for understanding, and we apologize for any inconvenience.

Log in to comment on this ticket.

Metadata