#104 Improve NSS token handling
Merged by rcritten. Opened by rcritten.
rcritten/certmonger tokens  into  master

Certificates could not be saved to the appropriate token. They were always stored in the NSS certificate database and in the case of a token we may not have access to it. This also affects de-duplication where other tokens are no longer examined.

The NSS p11-kit-proxy introduced in F29 makes extra tokens visible at all times which was confusing certmonger because in some cases it was trying to authenticate to the wrong token.

Note that most of the changes are simply moving code into deeper nesting. The big change in certsave-n.c is to find the right token and authenticate to it.

If no token is specified (for cert or key) then the internal NSS token is assumed.

The final change is related to the tests. Apparently $HOME/.rnd is required for some openssl commands but not created automatically? I just need to ensure it exists for the tests to pass.

Note that I've found a few more places where token handling isn't correct. It doesn't cause things to blow up but it does mean that certs seem to be saved both to the internal token and to the named token. I'm still investigating.

1 new commit added

  • Use only PK11_ImportCert to import certs, not CERT_ImportCerts

Why do you check for strlen() != 0, too?

Yeah, probably not needed. I don't know that an empty token value is even allowed. Maybe it was an attempt to save a strcmp? I can remove it.

rebased onto 3da0e186904ad81dd87cf74bfae88270f14bb770

Pull-Request has been merged by rcritten