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

Side by Side Diff: components/cast_certificate/cast_cert_validator.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 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 "components/cast_certificate/cast_cert_validator.h" 5 #include "components/cast_certificate/cast_cert_validator.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // Singleton for the Cast trust store. 48 // Singleton for the Cast trust store.
49 class CastTrustStore { 49 class CastTrustStore {
50 public: 50 public:
51 static CastTrustStore* GetInstance() { 51 static CastTrustStore* GetInstance() {
52 return base::Singleton<CastTrustStore, 52 return base::Singleton<CastTrustStore,
53 base::LeakySingletonTraits<CastTrustStore>>::get(); 53 base::LeakySingletonTraits<CastTrustStore>>::get();
54 } 54 }
55 55
56 static net::TrustStore& Get() { return GetInstance()->store_; } 56 static net::TrustStore& Get() { return GetInstance()->store_; }
57 57
58 static void Reinitialize() { GetInstance()->Initialize(); }
eroman 2016/08/03 22:47:58 How about ReinitializeForTest() ? Or make a comme
ryanchung 2016/08/04 18:46:43 Removed this code. It's no longer needed due to th
59
58 private: 60 private:
59 friend struct base::DefaultSingletonTraits<CastTrustStore>; 61 friend struct base::DefaultSingletonTraits<CastTrustStore>;
60 62
61 CastTrustStore() { 63 CastTrustStore() { Initialize(); }
64
65 void Initialize() {
66 store_.Clear();
62 AddAnchor(kCastRootCaDer); 67 AddAnchor(kCastRootCaDer);
63 AddAnchor(kEurekaRootCaDer); 68 AddAnchor(kEurekaRootCaDer);
64 } 69 }
65 70
66 // Adds a trust anchor given a DER-encoded certificate from static 71 // Adds a trust anchor given a DER-encoded certificate from static
67 // storage. 72 // storage.
68 template <size_t N> 73 template <size_t N>
69 void AddAnchor(const uint8_t (&data)[N]) { 74 void AddAnchor(const uint8_t (&data)[N]) {
70 scoped_refptr<net::ParsedCertificate> root = 75 scoped_refptr<net::ParsedCertificate> root =
71 net::ParsedCertificate::CreateFromCertificateData( 76 net::ParsedCertificate::CreateFromCertificateData(
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 scoped_refptr<net::ParsedCertificate> anchor( 339 scoped_refptr<net::ParsedCertificate> anchor(
335 net::ParsedCertificate::CreateFromCertificateCopy( 340 net::ParsedCertificate::CreateFromCertificateCopy(
336 cert, GetCertParsingOptions())); 341 cert, GetCertParsingOptions()));
337 if (!anchor) 342 if (!anchor)
338 return false; 343 return false;
339 CastTrustStore::Get().Clear(); 344 CastTrustStore::Get().Clear();
340 CastTrustStore::Get().AddTrustedCertificate(std::move(anchor)); 345 CastTrustStore::Get().AddTrustedCertificate(std::move(anchor));
341 return true; 346 return true;
342 } 347 }
343 348
349 void ResetTrustAnchorForTest() {
350 CastTrustStore::Reinitialize();
351 }
352
344 } // namespace cast_certificate 353 } // namespace cast_certificate
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698