scoped_test_nss_db.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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
  3. // found in the LICENSE file.
  4. #ifndef CRYPTO_SCOPED_TEST_NSS_DB_H_
  5. #define CRYPTO_SCOPED_TEST_NSS_DB_H_
  6. #include "base/files/scoped_temp_dir.h"
  7. #include "crypto/crypto_export.h"
  8. #include "crypto/scoped_nss_types.h"
  9. namespace crypto {
  10. // Opens a persistent NSS database in a temporary directory.
  11. // Prior NSS version 3.15.1, because of http://bugzil.la/875601 , the opened DB
  12. // will not be closed automatically.
  13. class CRYPTO_EXPORT ScopedTestNSSDB {
  14. public:
  15. ScopedTestNSSDB();
  16. ScopedTestNSSDB(const ScopedTestNSSDB&) = delete;
  17. ScopedTestNSSDB& operator=(const ScopedTestNSSDB&) = delete;
  18. ~ScopedTestNSSDB();
  19. bool is_open() const { return !!slot_; }
  20. PK11SlotInfo* slot() const { return slot_.get(); }
  21. private:
  22. // Removes trust from all certificates found in |slot_|.
  23. void RemoveTrustFromAllCerts();
  24. base::ScopedTempDir temp_dir_;
  25. ScopedPK11Slot slot_;
  26. };
  27. } // namespace crypto
  28. #endif // CRYPTO_SCOPED_TEST_NSS_DB_H_