| 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/cert_verify_proc.h" | 5 #include "net/cert/cert_verify_proc.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "net/cert/test_root_certs.h" | 25 #include "net/cert/test_root_certs.h" |
| 26 #include "net/cert/x509_certificate.h" | 26 #include "net/cert/x509_certificate.h" |
| 27 #include "net/test/cert_test_util.h" | 27 #include "net/test/cert_test_util.h" |
| 28 #include "net/test/test_certificate_data.h" | 28 #include "net/test/test_certificate_data.h" |
| 29 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
| 30 | 30 |
| 31 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
| 32 #include "base/win/windows_version.h" | 32 #include "base/win/windows_version.h" |
| 33 #elif defined(OS_ANDROID) | 33 #elif defined(OS_ANDROID) |
| 34 #include "base/android/build_info.h" | 34 #include "base/android/build_info.h" |
| 35 #elif defined(OS_IOS) |
| 36 #include "base/ios/ios_util.h" |
| 35 #endif | 37 #endif |
| 36 | 38 |
| 37 using base::HexEncode; | 39 using base::HexEncode; |
| 38 | 40 |
| 39 namespace net { | 41 namespace net { |
| 40 | 42 |
| 41 namespace { | 43 namespace { |
| 42 | 44 |
| 43 // A certificate for www.paypal.com with a NULL byte in the common name. | 45 // A certificate for www.paypal.com with a NULL byte in the common name. |
| 44 // From http://www.gossamer-threads.com/lists/fulldisc/full-disclosure/70363 | 46 // From http://www.gossamer-threads.com/lists/fulldisc/full-disclosure/70363 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 CertVerifyResult verify_result; | 222 CertVerifyResult verify_result; |
| 221 int error = Verify(paypal_null_cert.get(), | 223 int error = Verify(paypal_null_cert.get(), |
| 222 "www.paypal.com", | 224 "www.paypal.com", |
| 223 flags, | 225 flags, |
| 224 NULL, | 226 NULL, |
| 225 empty_cert_list_, | 227 empty_cert_list_, |
| 226 &verify_result); | 228 &verify_result); |
| 227 #if defined(USE_NSS_VERIFIER) || defined(OS_ANDROID) | 229 #if defined(USE_NSS_VERIFIER) || defined(OS_ANDROID) |
| 228 EXPECT_EQ(ERR_CERT_COMMON_NAME_INVALID, error); | 230 EXPECT_EQ(ERR_CERT_COMMON_NAME_INVALID, error); |
| 229 #elif defined(OS_IOS) && TARGET_IPHONE_SIMULATOR | 231 #elif defined(OS_IOS) && TARGET_IPHONE_SIMULATOR |
| 230 // iOS returns a ERR_CERT_INVALID error on the simulator, while returning | 232 // iOS returns a ERR_CERT_INVALID error on the simulator until iOS SDK 9.3, |
| 231 // ERR_CERT_AUTHORITY_INVALID on the real device. | 233 // while returning ERR_CERT_AUTHORITY_INVALID on the real device. |
| 232 EXPECT_EQ(ERR_CERT_INVALID, error); | 234 if (base::ios::IsRunningOnOrLater(9, 3, 0)) |
| 235 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, error); |
| 236 else |
| 237 EXPECT_EQ(ERR_CERT_INVALID, error); |
| 233 #else | 238 #else |
| 234 // TOOD(bulach): investigate why macosx and win aren't returning | 239 // TOOD(bulach): investigate why macosx and win aren't returning |
| 235 // ERR_CERT_INVALID or ERR_CERT_COMMON_NAME_INVALID. | 240 // ERR_CERT_INVALID or ERR_CERT_COMMON_NAME_INVALID. |
| 236 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, error); | 241 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, error); |
| 237 #endif | 242 #endif |
| 238 // Either the system crypto library should correctly report a certificate | 243 // Either the system crypto library should correctly report a certificate |
| 239 // name mismatch, or our certificate blacklist should cause us to report an | 244 // name mismatch, or our certificate blacklist should cause us to report an |
| 240 // invalid certificate. | 245 // invalid certificate. |
| 241 #if defined(USE_NSS_VERIFIER) || defined(OS_WIN) | 246 #if defined(USE_NSS_VERIFIER) || defined(OS_WIN) |
| 242 EXPECT_TRUE(verify_result.cert_status & | 247 EXPECT_TRUE(verify_result.cert_status & |
| (...skipping 1459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1702 int flags = 0; | 1707 int flags = 0; |
| 1703 CertVerifyResult verify_result; | 1708 CertVerifyResult verify_result; |
| 1704 int error = Verify(cert.get(), "127.0.0.1", flags, NULL, empty_cert_list_, | 1709 int error = Verify(cert.get(), "127.0.0.1", flags, NULL, empty_cert_list_, |
| 1705 &verify_result); | 1710 &verify_result); |
| 1706 EXPECT_EQ(ERR_CERT_INVALID, error); | 1711 EXPECT_EQ(ERR_CERT_INVALID, error); |
| 1707 EXPECT_EQ(CERT_STATUS_INVALID, verify_result.cert_status); | 1712 EXPECT_EQ(CERT_STATUS_INVALID, verify_result.cert_status); |
| 1708 } | 1713 } |
| 1709 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | 1714 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
| 1710 | 1715 |
| 1711 } // namespace net | 1716 } // namespace net |
| OLD | NEW |