#1176 Use nss_init_context() instead of nss_init() in Python client library
Closed: migrated by dmoluguw. Opened by edewata.

Currently the pki.crypto.NSSCryptoProvider uses nss_init() to access the NSS database. The nss_init() doesn't allow the concurrent use of multiple NSS databases in the same process, and the database is opened in read-only mode, so all database modifications have to be done before that, which is very limiting.

The NSSCryptoProvider should use the nss_init_context() instead which allows creating a separate context for each NSS database, and it's opened in read & write mode.

Make sure the NSS library version that supports nss_init_context() is available on all supported platforms.

https://www.mozilla.org/projects/security/pki/python-nss/doc/api/current/html/nss.nss-module.html#nss_init

https://www.mozilla.org/projects/security/pki/python-nss/doc/api/current/html/nss.nss-module.html#nss_init_context


I ran into the same issue while I was working on requests_nss. https://wiki.mozilla.org/NSS_Library_Init explains the different between NSS_Init() and NSS_InitContext() even better. NSS_InitContext() should be accompanied by a NSS_ShutdownContext(), too.

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

See also https://pagure.io/dogtagpki/issue/974

Metadata Update from @edewata:
- Custom field feature adjusted to None
- Custom field proposedmilestone adjusted to None
- Custom field proposedpriority adjusted to None
- Custom field reviewer adjusted to None
- Custom field version adjusted to None
- Issue close_status updated to: None

Metadata Update from @mharmsen:
- Issue priority set to: blocker (was: major)
- Issue set to the milestone: 10.5 (was: UNTRIAGED)

Metadata Update from @mharmsen:
- Issue priority set to: critical (was: blocker)

Metadata Update from @mharmsen:
- Issue priority set to: major (was: critical)

[20171025] - Offline Triage ==> 10.6

Metadata Update from @mharmsen:
- Issue set to the milestone: 10.6 (was: 10.5)

NOTE If you switch to nss_init_context, then you have to use NSS_INIT_READONLY or require a SQL format database. DBM databases are not concurrency safe. The class uses certutil to import a cert. This operation will likely destroy the DBM database.

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/1739

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)

Metadata