| 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/base64.h" | 5 #include "base/base64.h" |
| 6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "content/public/test/browser_test_utils.h" | 27 #include "content/public/test/browser_test_utils.h" |
| 28 #include "extensions/browser/event_router.h" | 28 #include "extensions/browser/event_router.h" |
| 29 #include "extensions/browser/extension_prefs.h" | 29 #include "extensions/browser/extension_prefs.h" |
| 30 #include "extensions/browser/extension_system.h" | 30 #include "extensions/browser/extension_system.h" |
| 31 #include "extensions/common/api/runtime.h" | 31 #include "extensions/common/api/runtime.h" |
| 32 #include "extensions/common/extension_builder.h" | 32 #include "extensions/common/extension_builder.h" |
| 33 #include "extensions/common/value_builder.h" | 33 #include "extensions/common/value_builder.h" |
| 34 #include "net/cert/asn1_util.h" | 34 #include "net/cert/asn1_util.h" |
| 35 #include "net/cert/jwk_serializer.h" | 35 #include "net/cert/jwk_serializer.h" |
| 36 #include "net/dns/mock_host_resolver.h" | 36 #include "net/dns/mock_host_resolver.h" |
| 37 #include "net/ssl/server_bound_cert_service.h" | 37 #include "net/ssl/channel_id_service.h" |
| 38 #include "net/test/embedded_test_server/embedded_test_server.h" | 38 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 39 #include "net/url_request/url_request_context.h" | 39 #include "net/url_request/url_request_context.h" |
| 40 #include "net/url_request/url_request_context_getter.h" | 40 #include "net/url_request/url_request_context_getter.h" |
| 41 #include "url/gurl.h" | 41 #include "url/gurl.h" |
| 42 | 42 |
| 43 namespace extensions { | 43 namespace extensions { |
| 44 namespace { | 44 namespace { |
| 45 | 45 |
| 46 class MessageSender : public content::NotificationObserver { | 46 class MessageSender : public content::NotificationObserver { |
| 47 public: | 47 public: |
| (...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 class ExternallyConnectableMessagingWithTlsChannelIdTest : | 828 class ExternallyConnectableMessagingWithTlsChannelIdTest : |
| 829 public ExternallyConnectableMessagingTest { | 829 public ExternallyConnectableMessagingTest { |
| 830 public: | 830 public: |
| 831 ExternallyConnectableMessagingWithTlsChannelIdTest() | 831 ExternallyConnectableMessagingWithTlsChannelIdTest() |
| 832 : tls_channel_id_created_(false, false) { | 832 : tls_channel_id_created_(false, false) { |
| 833 } | 833 } |
| 834 | 834 |
| 835 std::string CreateTlsChannelId() { | 835 std::string CreateTlsChannelId() { |
| 836 scoped_refptr<net::URLRequestContextGetter> request_context_getter( | 836 scoped_refptr<net::URLRequestContextGetter> request_context_getter( |
| 837 profile()->GetRequestContext()); | 837 profile()->GetRequestContext()); |
| 838 std::string domain_bound_private_key; | 838 std::string channel_id_private_key; |
| 839 std::string domain_bound_cert; | 839 std::string channel_id_cert; |
| 840 net::ServerBoundCertService::RequestHandle request_handle; | 840 net::ChannelIDService::RequestHandle request_handle; |
| 841 content::BrowserThread::PostTask( | 841 content::BrowserThread::PostTask( |
| 842 content::BrowserThread::IO, | 842 content::BrowserThread::IO, |
| 843 FROM_HERE, | 843 FROM_HERE, |
| 844 base::Bind( | 844 base::Bind( |
| 845 &ExternallyConnectableMessagingWithTlsChannelIdTest:: | 845 &ExternallyConnectableMessagingWithTlsChannelIdTest:: |
| 846 CreateDomainBoundCertOnIOThread, | 846 CreateDomainBoundCertOnIOThread, |
| 847 base::Unretained(this), | 847 base::Unretained(this), |
| 848 base::Unretained(&domain_bound_private_key), | 848 base::Unretained(&channel_id_private_key), |
| 849 base::Unretained(&domain_bound_cert), | 849 base::Unretained(&channel_id_cert), |
| 850 base::Unretained(&request_handle), | 850 base::Unretained(&request_handle), |
| 851 request_context_getter)); | 851 request_context_getter)); |
| 852 tls_channel_id_created_.Wait(); | 852 tls_channel_id_created_.Wait(); |
| 853 // Create the expected value. | 853 // Create the expected value. |
| 854 base::StringPiece spki; | 854 base::StringPiece spki; |
| 855 net::asn1::ExtractSPKIFromDERCert(domain_bound_cert, &spki); | 855 net::asn1::ExtractSPKIFromDERCert(channel_id_cert, &spki); |
| 856 base::DictionaryValue jwk_value; | 856 base::DictionaryValue jwk_value; |
| 857 net::JwkSerializer::ConvertSpkiFromDerToJwk(spki, &jwk_value); | 857 net::JwkSerializer::ConvertSpkiFromDerToJwk(spki, &jwk_value); |
| 858 std::string tls_channel_id_value; | 858 std::string tls_channel_id_value; |
| 859 base::JSONWriter::Write(&jwk_value, &tls_channel_id_value); | 859 base::JSONWriter::Write(&jwk_value, &tls_channel_id_value); |
| 860 return tls_channel_id_value; | 860 return tls_channel_id_value; |
| 861 } | 861 } |
| 862 | 862 |
| 863 private: | 863 private: |
| 864 void CreateDomainBoundCertOnIOThread( | 864 void CreateDomainBoundCertOnIOThread( |
| 865 std::string* domain_bound_private_key, | 865 std::string* channel_id_private_key, |
| 866 std::string* domain_bound_cert, | 866 std::string* channel_id_cert, |
| 867 net::ServerBoundCertService::RequestHandle* request_handle, | 867 net::ChannelIDService::RequestHandle* request_handle, |
| 868 scoped_refptr<net::URLRequestContextGetter> request_context_getter) { | 868 scoped_refptr<net::URLRequestContextGetter> request_context_getter) { |
| 869 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 869 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 870 net::ServerBoundCertService* server_bound_cert_service = | 870 net::ChannelIDService* channel_id_service = |
| 871 request_context_getter->GetURLRequestContext()-> | 871 request_context_getter->GetURLRequestContext()-> |
| 872 server_bound_cert_service(); | 872 channel_id_service(); |
| 873 int status = server_bound_cert_service->GetOrCreateDomainBoundCert( | 873 int status = channel_id_service->GetOrCreateChannelID( |
| 874 chromium_org_url().host(), | 874 chromium_org_url().host(), |
| 875 domain_bound_private_key, | 875 channel_id_private_key, |
| 876 domain_bound_cert, | 876 channel_id_cert, |
| 877 base::Bind(&ExternallyConnectableMessagingWithTlsChannelIdTest:: | 877 base::Bind(&ExternallyConnectableMessagingWithTlsChannelIdTest:: |
| 878 GotDomainBoundCert, | 878 GotDomainBoundCert, |
| 879 base::Unretained(this)), | 879 base::Unretained(this)), |
| 880 request_handle); | 880 request_handle); |
| 881 if (status == net::ERR_IO_PENDING) | 881 if (status == net::ERR_IO_PENDING) |
| 882 return; | 882 return; |
| 883 GotDomainBoundCert(status); | 883 GotDomainBoundCert(status); |
| 884 } | 884 } |
| 885 | 885 |
| 886 void GotDomainBoundCert(int status) { | 886 void GotDomainBoundCert(int status) { |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1057 ui_test_utils::NavigateToURL(browser(), chromium_org_url()); | 1057 ui_test_utils::NavigateToURL(browser(), chromium_org_url()); |
| 1058 EXPECT_EQ(COULD_NOT_ESTABLISH_CONNECTION_ERROR, | 1058 EXPECT_EQ(COULD_NOT_ESTABLISH_CONNECTION_ERROR, |
| 1059 CanConnectAndSendMessagesToMainFrame(invalid)); | 1059 CanConnectAndSendMessagesToMainFrame(invalid)); |
| 1060 } | 1060 } |
| 1061 | 1061 |
| 1062 #endif // !defined(OS_WIN) - http://crbug.com/350517. | 1062 #endif // !defined(OS_WIN) - http://crbug.com/350517. |
| 1063 | 1063 |
| 1064 } // namespace | 1064 } // namespace |
| 1065 | 1065 |
| 1066 }; // namespace extensions | 1066 }; // namespace extensions |
| OLD | NEW |