| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "crypto/scoped_test_nss_db.h" | 5 #include "crypto/scoped_test_nss_db.h" |
| 6 | 6 |
| 7 #include <cert.h> | 7 #include <cert.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 node = CERT_LIST_NEXT(node)) { | 37 node = CERT_LIST_NEXT(node)) { |
| 38 CERTCertTrust trust = {0}; | 38 CERTCertTrust trust = {0}; |
| 39 if (CERT_ChangeCertTrust(CERT_GetDefaultCertDB(), node->cert, &trust) != | 39 if (CERT_ChangeCertTrust(CERT_GetDefaultCertDB(), node->cert, &trust) != |
| 40 SECSuccess) { | 40 SECSuccess) { |
| 41 LOG(ERROR) << "CERT_ChangeCertTrust failed: " << PORT_GetError(); | 41 LOG(ERROR) << "CERT_ChangeCertTrust failed: " << PORT_GetError(); |
| 42 } | 42 } |
| 43 } | 43 } |
| 44 CERT_DestroyCertList(cert_list); | 44 CERT_DestroyCertList(cert_list); |
| 45 } | 45 } |
| 46 | 46 |
| 47 // Don't close when NSS is < 3.15.1, because it would require an additional | |
| 48 // sleep for 1 second after closing the database, due to | |
| 49 // http://bugzil.la/875601. | |
| 50 if (!NSS_VersionCheck("3.15.1")) { | |
| 51 LOG(ERROR) << "NSS version is < 3.15.1, test DB will not be closed."; | |
| 52 temp_dir_.Take(); | |
| 53 return; | |
| 54 } | |
| 55 | |
| 56 // NSS is allowed to do IO on the current thread since dispatching | 47 // NSS is allowed to do IO on the current thread since dispatching |
| 57 // to a dedicated thread would still have the affect of blocking | 48 // to a dedicated thread would still have the affect of blocking |
| 58 // the current thread, due to NSS's internal locking requirements | 49 // the current thread, due to NSS's internal locking requirements |
| 59 base::ThreadRestrictions::ScopedAllowIO allow_io; | 50 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 60 | 51 |
| 61 if (slot_) { | 52 if (slot_) { |
| 62 SECStatus status = SECMOD_CloseUserDB(slot_.get()); | 53 SECStatus status = SECMOD_CloseUserDB(slot_.get()); |
| 63 if (status != SECSuccess) | 54 if (status != SECSuccess) |
| 64 PLOG(ERROR) << "SECMOD_CloseUserDB failed: " << PORT_GetError(); | 55 PLOG(ERROR) << "SECMOD_CloseUserDB failed: " << PORT_GetError(); |
| 65 } | 56 } |
| 66 | 57 |
| 67 if (!temp_dir_.Delete()) | 58 if (!temp_dir_.Delete()) |
| 68 LOG(ERROR) << "Could not delete temporary directory."; | 59 LOG(ERROR) << "Could not delete temporary directory."; |
| 69 } | 60 } |
| 70 | 61 |
| 71 } // namespace crypto | 62 } // namespace crypto |
| OLD | NEW |