| 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 "net/cert/x509_certificate.h" | 10 #include "net/cert/x509_certificate.h" |
| 11 | 11 |
| 12 #if defined(OS_IOS) |
| 13 #include "net/cert/x509_util_ios.h" |
| 14 #else |
| 15 #include "net/cert/x509_util_mac.h" |
| 16 #endif |
| 17 |
| 12 namespace net { | 18 namespace net { |
| 13 | 19 |
| 14 bool TestRootCerts::Add(X509Certificate* certificate) { | 20 bool TestRootCerts::Add(X509Certificate* certificate) { |
| 21 base::ScopedCFTypeRef<SecCertificateRef> os_cert( |
| 22 x509_util::CreateSecCertificateFromX509Certificate(certificate)); |
| 23 if (!os_cert) |
| 24 return false; |
| 25 |
| 15 if (CFArrayContainsValue(temporary_roots_, | 26 if (CFArrayContainsValue(temporary_roots_, |
| 16 CFRangeMake(0, CFArrayGetCount(temporary_roots_)), | 27 CFRangeMake(0, CFArrayGetCount(temporary_roots_)), |
| 17 certificate->os_cert_handle())) | 28 os_cert.get())) |
| 18 return true; | 29 return true; |
| 19 CFArrayAppendValue(temporary_roots_, certificate->os_cert_handle()); | 30 CFArrayAppendValue(temporary_roots_, os_cert.get()); |
| 20 return true; | 31 return true; |
| 21 } | 32 } |
| 22 | 33 |
| 23 void TestRootCerts::Clear() { | 34 void TestRootCerts::Clear() { |
| 24 CFArrayRemoveAllValues(temporary_roots_); | 35 CFArrayRemoveAllValues(temporary_roots_); |
| 25 } | 36 } |
| 26 | 37 |
| 27 bool TestRootCerts::IsEmpty() const { | 38 bool TestRootCerts::IsEmpty() const { |
| 28 return CFArrayGetCount(temporary_roots_) == 0; | 39 return CFArrayGetCount(temporary_roots_) == 0; |
| 29 } | 40 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 44 | 55 |
| 45 TestRootCerts::~TestRootCerts() {} | 56 TestRootCerts::~TestRootCerts() {} |
| 46 | 57 |
| 47 void TestRootCerts::Init() { | 58 void TestRootCerts::Init() { |
| 48 temporary_roots_.reset( | 59 temporary_roots_.reset( |
| 49 CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks)); | 60 CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks)); |
| 50 allow_system_trust_ = true; | 61 allow_system_trust_ = true; |
| 51 } | 62 } |
| 52 | 63 |
| 53 } // namespace net | 64 } // namespace net |
| OLD | NEW |