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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 verify_proc_type() == CERT_VERIFY_PROC_WIN || | 266 verify_proc_type() == CERT_VERIFY_PROC_WIN || |
267 verify_proc_type() == CERT_VERIFY_PROC_MAC; | 267 verify_proc_type() == CERT_VERIFY_PROC_MAC; |
268 } | 268 } |
269 | 269 |
270 bool SupportsCRLSetsInPathBuilding() const { | 270 bool SupportsCRLSetsInPathBuilding() const { |
271 // TODO(crbug.com/649017): Return true for CERT_VERIFY_PROC_BUILTIN. | 271 // TODO(crbug.com/649017): Return true for CERT_VERIFY_PROC_BUILTIN. |
272 return verify_proc_type() == CERT_VERIFY_PROC_WIN || | 272 return verify_proc_type() == CERT_VERIFY_PROC_WIN || |
273 verify_proc_type() == CERT_VERIFY_PROC_NSS; | 273 verify_proc_type() == CERT_VERIFY_PROC_NSS; |
274 } | 274 } |
275 | 275 |
| 276 bool SupportsEV() const { |
| 277 // TODO(crbug.com/649017): CertVerifyProcBuiltin does not support EV. |
| 278 // TODO(crbug.com/117478): Android and iOS do not support EV. |
| 279 return verify_proc_type() == CERT_VERIFY_PROC_NSS || |
| 280 verify_proc_type() == CERT_VERIFY_PROC_WIN || |
| 281 verify_proc_type() == CERT_VERIFY_PROC_MAC; |
| 282 } |
| 283 |
276 CertVerifyProc* verify_proc() const { return verify_proc_.get(); } | 284 CertVerifyProc* verify_proc() const { return verify_proc_.get(); } |
277 | 285 |
278 private: | 286 private: |
279 scoped_refptr<CertVerifyProc> verify_proc_; | 287 scoped_refptr<CertVerifyProc> verify_proc_; |
280 }; | 288 }; |
281 | 289 |
282 INSTANTIATE_TEST_CASE_P(, | 290 INSTANTIATE_TEST_CASE_P(, |
283 CertVerifyProcInternalTest, | 291 CertVerifyProcInternalTest, |
284 testing::ValuesIn(kAllCertVerifiers), | 292 testing::ValuesIn(kAllCertVerifiers), |
285 VerifyProcTypeToName); | 293 VerifyProcTypeToName); |
286 | 294 |
287 // TODO(rsleevi): Reenable this test once comodo.chaim.pem is no longer | 295 // TODO(rsleevi): Reenable this test once comodo.chaim.pem is no longer |
288 // expired, http://crbug.com/502818 | 296 // expired, http://crbug.com/502818 |
289 TEST_P(CertVerifyProcInternalTest, DISABLED_EVVerification) { | 297 TEST_P(CertVerifyProcInternalTest, DISABLED_EVVerification) { |
290 if (verify_proc_type() == CERT_VERIFY_PROC_ANDROID || | 298 if (!SupportsEV()) { |
291 verify_proc_type() == CERT_VERIFY_PROC_OPENSSL) { | |
292 // TODO(jnd): http://crbug.com/117478 - EV verification is not yet | |
293 // supported. | |
294 LOG(INFO) << "Skipping test as EV verification is not yet supported"; | 299 LOG(INFO) << "Skipping test as EV verification is not yet supported"; |
295 return; | 300 return; |
296 } | 301 } |
297 | 302 |
298 scoped_refptr<X509Certificate> comodo_chain = CreateCertificateChainFromFile( | 303 scoped_refptr<X509Certificate> comodo_chain = CreateCertificateChainFromFile( |
299 GetTestCertsDirectory(), "comodo.chain.pem", | 304 GetTestCertsDirectory(), "comodo.chain.pem", |
300 X509Certificate::FORMAT_PEM_CERT_SEQUENCE); | 305 X509Certificate::FORMAT_PEM_CERT_SEQUENCE); |
301 ASSERT_TRUE(comodo_chain); | 306 ASSERT_TRUE(comodo_chain); |
302 ASSERT_EQ(2U, comodo_chain->GetIntermediateCertificates().size()); | 307 ASSERT_EQ(2U, comodo_chain->GetIntermediateCertificates().size()); |
303 | 308 |
304 scoped_refptr<CRLSet> crl_set(CRLSet::ForTesting(false, NULL, "")); | 309 scoped_refptr<CRLSet> crl_set(CRLSet::ForTesting(false, NULL, "")); |
305 CertVerifyResult verify_result; | 310 CertVerifyResult verify_result; |
306 int flags = CertVerifier::VERIFY_EV_CERT; | 311 int flags = CertVerifier::VERIFY_EV_CERT; |
307 int error = Verify(comodo_chain.get(), "comodo.com", flags, crl_set.get(), | 312 int error = Verify(comodo_chain.get(), "comodo.com", flags, crl_set.get(), |
308 CertificateList(), &verify_result); | 313 CertificateList(), &verify_result); |
309 EXPECT_THAT(error, IsOk()); | 314 EXPECT_THAT(error, IsOk()); |
310 EXPECT_TRUE(verify_result.cert_status & CERT_STATUS_IS_EV); | 315 EXPECT_TRUE(verify_result.cert_status & CERT_STATUS_IS_EV); |
311 } | 316 } |
312 | 317 |
| 318 // Tests that a certificate is recognized as EV, when the valid EV policy OID |
| 319 // for the trust anchor is the second candidate EV oid in the target |
| 320 // certificate. This is a regression test for crbug.com/705285. |
| 321 TEST_P(CertVerifyProcInternalTest, EVVerificationMultipleOID) { |
| 322 if (!SupportsEV()) { |
| 323 LOG(INFO) << "Skipping test as EV verification is not yet supported"; |
| 324 return; |
| 325 } |
| 326 |
| 327 // TODO(eroman): Update this test to use a synthetic certificate, so the test |
| 328 // does not break in the future. The certificate chain in question expires on |
| 329 // Dec 22 23:59:59 2018 GMT 2018, at which point this test will start failing. |
| 330 if (base::Time::Now() > |
| 331 base::Time::UnixEpoch() + base::TimeDelta::FromSeconds(1545523199)) { |
| 332 FAIL() << "This test uses a certificate chain which is now expired. Please " |
| 333 "disable and file a bug."; |
| 334 return; |
| 335 } |
| 336 |
| 337 scoped_refptr<X509Certificate> chain = CreateCertificateChainFromFile( |
| 338 GetTestCertsDirectory(), "trustcenter.websecurity.symantec.com.pem", |
| 339 X509Certificate::FORMAT_PEM_CERT_SEQUENCE); |
| 340 ASSERT_TRUE(chain); |
| 341 |
| 342 scoped_refptr<CRLSet> crl_set(CRLSet::ForTesting(false, NULL, "")); |
| 343 CertVerifyResult verify_result; |
| 344 int flags = CertVerifier::VERIFY_EV_CERT; |
| 345 int error = Verify(chain.get(), "trustcenter.websecurity.symantec.com", flags, |
| 346 crl_set.get(), CertificateList(), &verify_result); |
| 347 EXPECT_THAT(error, IsOk()); |
| 348 EXPECT_TRUE(verify_result.cert_status & CERT_STATUS_IS_EV); |
| 349 } |
| 350 |
313 // TODO(crbug.com/605457): the test expectation was incorrect on some | 351 // TODO(crbug.com/605457): the test expectation was incorrect on some |
314 // configurations, so disable the test until it is fixed (better to have | 352 // configurations, so disable the test until it is fixed (better to have |
315 // a bug to track a failing test than a false sense of security due to | 353 // a bug to track a failing test than a false sense of security due to |
316 // false positive). | 354 // false positive). |
317 TEST_P(CertVerifyProcInternalTest, DISABLED_PaypalNullCertParsing) { | 355 TEST_P(CertVerifyProcInternalTest, DISABLED_PaypalNullCertParsing) { |
318 // A certificate for www.paypal.com with a NULL byte in the common name. | 356 // A certificate for www.paypal.com with a NULL byte in the common name. |
319 // From http://www.gossamer-threads.com/lists/fulldisc/full-disclosure/70363 | 357 // From http://www.gossamer-threads.com/lists/fulldisc/full-disclosure/70363 |
320 SHA256HashValue paypal_null_fingerprint = {{0x00}}; | 358 SHA256HashValue paypal_null_fingerprint = {{0x00}}; |
321 | 359 |
322 scoped_refptr<X509Certificate> paypal_null_cert( | 360 scoped_refptr<X509Certificate> paypal_null_cert( |
(...skipping 2024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2347 int flags = 0; | 2385 int flags = 0; |
2348 CertVerifyResult verify_result; | 2386 CertVerifyResult verify_result; |
2349 int error = verify_proc->Verify(cert.get(), "127.0.0.1", std::string(), flags, | 2387 int error = verify_proc->Verify(cert.get(), "127.0.0.1", std::string(), flags, |
2350 NULL, CertificateList(), &verify_result); | 2388 NULL, CertificateList(), &verify_result); |
2351 EXPECT_EQ(OK, error); | 2389 EXPECT_EQ(OK, error); |
2352 histograms.ExpectTotalCount(kTLSFeatureExtensionHistogram, 0); | 2390 histograms.ExpectTotalCount(kTLSFeatureExtensionHistogram, 0); |
2353 histograms.ExpectTotalCount(kTLSFeatureExtensionOCSPHistogram, 0); | 2391 histograms.ExpectTotalCount(kTLSFeatureExtensionOCSPHistogram, 0); |
2354 } | 2392 } |
2355 | 2393 |
2356 } // namespace net | 2394 } // namespace net |
OLD | NEW |