| 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/mac_util.h" | 10 #include "base/mac/mac_util.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 } | 87 } |
| 88 | 88 |
| 89 // Otherwise, both system trust and temporary_roots_ must be trusted. | 89 // Otherwise, both system trust and temporary_roots_ must be trusted. |
| 90 // Emulate the functionality of SecTrustSetAnchorCertificatesOnly by | 90 // Emulate the functionality of SecTrustSetAnchorCertificatesOnly by |
| 91 // creating a copy of the system roots and merging with temporary_roots_. | 91 // creating a copy of the system roots and merging with temporary_roots_. |
| 92 CFArrayRef system_roots = NULL; | 92 CFArrayRef system_roots = NULL; |
| 93 OSStatus status = SecTrustCopyAnchorCertificates(&system_roots); | 93 OSStatus status = SecTrustCopyAnchorCertificates(&system_roots); |
| 94 if (status) | 94 if (status) |
| 95 return status; | 95 return status; |
| 96 | 96 |
| 97 base::mac::ScopedCFTypeRef<CFArrayRef> scoped_system_roots(system_roots); | 97 base::ScopedCFTypeRef<CFArrayRef> scoped_system_roots(system_roots); |
| 98 base::mac::ScopedCFTypeRef<CFMutableArrayRef> scoped_roots( | 98 base::ScopedCFTypeRef<CFMutableArrayRef> scoped_roots( |
| 99 CFArrayCreateMutableCopy(kCFAllocatorDefault, 0, scoped_system_roots)); | 99 CFArrayCreateMutableCopy(kCFAllocatorDefault, 0, scoped_system_roots)); |
| 100 CFArrayAppendArray(scoped_roots, temporary_roots_, | 100 CFArrayAppendArray(scoped_roots, temporary_roots_, |
| 101 CFRangeMake(0, CFArrayGetCount(temporary_roots_))); | 101 CFRangeMake(0, CFArrayGetCount(temporary_roots_))); |
| 102 return SecTrustSetAnchorCertificates(trust_ref, scoped_roots); | 102 return SecTrustSetAnchorCertificates(trust_ref, scoped_roots); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void TestRootCerts::SetAllowSystemTrust(bool allow_system_trust) { | 105 void TestRootCerts::SetAllowSystemTrust(bool allow_system_trust) { |
| 106 allow_system_trust_ = allow_system_trust; | 106 allow_system_trust_ = allow_system_trust; |
| 107 } | 107 } |
| 108 | 108 |
| 109 TestRootCerts::~TestRootCerts() {} | 109 TestRootCerts::~TestRootCerts() {} |
| 110 | 110 |
| 111 void TestRootCerts::Init() { | 111 void TestRootCerts::Init() { |
| 112 temporary_roots_.reset(CFArrayCreateMutable(kCFAllocatorDefault, 0, | 112 temporary_roots_.reset(CFArrayCreateMutable(kCFAllocatorDefault, 0, |
| 113 &kCertArrayCallbacks)); | 113 &kCertArrayCallbacks)); |
| 114 allow_system_trust_ = true; | 114 allow_system_trust_ = true; |
| 115 } | 115 } |
| 116 | 116 |
| 117 } // namespace net | 117 } // namespace net |
| OLD | NEW |