aboutsummaryrefslogtreecommitdiff
path: root/cast/common/certificate/cast_trust_store.h
blob: 7bd7595594d7765077de5518450fbe11214be4bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CAST_COMMON_CERTIFICATE_CAST_TRUST_STORE_H_
#define CAST_COMMON_CERTIFICATE_CAST_TRUST_STORE_H_

#include <vector>

#include "absl/strings/string_view.h"
#include "cast/common/certificate/cast_cert_validator_internal.h"

namespace openscreen {
namespace cast {

class CastTrustStore {
 public:
  static CastTrustStore* GetInstance();
  static void ResetInstance();

  static CastTrustStore* CreateInstanceForTest(
      const std::vector<uint8_t>& trust_anchor_der);

  static CastTrustStore* CreateInstanceFromPemFile(
      absl::string_view file_path,
      TrustStore::Mode mode = TrustStore::Mode::kStrict);

  CastTrustStore();
  explicit CastTrustStore(const std::vector<uint8_t>& trust_anchor_der);
  explicit CastTrustStore(TrustStore trust_store);
  CastTrustStore(const CastTrustStore&) = delete;
  ~CastTrustStore();
  CastTrustStore& operator=(const CastTrustStore&) = delete;

  TrustStore* trust_store() { return &trust_store_; }

 private:
  static CastTrustStore* store_;
  TrustStore trust_store_;
};

}  // namespace cast
}  // namespace openscreen

#endif  // CAST_COMMON_CERTIFICATE_CAST_TRUST_STORE_H_