#181 Unable to remove user cert via console
Closed: migrated 2 years ago by dmoluguw. Opened 11 years ago by edewata.

Console generates the following exception when removing a user certificate:

Exception in thread "AWT-EventQueue-0" java.lang.StringIndexOutOfBoundsException: String index out of range: -4
    at java.lang.String.substring(String.java:1958)
    at com.netscape.admin.certsrv.ug.CertManagementDialog.toServerFormat(CertManagementDialog.java:334)
    at com.netscape.admin.certsrv.ug.CertManagementDialog.deleteCert(CertManagementDialog.java:423)
    at com.netscape.admin.certsrv.ug.CertManagementDialog.actionPerformed(CertManagementDialog.java:130)

It looks like in CertManagementDialog.java:334 the code is trying to get the serial number from a string but the string doesn't have it.

The problem only happens with large serial number such as "12512514865863765114". In CertManagementDialog?.java:368 the console tries to parse the serial number that it receives from the server as an integer:

try {
    if (serial != null) {
        String hexserial = Integer.toHexString(Integer.parseInt(serial));
        name = name + "Serial:0x"+hexserial;
} catch (Exception e) {}

If the serial number is outside the integer range the parseInt() throws a number format exception, so the serial number is not added to the string that's going to be read by line 334 above, causing the original problem. Also, the exception is swallowed by the code, so the problem is undetected until you try to remove a certificate.

So the integer parsing should be replaced with BigInteger (or SerialNumber class) and the exception should be handled properly (e.g. generating error dialog).

Metadata Update from @edewata:
- Issue assigned to awnuk
- Issue set to the milestone: UNTRIAGED

6 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:

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.

Metadata Update from @dmoluguw:
- Issue close_status updated to: migrated
- Issue status updated to: Closed (was: Open)

2 years ago

Login to comment on this ticket.