Index: chrome/browser/ssl/ssl_browser_tests.cc |
diff --git a/chrome/browser/ssl/ssl_browser_tests.cc b/chrome/browser/ssl/ssl_browser_tests.cc |
index ba69fe78eb8b47aee9d8ebc1bb8ecb8fff4a3cc8..430be39ffa37987689beb3815a39ff945eee48b7 100644 |
--- a/chrome/browser/ssl/ssl_browser_tests.cc |
+++ b/chrome/browser/ssl/ssl_browser_tests.cc |
@@ -19,6 +19,7 @@ |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/safe_browsing/ping_manager.h" |
#include "chrome/browser/safe_browsing/safe_browsing_service.h" |
+#include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h" |
#include "chrome/browser/ssl/ssl_blocking_page.h" |
#include "chrome/browser/ui/browser.h" |
#include "chrome/browser/ui/browser_commands.h" |
@@ -38,6 +39,7 @@ |
#include "content/public/browser/navigation_entry.h" |
#include "content/public/browser/notification_service.h" |
#include "content/public/browser/render_frame_host.h" |
+#include "content/public/browser/render_process_host.h" |
#include "content/public/browser/render_view_host.h" |
#include "content/public/browser/render_widget_host_view.h" |
#include "content/public/browser/web_contents.h" |
@@ -50,10 +52,13 @@ |
#include "net/base/net_errors.h" |
#include "net/base/test_data_directory.h" |
#include "net/cert/cert_status_flags.h" |
+#include "net/cert/test_root_certs.h" |
#include "net/cert/x509_certificate.h" |
+#include "net/http/http_transaction_factory.h" |
#include "net/ssl/ssl_info.h" |
#include "net/test/spawned_test_server/spawned_test_server.h" |
#include "net/url_request/url_request_context.h" |
+#include "net/url_request/url_request_context_getter.h" |
#if defined(USE_NSS) |
#include "chrome/browser/net/nss_context.h" |
@@ -222,6 +227,29 @@ void SetUpMockReporter(SafeBrowsingService* safe_browsing_service, |
} // namespace CertificateReporting |
+void RootCertsChangedOnIO(net::URLRequestContextGetter* context_getter) { |
Ryan Sleevi
2015/04/09 20:55:48
s/OnIO/OnIOThread/
Ryan Sleevi
2015/04/09 20:55:48
DANGER WILL ROBINSON: Passing a naked pointer arou
jww
2015/04/16 23:59:07
Done.
jww
2015/04/16 23:59:07
Done.
|
+ context_getter->GetURLRequestContext() |
+ ->http_transaction_factory() |
+ ->GetSession() |
+ ->CloseAllConnections(); |
+} |
+ |
+void RootCertsChanged(WebContents* contents) { |
Ryan Sleevi
2015/04/09 20:55:48
Document
jww
2015/04/16 23:59:07
Done.
|
+ net::CertDatabase::GetInstance()->NotifyObserversOfCACertChanged(NULL); |
Ryan Sleevi
2015/04/09 20:55:48
Running this on not-IO thread? Sounds super sketch
jww
2015/04/16 23:59:07
I'ved moved it to RootCertsChangedOnIOThread().
|
+ |
+ scoped_refptr<net::URLRequestContextGetter> url_request_context = |
+ contents->GetBrowserContext()->GetRequestContextForRenderProcess( |
+ contents->GetRenderProcessHost()->GetID()); |
+ base::RunLoop run_loop; |
+ content::BrowserThread::PostTaskAndReply( |
+ content::BrowserThread::IO, FROM_HERE, |
+ base::Bind(&RootCertsChangedOnIO, url_request_context), |
+ run_loop.QuitClosure()); |
+ |
+ run_loop.Run(); |
+ base::RunLoop().RunUntilIdle(); |
+} |
+ |
} // namespace |
class SSLUITest : public InProcessBrowserTest { |
@@ -2129,6 +2157,40 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, InterstitialNotAffectedByHideShow) { |
EXPECT_TRUE(tab->GetRenderWidgetHostView()->IsShowing()); |
} |
+// Verifies that if a bad certificate is seen for a host and the user proceeds |
+// through the interstitial, the decision to proceed is initially remembered. |
+// However, if this is followed by another visit, and a good certificate |
+// is seen for the same host, the original exception is forgotten. |
+IN_PROC_BROWSER_TEST_F(SSLUITest, BadCertFollowedByGoodCert) { |
+ ASSERT_TRUE(https_server_.Start()); |
+ std::string https_server_host = |
+ https_server_.GetURL("files/ssl/google.html").host(); |
+ |
+ WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
+ net::TestRootCerts* root_certs = net::TestRootCerts::GetInstance(); |
+ |
+ ASSERT_TRUE(root_certs != NULL); |
Ryan Sleevi
2015/04/09 20:55:48
ASSERT_TRUE(root_certs)
jww
2015/04/16 23:59:06
Done.
|
+ root_certs->Clear(); |
+ |
+ Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); |
+ ChromeSSLHostStateDelegate* state = |
+ reinterpret_cast<ChromeSSLHostStateDelegate*>( |
+ profile->GetSSLHostStateDelegate()); |
+ |
+ ui_test_utils::NavigateToURL(browser(), |
+ https_server_.GetURL("files/ssl/google.html")); |
+ |
+ ProceedThroughInterstitial(tab); |
+ EXPECT_TRUE(state->HasAllowException(https_server_host)); |
+ |
+ ASSERT_TRUE(https_server_.LoadTestRootCert()); |
+ RootCertsChanged(tab); |
+ ui_test_utils::NavigateToURL(browser(), |
+ https_server_.GetURL("files/ssl/google.html")); |
+ ASSERT_FALSE(tab->GetInterstitialPage()); |
+ EXPECT_FALSE(state->HasAllowException(https_server_host)); |
+} |
+ |
class SSLBlockingPageIDNTest : public SecurityInterstitialIDNTest { |
protected: |
// SecurityInterstitialIDNTest implementation |