| 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 return verify_proc_type() == CERT_VERIFY_PROC_NSS || | 246 return verify_proc_type() == CERT_VERIFY_PROC_NSS || |
| 247 verify_proc_type() == CERT_VERIFY_PROC_WIN || | 247 verify_proc_type() == CERT_VERIFY_PROC_WIN || |
| 248 verify_proc_type() == CERT_VERIFY_PROC_MAC; | 248 verify_proc_type() == CERT_VERIFY_PROC_MAC; |
| 249 } | 249 } |
| 250 | 250 |
| 251 bool SupportsCRLSetsInPathBuilding() const { | 251 bool SupportsCRLSetsInPathBuilding() const { |
| 252 return verify_proc_type() == CERT_VERIFY_PROC_WIN || | 252 return verify_proc_type() == CERT_VERIFY_PROC_WIN || |
| 253 verify_proc_type() == CERT_VERIFY_PROC_NSS; | 253 verify_proc_type() == CERT_VERIFY_PROC_NSS; |
| 254 } | 254 } |
| 255 | 255 |
| 256 bool SupportsEV() const { |
| 257 // TODO(crbug.com/649017): CertVerifyProcBuiltin does not support EV. |
| 258 // TODO(crbug.com/117478): Android and iOS do not support EV. |
| 259 return verify_proc_type() == CERT_VERIFY_PROC_NSS || |
| 260 verify_proc_type() == CERT_VERIFY_PROC_WIN || |
| 261 verify_proc_type() == CERT_VERIFY_PROC_MAC; |
| 262 } |
| 263 |
| 256 CertVerifyProc* verify_proc() const { return verify_proc_.get(); } | 264 CertVerifyProc* verify_proc() const { return verify_proc_.get(); } |
| 257 | 265 |
| 258 private: | 266 private: |
| 259 scoped_refptr<CertVerifyProc> verify_proc_; | 267 scoped_refptr<CertVerifyProc> verify_proc_; |
| 260 }; | 268 }; |
| 261 | 269 |
| 262 INSTANTIATE_TEST_CASE_P(, | 270 INSTANTIATE_TEST_CASE_P(, |
| 263 CertVerifyProcInternalTest, | 271 CertVerifyProcInternalTest, |
| 264 testing::ValuesIn(kAllCertVerifiers), | 272 testing::ValuesIn(kAllCertVerifiers), |
| 265 VerifyProcTypeToName); | 273 VerifyProcTypeToName); |
| 266 | 274 |
| 267 // TODO(rsleevi): Reenable this test once comodo.chaim.pem is no longer | 275 // TODO(rsleevi): Reenable this test once comodo.chaim.pem is no longer |
| 268 // expired, http://crbug.com/502818 | 276 // expired, http://crbug.com/502818 |
| 269 TEST_P(CertVerifyProcInternalTest, DISABLED_EVVerification) { | 277 TEST_P(CertVerifyProcInternalTest, DISABLED_EVVerification) { |
| 270 if (verify_proc_type() == CERT_VERIFY_PROC_ANDROID || | 278 if (!SupportsEV()) { |
| 271 verify_proc_type() == CERT_VERIFY_PROC_OPENSSL) { | |
| 272 // TODO(jnd): http://crbug.com/117478 - EV verification is not yet | |
| 273 // supported. | |
| 274 LOG(INFO) << "Skipping test as EV verification is not yet supported"; | 279 LOG(INFO) << "Skipping test as EV verification is not yet supported"; |
| 275 return; | 280 return; |
| 276 } | 281 } |
| 277 | 282 |
| 278 CertificateList certs = | 283 CertificateList certs = |
| 279 CreateCertificateListFromFile(GetTestCertsDirectory(), "comodo.chain.pem", | 284 CreateCertificateListFromFile(GetTestCertsDirectory(), "comodo.chain.pem", |
| 280 X509Certificate::FORMAT_PEM_CERT_SEQUENCE); | 285 X509Certificate::FORMAT_PEM_CERT_SEQUENCE); |
| 281 ASSERT_EQ(3U, certs.size()); | 286 ASSERT_EQ(3U, certs.size()); |
| 282 | 287 |
| 283 X509Certificate::OSCertHandles intermediates; | 288 X509Certificate::OSCertHandles intermediates; |
| 284 intermediates.push_back(certs[1]->os_cert_handle()); | 289 intermediates.push_back(certs[1]->os_cert_handle()); |
| 285 intermediates.push_back(certs[2]->os_cert_handle()); | 290 intermediates.push_back(certs[2]->os_cert_handle()); |
| 286 | 291 |
| 287 scoped_refptr<X509Certificate> comodo_chain = | 292 scoped_refptr<X509Certificate> comodo_chain = |
| 288 X509Certificate::CreateFromHandle(certs[0]->os_cert_handle(), | 293 X509Certificate::CreateFromHandle(certs[0]->os_cert_handle(), |
| 289 intermediates); | 294 intermediates); |
| 290 | 295 |
| 291 scoped_refptr<CRLSet> crl_set(CRLSet::ForTesting(false, NULL, "")); | 296 scoped_refptr<CRLSet> crl_set(CRLSet::ForTesting(false, NULL, "")); |
| 292 CertVerifyResult verify_result; | 297 CertVerifyResult verify_result; |
| 293 int flags = CertVerifier::VERIFY_EV_CERT; | 298 int flags = CertVerifier::VERIFY_EV_CERT; |
| 294 int error = Verify(comodo_chain.get(), "comodo.com", flags, crl_set.get(), | 299 int error = Verify(comodo_chain.get(), "comodo.com", flags, crl_set.get(), |
| 295 CertificateList(), &verify_result); | 300 CertificateList(), &verify_result); |
| 296 EXPECT_THAT(error, IsOk()); | 301 EXPECT_THAT(error, IsOk()); |
| 297 EXPECT_TRUE(verify_result.cert_status & CERT_STATUS_IS_EV); | 302 EXPECT_TRUE(verify_result.cert_status & CERT_STATUS_IS_EV); |
| 298 } | 303 } |
| 299 | 304 |
| 305 // Tests that a certificate is recognized as EV, when the valid EV policy OID |
| 306 // for the trust anchor is the second candidate EV oid in the target |
| 307 // certificate. This is a regression test for crbug.com/705285. |
| 308 TEST_P(CertVerifyProcInternalTest, EVVerificationMultipleOID) { |
| 309 if (!SupportsEV()) { |
| 310 LOG(INFO) << "Skipping test as EV verification is not yet supported"; |
| 311 return; |
| 312 } |
| 313 |
| 314 // TODO(eroman): Update this test to use a synthetic certificate, so the test |
| 315 // does not break in the future. The certificate chain in question expires on |
| 316 // Dec 22 23:59:59 2018 GMT 2018, at which point this test will start failing. |
| 317 if (base::Time::Now() > |
| 318 base::Time::UnixEpoch() + base::TimeDelta::FromSeconds(1545523199)) { |
| 319 FAIL() << "This test uses a certificate chain which is now expired. Please " |
| 320 "disable and file a bug."; |
| 321 return; |
| 322 } |
| 323 |
| 324 scoped_refptr<X509Certificate> chain = CreateCertificateChainFromFile( |
| 325 GetTestCertsDirectory(), "trustcenter.websecurity.symantec.com.pem", |
| 326 X509Certificate::FORMAT_PEM_CERT_SEQUENCE); |
| 327 ASSERT_TRUE(chain); |
| 328 |
| 329 scoped_refptr<CRLSet> crl_set(CRLSet::ForTesting(false, NULL, "")); |
| 330 CertVerifyResult verify_result; |
| 331 int flags = CertVerifier::VERIFY_EV_CERT; |
| 332 int error = Verify(chain.get(), "trustcenter.websecurity.symantec.com", flags, |
| 333 crl_set.get(), CertificateList(), &verify_result); |
| 334 EXPECT_THAT(error, IsOk()); |
| 335 EXPECT_TRUE(verify_result.cert_status & CERT_STATUS_IS_EV); |
| 336 } |
| 337 |
| 300 // TODO(crbug.com/605457): the test expectation was incorrect on some | 338 // TODO(crbug.com/605457): the test expectation was incorrect on some |
| 301 // configurations, so disable the test until it is fixed (better to have | 339 // configurations, so disable the test until it is fixed (better to have |
| 302 // a bug to track a failing test than a false sense of security due to | 340 // a bug to track a failing test than a false sense of security due to |
| 303 // false positive). | 341 // false positive). |
| 304 TEST_P(CertVerifyProcInternalTest, DISABLED_PaypalNullCertParsing) { | 342 TEST_P(CertVerifyProcInternalTest, DISABLED_PaypalNullCertParsing) { |
| 305 // A certificate for www.paypal.com with a NULL byte in the common name. | 343 // A certificate for www.paypal.com with a NULL byte in the common name. |
| 306 // From http://www.gossamer-threads.com/lists/fulldisc/full-disclosure/70363 | 344 // From http://www.gossamer-threads.com/lists/fulldisc/full-disclosure/70363 |
| 307 SHA256HashValue paypal_null_fingerprint = {{0x00}}; | 345 SHA256HashValue paypal_null_fingerprint = {{0x00}}; |
| 308 | 346 |
| 309 scoped_refptr<X509Certificate> paypal_null_cert( | 347 scoped_refptr<X509Certificate> paypal_null_cert( |
| (...skipping 2013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2323 int flags = 0; | 2361 int flags = 0; |
| 2324 CertVerifyResult verify_result; | 2362 CertVerifyResult verify_result; |
| 2325 int error = verify_proc->Verify(cert.get(), "127.0.0.1", std::string(), flags, | 2363 int error = verify_proc->Verify(cert.get(), "127.0.0.1", std::string(), flags, |
| 2326 NULL, CertificateList(), &verify_result); | 2364 NULL, CertificateList(), &verify_result); |
| 2327 EXPECT_EQ(OK, error); | 2365 EXPECT_EQ(OK, error); |
| 2328 histograms.ExpectTotalCount(kTLSFeatureExtensionHistogram, 0); | 2366 histograms.ExpectTotalCount(kTLSFeatureExtensionHistogram, 0); |
| 2329 histograms.ExpectTotalCount(kTLSFeatureExtensionOCSPHistogram, 0); | 2367 histograms.ExpectTotalCount(kTLSFeatureExtensionOCSPHistogram, 0); |
| 2330 } | 2368 } |
| 2331 | 2369 |
| 2332 } // namespace net | 2370 } // namespace net |
| OLD | NEW |