OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/cert/test_root_certs.h" | 5 #include "net/cert/test_root_certs.h" |
6 | 6 |
7 #include <Security/Security.h> | 7 #include <Security/Security.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/mac/scoped_cftyperef.h" | 10 #include "base/mac/scoped_cftyperef.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 return CFArrayGetCount(temporary_roots_) == 0; | 64 return CFArrayGetCount(temporary_roots_) == 0; |
65 } | 65 } |
66 | 66 |
67 OSStatus TestRootCerts::FixupSecTrustRef(SecTrustRef trust_ref) const { | 67 OSStatus TestRootCerts::FixupSecTrustRef(SecTrustRef trust_ref) const { |
68 if (IsEmpty()) | 68 if (IsEmpty()) |
69 return noErr; | 69 return noErr; |
70 | 70 |
71 OSStatus status = SecTrustSetAnchorCertificates(trust_ref, temporary_roots_); | 71 OSStatus status = SecTrustSetAnchorCertificates(trust_ref, temporary_roots_); |
72 if (status) | 72 if (status) |
73 return status; | 73 return status; |
74 return SecTrustSetAnchorCertificatesOnly(trust_ref, false); | 74 return SecTrustSetAnchorCertificatesOnly(trust_ref, !allow_system_trust_); |
75 } | |
76 | |
77 void TestRootCerts::SetAllowSystemTrust(bool allow_system_trust) { | |
78 allow_system_trust_ = allow_system_trust; | |
75 } | 79 } |
76 | 80 |
77 TestRootCerts::~TestRootCerts() {} | 81 TestRootCerts::~TestRootCerts() {} |
78 | 82 |
79 void TestRootCerts::Init() { | 83 void TestRootCerts::Init() { |
80 temporary_roots_.reset(CFArrayCreateMutable(kCFAllocatorDefault, 0, | 84 temporary_roots_.reset(CFArrayCreateMutable(kCFAllocatorDefault, 0, |
81 &kCertArrayCallbacks)); | 85 &kCertArrayCallbacks)); |
86 allow_system_trust_ = true; | |
wtc
2013/04/29 19:14:57
Is it convenient to initialize allow_system_trust_
Ryan Sleevi
2013/04/29 21:28:23
No. We use |Init()| to handle the per-OS initializ
wtc
2013/04/29 22:53:42
I see. I didn't know that (I didn't check test_roo
| |
82 } | 87 } |
83 | 88 |
84 } // namespace net | 89 } // namespace net |
OLD | NEW |