void release_pkcs11_module(pkcs11_handle_t *h) { SECStatus rv; close_pkcs11_session(h); if (h->is_user_module) { rv = SECMOD_UnloadUserModule(h->module); if (rv != SECSuccess) { DBG1("Unloading UserModule failed: %s", SECU_Strerror(PR_GetError())); } } if (h->module) { SECMOD_DestroyModule(h->module); } memset(h, 0, sizeof(pkcs11_handle_t)); free(h); /* if we initialized NSS, then we need to shut it down */ if (!app_has_NSS) { rv = NSS_Shutdown(); if (rv != SECSuccess) { DBG1("NSS Shutdown Failed: %s", SECU_Strerror(PR_GetError())); } } }
/* Global cleanup */ void Curl_nss_cleanup(void) { /* This function isn't required to be threadsafe and this is only done * as a safety feature. */ PR_Lock(nss_initlock); if (initialized) { /* Free references to client certificates held in the SSL session cache. * Omitting this hampers destruction of the security module owning * the certificates. */ SSL_ClearSessionCache(); if(mod && SECSuccess == SECMOD_UnloadUserModule(mod)) { SECMOD_DestroyModule(mod); mod = NULL; } NSS_Shutdown(); } PR_Unlock(nss_initlock); PR_DestroyLock(nss_initlock); nss_initlock = NULL; initialized = 0; }
void UnloadLoadableRoots(const char* modNameUTF8) { PR_ASSERT(modNameUTF8); ScopedSECMODModule rootsModule(SECMOD_FindModule(modNameUTF8)); if (rootsModule) { SECMOD_UnloadUserModule(rootsModule.get()); } }