Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(943)

Side by Side Diff: net/url_request/url_request_unittest.cc

Issue 10857020: Do not perform online revocation checking when the user has explicitly disabled it, except for when… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shlobj.h> 9 #include <shlobj.h>
10 #endif 10 #endif
(...skipping 1467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 0xdb, 0x1a, 0xf7, 0xa0, 0x9f, 0x09, 0xa1, 0xea, 0xf1, 0x5c } }; 1478 0xdb, 0x1a, 0xf7, 0xa0, 0x9f, 0x09, 0xa1, 0xea, 0xf1, 0x5c } };
1479 1479
1480 // This is the policy OID contained in the certificates that testserver 1480 // This is the policy OID contained in the certificates that testserver
1481 // generates. 1481 // generates.
1482 static const char kOCSPTestCertPolicy[] = "1.3.6.1.4.1.11129.2.4.1"; 1482 static const char kOCSPTestCertPolicy[] = "1.3.6.1.4.1.11129.2.4.1";
1483 1483
1484 class HTTPSOCSPTest : public HTTPSRequestTest { 1484 class HTTPSOCSPTest : public HTTPSRequestTest {
1485 public: 1485 public:
1486 HTTPSOCSPTest() 1486 HTTPSOCSPTest()
1487 : context_(true), 1487 : context_(true),
1488 ev_test_policy_(EVRootCAMetadata::GetInstance(), 1488 ev_test_policy_(
1489 kOCSPTestCertFingerprint, 1489 new ScopedTestEVPolicy(EVRootCAMetadata::GetInstance(),
1490 kOCSPTestCertPolicy) { 1490 kOCSPTestCertFingerprint,
1491 kOCSPTestCertPolicy)) {
1491 } 1492 }
1492 1493
1493 virtual void SetUp() OVERRIDE { 1494 virtual void SetUp() OVERRIDE {
1494 SetupContext(&context_); 1495 SetupContext(&context_);
1495 context_.Init(); 1496 context_.Init();
1496 1497
1497 scoped_refptr<net::X509Certificate> root_cert = 1498 scoped_refptr<net::X509Certificate> root_cert =
1498 ImportCertFromFile(GetTestCertsDirectory(), "ocsp-test-root.pem"); 1499 ImportCertFromFile(GetTestCertsDirectory(), "ocsp-test-root.pem");
1499 CHECK_NE(static_cast<X509Certificate*>(NULL), root_cert); 1500 CHECK_NE(static_cast<X509Certificate*>(NULL), root_cert);
1500 test_root_.reset(new ScopedTestRoot(root_cert)); 1501 test_root_.reset(new ScopedTestRoot(root_cert));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 // connetions to testserver. This can be overridden in test subclasses for 1534 // connetions to testserver. This can be overridden in test subclasses for
1534 // different behaviour. 1535 // different behaviour.
1535 virtual void SetupContext(URLRequestContext* context) { 1536 virtual void SetupContext(URLRequestContext* context) {
1536 context->set_ssl_config_service( 1537 context->set_ssl_config_service(
1537 new TestSSLConfigService(true /* check for EV */, 1538 new TestSSLConfigService(true /* check for EV */,
1538 true /* online revocation checking */)); 1539 true /* online revocation checking */));
1539 } 1540 }
1540 1541
1541 scoped_ptr<ScopedTestRoot> test_root_; 1542 scoped_ptr<ScopedTestRoot> test_root_;
1542 TestURLRequestContext context_; 1543 TestURLRequestContext context_;
1543 ScopedTestEVPolicy ev_test_policy_; 1544 scoped_ptr<ScopedTestEVPolicy> ev_test_policy_;
1544 }; 1545 };
1545 1546
1546 static CertStatus ExpectedCertStatusForFailedOnlineRevocationCheck() { 1547 static CertStatus ExpectedCertStatusForFailedOnlineRevocationCheck() {
1547 #if defined(OS_WIN) 1548 #if defined(OS_WIN)
1548 // Windows can return CERT_STATUS_UNABLE_TO_CHECK_REVOCATION but we don't 1549 // Windows can return CERT_STATUS_UNABLE_TO_CHECK_REVOCATION but we don't
1549 // have that ability on other platforms. 1550 // have that ability on other platforms.
1550 return CERT_STATUS_UNABLE_TO_CHECK_REVOCATION; 1551 return CERT_STATUS_UNABLE_TO_CHECK_REVOCATION;
1551 #else 1552 #else
1552 return 0; 1553 return 0;
1553 #endif 1554 #endif
1554 } 1555 }
1555 1556
1556 // SystemUsesChromiumEVMetadata returns true iff the current operating system 1557 // SystemUsesChromiumEVMetadata returns true iff the current operating system
1557 // uses Chromium's EV metadata (i.e. EVRootCAMetadata). If it does not, then 1558 // uses Chromium's EV metadata (i.e. EVRootCAMetadata). If it does not, then
1558 // several tests are effected because our testing EV certificate won't be 1559 // several tests are effected because our testing EV certificate won't be
1559 // recognised as EV. 1560 // recognised as EV.
1560 static bool SystemUsesChromiumEVMetadata() { 1561 static bool SystemUsesChromiumEVMetadata() {
1561 #if defined(USE_OPENSSL) 1562 #if defined(USE_OPENSSL)
1562 // http://crbug.com/117478 - OpenSSL does not support EV validation. 1563 // http://crbug.com/117478 - OpenSSL does not support EV validation.
1563 return false; 1564 return false;
1564 #elif defined(OS_MACOSX) 1565 #elif defined(OS_MACOSX)
1565 // On OS X, we use the system to tell us whether a certificate is EV or not 1566 // On OS X, we use the system to tell us whether a certificate is EV or not
1566 // and the system won't recognise our testing root. 1567 // and the system won't recognise our testing root.
1567 return false; 1568 return false;
1568 #else 1569 #else
1569 return true; 1570 return true;
1570 #endif 1571 #endif
1571 } 1572 }
1572 1573
1573 static bool 1574 static bool SystemSupportsOCSP() {
1574 SystemSupportsOCSP() {
1575 #if defined(USE_OPENSSL) 1575 #if defined(USE_OPENSSL)
1576 // http://crbug.com/117478 - OpenSSL does not support OCSP. 1576 // http://crbug.com/117478 - OpenSSL does not support OCSP.
1577 return false; 1577 return false;
1578 #elif defined(OS_WIN) 1578 #elif defined(OS_WIN)
1579 return base::win::GetVersion() >= base::win::VERSION_VISTA; 1579 return base::win::GetVersion() >= base::win::VERSION_VISTA;
1580 #elif defined(OS_ANDROID) 1580 #elif defined(OS_ANDROID)
1581 // TODO(jnd): http://crbug.com/117478 - EV verification is not yet supported. 1581 // TODO(jnd): http://crbug.com/117478 - EV verification is not yet supported.
1582 return false; 1582 return false;
1583 #else 1583 #else
1584 return true; 1584 return true;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1734 // With a valid, fresh CRLSet the bad OCSP response shouldn't matter because 1734 // With a valid, fresh CRLSet the bad OCSP response shouldn't matter because
1735 // we wont check it. 1735 // we wont check it.
1736 EXPECT_EQ(0u, cert_status & CERT_STATUS_ALL_ERRORS); 1736 EXPECT_EQ(0u, cert_status & CERT_STATUS_ALL_ERRORS);
1737 1737
1738 EXPECT_EQ(SystemUsesChromiumEVMetadata(), 1738 EXPECT_EQ(SystemUsesChromiumEVMetadata(),
1739 static_cast<bool>(cert_status & CERT_STATUS_IS_EV)); 1739 static_cast<bool>(cert_status & CERT_STATUS_IS_EV));
1740 1740
1741 EXPECT_FALSE(cert_status & CERT_STATUS_REV_CHECKING_ENABLED); 1741 EXPECT_FALSE(cert_status & CERT_STATUS_REV_CHECKING_ENABLED);
1742 } 1742 }
1743 1743
1744 TEST_F(HTTPSEVCRLSetTest, ExpiredCRLSetAndRevokedNonEVCert) {
1745 // Test that when EV verification is requested, but online revocation
1746 // checking is disabled, and the leaf certificate is not in fact EV, that
1747 // no revocation checking actually happens.
1748 if (!SystemSupportsOCSP()) {
1749 LOG(WARNING) << "Skipping test because system doesn't support OCSP";
1750 return;
1751 }
1752
1753 // Unmark the certificate's OID as EV, which should disable revocation
1754 // checking (as per the user preference)
1755 ev_test_policy_.reset();
1756
1757 TestServer::HTTPSOptions https_options(
1758 TestServer::HTTPSOptions::CERT_AUTO);
1759 https_options.ocsp_status = TestServer::HTTPSOptions::OCSP_REVOKED;
1760 SSLConfigService::SetCRLSet(
1761 scoped_refptr<CRLSet>(CRLSet::ExpiredCRLSetForTesting()));
1762
1763 CertStatus cert_status;
1764 DoConnection(https_options, &cert_status);
1765
1766 EXPECT_EQ(0u, cert_status & CERT_STATUS_ALL_ERRORS);
1767
1768 EXPECT_FALSE(cert_status & CERT_STATUS_IS_EV);
1769 EXPECT_FALSE(cert_status & CERT_STATUS_REV_CHECKING_ENABLED);
1770 }
1771
1744 class HTTPSCRLSetTest : public HTTPSOCSPTest { 1772 class HTTPSCRLSetTest : public HTTPSOCSPTest {
1745 protected: 1773 protected:
1746 virtual void SetupContext(URLRequestContext* context) OVERRIDE { 1774 virtual void SetupContext(URLRequestContext* context) OVERRIDE {
1747 context->set_ssl_config_service( 1775 context->set_ssl_config_service(
1748 new TestSSLConfigService(false /* check for EV */, 1776 new TestSSLConfigService(false /* check for EV */,
1749 false /* online revocation checking */)); 1777 false /* online revocation checking */));
1750 } 1778 }
1751 }; 1779 };
1752 1780
1753 TEST_F(HTTPSCRLSetTest, ExpiredCRLSet) { 1781 TEST_F(HTTPSCRLSetTest, ExpiredCRLSet) {
(...skipping 2874 matching lines...) Expand 10 before | Expand all | Expand 10 after
4628 req.SetExtraRequestHeaders(headers); 4656 req.SetExtraRequestHeaders(headers);
4629 req.Start(); 4657 req.Start();
4630 MessageLoop::current()->Run(); 4658 MessageLoop::current()->Run();
4631 // If the net tests are being run with ChromeFrame then we need to allow for 4659 // If the net tests are being run with ChromeFrame then we need to allow for
4632 // the 'chromeframe' suffix which is added to the user agent before the 4660 // the 'chromeframe' suffix which is added to the user agent before the
4633 // closing parentheses. 4661 // closing parentheses.
4634 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); 4662 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true));
4635 } 4663 }
4636 4664
4637 } // namespace net 4665 } // namespace net
OLDNEW
« net/base/cert_verify_proc_nss.cc ('K') | « net/base/x509_certificate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698