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

Side by Side Diff: components/cast_certificate/cast_crl.cc

Issue 2205403002: Add production Cast CRL certificate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/cast_certificate/cast_crl.h" 5 #include "components/cast_certificate/cast_crl.h"
6 6
7 #include <unordered_map> 7 #include <unordered_map>
8 #include <unordered_set> 8 #include <unordered_set>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 // Singleton for the Cast CRL trust store. 50 // Singleton for the Cast CRL trust store.
51 class CastCRLTrustStore { 51 class CastCRLTrustStore {
52 public: 52 public:
53 static CastCRLTrustStore* GetInstance() { 53 static CastCRLTrustStore* GetInstance() {
54 return base::Singleton<CastCRLTrustStore, base::LeakySingletonTraits< 54 return base::Singleton<CastCRLTrustStore, base::LeakySingletonTraits<
55 CastCRLTrustStore>>::get(); 55 CastCRLTrustStore>>::get();
56 } 56 }
57 57
58 static net::TrustStore& Get() { return GetInstance()->store_; } 58 static net::TrustStore& Get() { return GetInstance()->store_; }
59 59
60 static void Reinitialize() { GetInstance()->Initialize(); }
61
60 private: 62 private:
61 friend struct base::DefaultSingletonTraits<CastCRLTrustStore>; 63 friend struct base::DefaultSingletonTraits<CastCRLTrustStore>;
62 64
63 CastCRLTrustStore() { 65 CastCRLTrustStore() { Initialize(); }
66
67 void Initialize() {
68 store_.Clear();
64 // Initialize the trust store with the root certificate. 69 // Initialize the trust store with the root certificate.
65 // TODO(ryanchung): Add official Cast CRL Root here 70 scoped_refptr<net::ParsedCertificate> root =
66 // scoped_refptr<net::ParsedCertificate> root = net::ParsedCertificate:: 71 net::ParsedCertificate::CreateFromCertificateData(
67 // net::ParsedCertificate::CreateFromCertificateData( 72 kCastCRLRootCaDer, sizeof(kCastCRLRootCaDer),
68 // kCastCRLRootCaDer, sizeof(kCastCRLRootCaDer), 73 net::ParsedCertificate::DataSource::EXTERNAL_REFERENCE, {});
69 // net::ParsedCertificate::DataSource::EXTERNAL_REFERENCE, {}); 74 CHECK(root);
70 // CHECK(root); 75 store_.AddTrustedCertificate(std::move(root));
71 // store_.AddTrustedCertificate(std::move(root));
72 } 76 }
73 77
74 net::TrustStore store_; 78 net::TrustStore store_;
75 DISALLOW_COPY_AND_ASSIGN(CastCRLTrustStore); 79 DISALLOW_COPY_AND_ASSIGN(CastCRLTrustStore);
76 }; 80 };
77 81
78 // Converts a uint64_t unix timestamp to net::der::GeneralizedTime. 82 // Converts a uint64_t unix timestamp to net::der::GeneralizedTime.
79 bool ConvertTimeSeconds(uint64_t seconds, 83 bool ConvertTimeSeconds(uint64_t seconds,
80 net::der::GeneralizedTime* generalized_time) { 84 net::der::GeneralizedTime* generalized_time) {
81 base::Time unix_timestamp = 85 base::Time unix_timestamp =
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 bool SetCRLTrustAnchorForTest(const std::string& cert) { 334 bool SetCRLTrustAnchorForTest(const std::string& cert) {
331 scoped_refptr<net::ParsedCertificate> anchor( 335 scoped_refptr<net::ParsedCertificate> anchor(
332 net::ParsedCertificate::CreateFromCertificateCopy(cert, {})); 336 net::ParsedCertificate::CreateFromCertificateCopy(cert, {}));
333 if (!anchor) 337 if (!anchor)
334 return false; 338 return false;
335 CastCRLTrustStore::Get().Clear(); 339 CastCRLTrustStore::Get().Clear();
336 CastCRLTrustStore::Get().AddTrustedCertificate(std::move(anchor)); 340 CastCRLTrustStore::Get().AddTrustedCertificate(std::move(anchor));
337 return true; 341 return true;
338 } 342 }
339 343
344 void ResetCRLTrustAnchorForTest() {
345 CastCRLTrustStore::Reinitialize();
346 }
347
340 } // namespace cast_certificate 348 } // namespace cast_certificate
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698