| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/internal/trust_store_mac.h" | 5 #include "net/cert/internal/trust_store_mac.h" |
| 6 | 6 |
| 7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/process/launch.h" | 11 #include "base/process/launch.h" |
| 12 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
| 13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
| 14 #include "crypto/mac_security_services_lock.h" | 14 #include "crypto/mac_security_services_lock.h" |
| 15 #include "net/cert/internal/cert_errors.h" | 15 #include "net/cert/internal/cert_errors.h" |
| 16 #include "net/cert/internal/test_helpers.h" | 16 #include "net/cert/internal/test_helpers.h" |
| 17 #include "net/cert/pem_tokenizer.h" | 17 #include "net/cert/pem_tokenizer.h" |
| 18 #include "net/cert/test_keychain_search_list_mac.h" | 18 #include "net/cert/test_keychain_search_list_mac.h" |
| 19 #include "net/cert/x509_certificate.h" | 19 #include "net/cert/x509_certificate.h" |
| 20 #include "net/cert/x509_util.h" | 20 #include "net/cert/x509_util.h" |
| 21 #include "net/cert/x509_util_mac.h" |
| 21 #include "net/test/test_data_directory.h" | 22 #include "net/test/test_data_directory.h" |
| 22 #include "testing/gmock/include/gmock/gmock.h" | 23 #include "testing/gmock/include/gmock/gmock.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 24 | 25 |
| 25 using ::testing::UnorderedElementsAreArray; | 26 using ::testing::UnorderedElementsAreArray; |
| 26 | 27 |
| 27 namespace net { | 28 namespace net { |
| 28 | 29 |
| 29 namespace { | 30 namespace { |
| 30 | 31 |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 options.allow_invalid_serial_numbers = true; | 257 options.allow_invalid_serial_numbers = true; |
| 257 scoped_refptr<ParsedCertificate> cert = ParsedCertificate::Create( | 258 scoped_refptr<ParsedCertificate> cert = ParsedCertificate::Create( |
| 258 x509_util::CreateCryptoBuffer(cert_der), options, &errors); | 259 x509_util::CreateCryptoBuffer(cert_der), options, &errors); |
| 259 if (!cert) { | 260 if (!cert) { |
| 260 LOG(WARNING) << "ParseCertificate::Create " << hash_text << " failed:\n" | 261 LOG(WARNING) << "ParseCertificate::Create " << hash_text << " failed:\n" |
| 261 << errors.ToDebugString(); | 262 << errors.ToDebugString(); |
| 262 continue; | 263 continue; |
| 263 } | 264 } |
| 264 | 265 |
| 265 base::ScopedCFTypeRef<SecCertificateRef> cert_handle( | 266 base::ScopedCFTypeRef<SecCertificateRef> cert_handle( |
| 266 X509Certificate::CreateOSCertHandleFromBytes( | 267 x509_util::CreateSecCertificateFromBytes(cert->der_cert().UnsafeData(), |
| 267 cert->der_cert().AsStringPiece().data(), | 268 cert->der_cert().Length())); |
| 268 cert->der_cert().Length())); | |
| 269 if (!cert_handle) { | 269 if (!cert_handle) { |
| 270 ADD_FAILURE() << "CreateOSCertHandleFromBytes " << hash_text; | 270 ADD_FAILURE() << "CreateOSCertHandleFromBytes " << hash_text; |
| 271 continue; | 271 continue; |
| 272 } | 272 } |
| 273 base::ScopedCFTypeRef<CFDataRef> mac_normalized_subject; | 273 base::ScopedCFTypeRef<CFDataRef> mac_normalized_subject; |
| 274 { | 274 { |
| 275 base::AutoLock lock(crypto::GetMacSecurityServicesLock()); | 275 base::AutoLock lock(crypto::GetMacSecurityServicesLock()); |
| 276 mac_normalized_subject.reset( | 276 mac_normalized_subject.reset( |
| 277 SecCertificateCopyNormalizedSubjectContent(cert_handle, nullptr)); | 277 SecCertificateCopyNormalizedSubjectContent(cert_handle, nullptr)); |
| 278 } | 278 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 bool expected_trust_anchor = | 310 bool expected_trust_anchor = |
| 311 ((trust_result == kSecTrustResultProceed) || | 311 ((trust_result == kSecTrustResultProceed) || |
| 312 (trust_result == kSecTrustResultUnspecified)) && | 312 (trust_result == kSecTrustResultUnspecified)) && |
| 313 (SecTrustGetCertificateCount(trust) == 1); | 313 (SecTrustGetCertificateCount(trust) == 1); |
| 314 EXPECT_EQ(expected_trust_anchor, is_trust_anchor); | 314 EXPECT_EQ(expected_trust_anchor, is_trust_anchor); |
| 315 } | 315 } |
| 316 } | 316 } |
| 317 } | 317 } |
| 318 | 318 |
| 319 } // namespace net | 319 } // namespace net |
| OLD | NEW |