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 "base/bind.h" |
| 6 #include "base/bind_helpers.h" |
5 #include "base/command_line.h" | 7 #include "base/command_line.h" |
6 #include "base/path_service.h" | 8 #include "base/path_service.h" |
7 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
8 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
9 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
10 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
11 #include "base/time/time.h" | 13 #include "base/time/time.h" |
12 #include "chrome/app/chrome_command_ids.h" | 14 #include "chrome/app/chrome_command_ids.h" |
13 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
14 #include "chrome/browser/content_settings/host_content_settings_map.h" | 16 #include "chrome/browser/content_settings/host_content_settings_map.h" |
(...skipping 17 matching lines...) Expand all Loading... |
32 #include "content/public/browser/notification_service.h" | 34 #include "content/public/browser/notification_service.h" |
33 #include "content/public/browser/render_view_host.h" | 35 #include "content/public/browser/render_view_host.h" |
34 #include "content/public/browser/render_widget_host_view.h" | 36 #include "content/public/browser/render_widget_host_view.h" |
35 #include "content/public/browser/web_contents.h" | 37 #include "content/public/browser/web_contents.h" |
36 #include "content/public/browser/web_contents_observer.h" | 38 #include "content/public/browser/web_contents_observer.h" |
37 #include "content/public/common/security_style.h" | 39 #include "content/public/common/security_style.h" |
38 #include "content/public/common/ssl_status.h" | 40 #include "content/public/common/ssl_status.h" |
39 #include "content/public/test/browser_test_utils.h" | 41 #include "content/public/test/browser_test_utils.h" |
40 #include "content/public/test/download_test_observer.h" | 42 #include "content/public/test/download_test_observer.h" |
41 #include "content/public/test/test_renderer_host.h" | 43 #include "content/public/test/test_renderer_host.h" |
42 #include "crypto/nss_util.h" | |
43 #include "net/base/crypto_module.h" | |
44 #include "net/base/net_errors.h" | 44 #include "net/base/net_errors.h" |
45 #include "net/base/test_data_directory.h" | 45 #include "net/base/test_data_directory.h" |
46 #include "net/cert/cert_status_flags.h" | 46 #include "net/cert/cert_status_flags.h" |
47 #include "net/test/spawned_test_server/spawned_test_server.h" | 47 #include "net/test/spawned_test_server/spawned_test_server.h" |
48 | 48 |
49 #if defined(USE_NSS) | 49 #if defined(USE_NSS) |
| 50 #include "chrome/browser/net/nss_context.h" |
| 51 #include "net/base/crypto_module.h" |
50 #include "net/cert/nss_cert_database.h" | 52 #include "net/cert/nss_cert_database.h" |
51 #endif // defined(USE_NSS) | 53 #endif // defined(USE_NSS) |
52 | 54 |
53 using base::ASCIIToUTF16; | 55 using base::ASCIIToUTF16; |
54 using content::InterstitialPage; | 56 using content::InterstitialPage; |
55 using content::NavigationController; | 57 using content::NavigationController; |
56 using content::NavigationEntry; | 58 using content::NavigationEntry; |
57 using content::SSLStatus; | 59 using content::SSLStatus; |
58 using content::WebContents; | 60 using content::WebContents; |
59 using web_modal::WebContentsModalDialogManager; | 61 using web_modal::WebContentsModalDialogManager; |
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 // Proceed anyway. | 712 // Proceed anyway. |
711 ProceedThroughInterstitial(tab); | 713 ProceedThroughInterstitial(tab); |
712 | 714 |
713 // Test page run a WebSocket wss connection test. The result will be shown | 715 // Test page run a WebSocket wss connection test. The result will be shown |
714 // as page title. | 716 // as page title. |
715 const base::string16 result = watcher.WaitAndGetTitle(); | 717 const base::string16 result = watcher.WaitAndGetTitle(); |
716 EXPECT_TRUE(LowerCaseEqualsASCII(result, "pass")); | 718 EXPECT_TRUE(LowerCaseEqualsASCII(result, "pass")); |
717 } | 719 } |
718 | 720 |
719 #if defined(USE_NSS) | 721 #if defined(USE_NSS) |
| 722 class SSLUITestWithClientCert : public SSLUITest { |
| 723 public: |
| 724 SSLUITestWithClientCert() : cert_db_(NULL) {} |
| 725 |
| 726 virtual void SetUpOnMainThread() OVERRIDE { |
| 727 SSLUITest::SetUpOnMainThread(); |
| 728 |
| 729 base::RunLoop loop; |
| 730 GetNSSCertDatabaseForProfile( |
| 731 browser()->profile(), |
| 732 base::Bind(&SSLUITestWithClientCert::DidGetCertDatabase, |
| 733 base::Unretained(this), |
| 734 &loop)); |
| 735 loop.Run(); |
| 736 } |
| 737 |
| 738 protected: |
| 739 void DidGetCertDatabase(base::RunLoop* loop, net::NSSCertDatabase* cert_db) { |
| 740 cert_db_ = cert_db; |
| 741 loop->Quit(); |
| 742 } |
| 743 |
| 744 net::NSSCertDatabase* cert_db_; |
| 745 }; |
| 746 |
720 // SSL client certificate tests are only enabled when using NSS for private key | 747 // SSL client certificate tests are only enabled when using NSS for private key |
721 // storage, as only NSS can avoid modifying global machine state when testing. | 748 // storage, as only NSS can avoid modifying global machine state when testing. |
722 // See http://crbug.com/51132 | 749 // See http://crbug.com/51132 |
723 | 750 |
724 // Visit a HTTPS page which requires client cert authentication. The client | 751 // Visit a HTTPS page which requires client cert authentication. The client |
725 // cert will be selected automatically, then a test which uses WebSocket runs. | 752 // cert will be selected automatically, then a test which uses WebSocket runs. |
726 // Disabled: http://crbug.com/159985 | 753 IN_PROC_BROWSER_TEST_F(SSLUITestWithClientCert, TestWSSClientCert) { |
727 IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestWSSClientCert) { | 754 // Import a client cert for test. |
728 // Open a temporary NSS DB for testing. | 755 scoped_refptr<net::CryptoModule> crypt_module = cert_db_->GetPublicModule(); |
729 crypto::ScopedTestNSSDB test_nssdb; | |
730 ASSERT_TRUE(test_nssdb.is_open()); | |
731 | |
732 // Import client cert for test. These interfaces require NSS. | |
733 net::NSSCertDatabase* cert_db = net::NSSCertDatabase::GetInstance(); | |
734 scoped_refptr<net::CryptoModule> crypt_module = cert_db->GetPublicModule(); | |
735 std::string pkcs12_data; | 756 std::string pkcs12_data; |
736 base::FilePath cert_path = net::GetTestCertsDirectory().Append( | 757 base::FilePath cert_path = net::GetTestCertsDirectory().Append( |
737 FILE_PATH_LITERAL("websocket_client_cert.p12")); | 758 FILE_PATH_LITERAL("websocket_client_cert.p12")); |
738 EXPECT_TRUE(base::ReadFileToString(cert_path, &pkcs12_data)); | 759 EXPECT_TRUE(base::ReadFileToString(cert_path, &pkcs12_data)); |
739 EXPECT_EQ(net::OK, | 760 EXPECT_EQ(net::OK, |
740 cert_db->ImportFromPKCS12( | 761 cert_db_->ImportFromPKCS12( |
741 crypt_module.get(), pkcs12_data, base::string16(), true, NULL)); | 762 crypt_module.get(), pkcs12_data, base::string16(), true, NULL)); |
742 | 763 |
743 // Start WebSocket test server with TLS and client cert authentication. | 764 // Start WebSocket test server with TLS and client cert authentication. |
744 net::SpawnedTestServer::SSLOptions options( | 765 net::SpawnedTestServer::SSLOptions options( |
745 net::SpawnedTestServer::SSLOptions::CERT_OK); | 766 net::SpawnedTestServer::SSLOptions::CERT_OK); |
746 options.request_client_certificate = true; | 767 options.request_client_certificate = true; |
747 base::FilePath ca_path = net::GetTestCertsDirectory().Append( | 768 base::FilePath ca_path = net::GetTestCertsDirectory().Append( |
748 FILE_PATH_LITERAL("websocket_cacert.pem")); | 769 FILE_PATH_LITERAL("websocket_cacert.pem")); |
749 options.client_authorities.push_back(ca_path); | 770 options.client_authorities.push_back(ca_path); |
750 net::SpawnedTestServer wss_server(net::SpawnedTestServer::TYPE_WSS, | 771 net::SpawnedTestServer wss_server(net::SpawnedTestServer::TYPE_WSS, |
(...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1825 | 1846 |
1826 // Visit a page over https that contains a frame with a redirect. | 1847 // Visit a page over https that contains a frame with a redirect. |
1827 | 1848 |
1828 // XMLHttpRequest insecure content in synchronous mode. | 1849 // XMLHttpRequest insecure content in synchronous mode. |
1829 | 1850 |
1830 // XMLHttpRequest insecure content in asynchronous mode. | 1851 // XMLHttpRequest insecure content in asynchronous mode. |
1831 | 1852 |
1832 // XMLHttpRequest over bad ssl in synchronous mode. | 1853 // XMLHttpRequest over bad ssl in synchronous mode. |
1833 | 1854 |
1834 // XMLHttpRequest over OK ssl in synchronous mode. | 1855 // XMLHttpRequest over OK ssl in synchronous mode. |
OLD | NEW |