RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1144186 - Cannot delete orphan private keys with certutil.
Summary: Cannot delete orphan private keys with certutil.
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: nss
Version: 7.2
Hardware: Unspecified
OS: Unspecified
low
medium
Target Milestone: rc
: ---
Assignee: Daiki Ueno
QA Contact: Ivan Nikolchev
URL:
Whiteboard:
Depends On: 1645231
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-09-18 23:14 UTC by William Brown
Modified: 2019-08-06 13:08 UTC (History)
10 users (show)

Fixed In Version: nss-3.43.0-2.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-08-06 13:08:26 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Mozilla Foundation 291383 0 P4 RESOLVED certutil cannot delete orphan private keys 2021-02-16 17:25:13 UTC
Red Hat Product Errata RHSA-2019:2237 0 None None None 2019-08-06 13:08:53 UTC

Description William Brown 2014-09-18 23:14:34 UTC
Description of problem:
Cannot delete orhpan private keys with certutil.

[root@ammy slapd-ammy]# certutil -L -d .

Certificate Nickname                                         Trust Attributes
                                                             SSL,S/MIME,JAR/XPI

[root@ammy slapd-ammy]# certutil -K -d .
certutil: Checking token "NSS Certificate DB" in slot "NSS User Private Key and Certificate Services"
Enter Password or Pin for "NSS Certificate DB":
< 0> rsa      7d4b5b10928a99fb660422e1c4adb6490260671c   (orphan)
< 1> rsa      788a94edbeb030b97cdbc7cc401dc31cea20e69b   (orphan)
[root@ammy slapd-ammy]# certutil -F -d . -n '(orphan)'
Enter Password or Pin for "NSS Certificate DB":
[root@ammy slapd-ammy]# certutil -K -d .
certutil: Checking token "NSS Certificate DB" in slot "NSS User Private Key and Certificate Services"
Enter Password or Pin for "NSS Certificate DB":
< 0> rsa      7d4b5b10928a99fb660422e1c4adb6490260671c   (orphan)
< 1> rsa      788a94edbeb030b97cdbc7cc401dc31cea20e69b   (orphan)
[root@ammy slapd-ammy]# certutil -F -d . -n 7d4b5b10928a99fb660422e1c4adb6490260671c
certutil: Checking token "NSS Certificate DB" in slot "NSS User Private Key and Certificate Services"
Enter Password or Pin for "NSS Certificate DB":
< 0> rsa      7d4b5b10928a99fb660422e1c4adb6490260671c   (orphan)
< 1> rsa      788a94edbeb030b97cdbc7cc401dc31cea20e69b   (orphan)


There is no way to remove orphan certs without deleting and recreating the database. In this example I can do so, but on a production system, it's infeasible.

Comment 3 lejeczek 2016-04-08 16:30:52 UTC
yes, me too.

Comment 4 Yuri Arabadji 2016-09-27 14:00:05 UTC
+1
NSS management utils are hell.

Comment 5 Julius Schwartzenberg 2017-01-19 13:24:25 UTC
There seems to be an upstream bug for the same problem as well:
https://bugzilla.mozilla.org/show_bug.cgi?id=291383

Comment 7 Kai Engert (:kaie) (inactive account) 2018-03-09 17:18:37 UTC
I realize that NSS provides an utility that might be useful for this purpose:
  symkeyutil

We ship it as part of the nss-tools package.
It's in the unsupported directory, because we don't have documentation for it etc.

However, you should be able execute it directly using its full path:
  /usr/lib64/nss/unsupported-tools/symkeyutil

Use parameter -H for help

It seems that an orphan key (no nickname) can be deleted using
  symkeyutil -D -i <id-printed-by-certutil>

Does that work for you?

Comment 8 Kai Engert (:kaie) (inactive account) 2018-03-09 17:23:32 UTC
I take that back.

The keys you're talking about aren't symmetric keys.

Comment 9 Richard Chan 2018-07-07 03:09:11 UTC
This persists in 3.38 with a bizarre workaround:

now you can adopt an orphan key using -R and hexadecimal.

## specify the key by nickname but will fallback to checking hexadecimal
certutil -R -k 0x788a94edbeb030b97cdbc7cc401dc31cea20e69b -a -s CN=adoptkey
(The 0x is optional).

For some reason -R tests for hex id in -k, but -F does not test for hex id in -n.

Then you can generate a self-signed cert form the CSR -> inject the cert -> delete both cert/key

This does not work if your orphan key is ec. Then the R -k <hex-id> trick doesn't work.

NSS management utils are still hell.

Comment 10 Richard Chan 2018-07-07 03:37:52 UTC
Just a follow-up note on EC keys: the reason the adopt-a-key drive fails on EC keys is a limitation in nss-softokn nss-softokn-freebl

In order to generate the CSR from the orphan key, certutil attempts to extract the attribute CKA_EC_POINT from the ec orphan key. Not all PKCS11 modules implement this and softokn is sadly one of them (<-- this attribute is not required by the standard).

AWS CloudHSM/SafeNet Luna is an example where this would work as they provide CKA_EC_POINT in  the CKO_PRIVATE_KEY of EC type.

Comment 11 Simo Sorce 2019-02-11 15:41:11 UTC
This issue was not selected to be included either in Red Hat Enterprise Linux 7.7 because it is seen either as low or moderate impact to a small amount of use-cases. The next release will be in Maintenance Support 1 Phase, which means that qualified Critical and Important Security errata advisories (RHSAs) and Urgent Priority Bug Fix errata advisories (RHBAs) may be released as they become available. We will now close this issue, but if you believe that it qualifies for the Maintenance Support 1 Phase, please re-open; otherwise we recommend moving the request to Red Hat Enterprise Linux 8 if applicable.

Comment 22 errata-xmlrpc 2019-08-06 13:08:26 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2019:2237


Note You need to log in before you can comment on or make changes to this bug.