Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2406)

Unified Diff: crypto/scoped_test_nss_db.cc

Issue 1532223005: Remove trust from any certs in ScopedTestDB before closing it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crypto/scoped_test_nss_db.cc
diff --git a/crypto/scoped_test_nss_db.cc b/crypto/scoped_test_nss_db.cc
index 452c26d73e50500dd820b58f3821387404414448..dc58031ce5dd63ea11f1c704c711df545442c081 100644
--- a/crypto/scoped_test_nss_db.cc
+++ b/crypto/scoped_test_nss_db.cc
@@ -4,6 +4,8 @@
#include "crypto/scoped_test_nss_db.h"
+#include <cert.h>
+
#include "base/logging.h"
#include "base/threading/thread_restrictions.h"
#include "crypto/nss_util.h"
@@ -26,6 +28,22 @@ ScopedTestNSSDB::ScopedTestNSSDB() {
}
ScopedTestNSSDB::~ScopedTestNSSDB() {
+ // Remove trust from any certs in the test DB before closing it. Otherwise NSS
+ // may cache verification results even after the test DB is gone.
+ if (slot_) {
+ CERTCertList* cert_list = PK11_ListCertsInSlot(slot_.get());
+ for (CERTCertListNode* node = CERT_LIST_HEAD(cert_list);
+ !CERT_LIST_END(node, cert_list);
+ node = CERT_LIST_NEXT(node)) {
+ CERTCertTrust trust = {0};
+ if (CERT_ChangeCertTrust(CERT_GetDefaultCertDB(), node->cert, &trust) !=
+ SECSuccess) {
+ LOG(ERROR) << "CERT_ChangeCertTrust failed: " << PORT_GetError();
+ }
+ }
+ CERT_DestroyCertList(cert_list);
+ }
+
// Don't close when NSS is < 3.15.1, because it would require an additional
// sleep for 1 second after closing the database, due to
// http://bugzil.la/875601.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698