net_trust_store.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright 2022 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 COMPONENTS_CAST_CERTIFICATE_NET_TRUST_STORE_H_
  5. #define COMPONENTS_CAST_CERTIFICATE_NET_TRUST_STORE_H_
  6. #include <vector>
  7. #include "base/check.h"
  8. #include "net/cert/pki/cert_errors.h"
  9. #include "net/cert/pki/trust_store_in_memory.h"
  10. #include "net/cert/x509_util.h"
  11. #include "third_party/openscreen/src/cast/common/public/trust_store.h"
  12. namespace cast_certificate {
  13. class NetTrustStore final : public openscreen::cast::TrustStore {
  14. public:
  15. using openscreen::cast::TrustStore::CertificatePathResult;
  16. NetTrustStore();
  17. ~NetTrustStore() override;
  18. // Adds a trust anchor given a DER-encoded certificate from static storage.
  19. template <size_t N>
  20. void AddAnchor(const uint8_t (&data)[N]) {
  21. AddAnchor(base::span<const uint8_t>(data, N));
  22. }
  23. void AddAnchor(base::span<const uint8_t> data);
  24. openscreen::ErrorOr<CertificatePathResult> FindCertificatePath(
  25. const std::vector<std::string>& der_certs,
  26. const openscreen::cast::DateTime& time) override;
  27. private:
  28. net::TrustStoreInMemory store_;
  29. };
  30. } // namespace cast_certificate
  31. #endif // COMPONENTS_CAST_CERTIFICATE_NET_TRUST_STORE_H_