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

Side by Side Diff: chrome/browser/extensions/extension_messages_apitest.cc

Issue 1076063002: Remove certificates from Channel ID (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Udpate KeysEqual to fail if preconditions fail Created 5 years, 7 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
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 "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 955 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 class ExternallyConnectableMessagingWithTlsChannelIdTest : 966 class ExternallyConnectableMessagingWithTlsChannelIdTest :
967 public ExternallyConnectableMessagingTest { 967 public ExternallyConnectableMessagingTest {
968 public: 968 public:
969 ExternallyConnectableMessagingWithTlsChannelIdTest() 969 ExternallyConnectableMessagingWithTlsChannelIdTest()
970 : tls_channel_id_created_(false, false) { 970 : tls_channel_id_created_(false, false) {
971 } 971 }
972 972
973 std::string CreateTlsChannelId() { 973 std::string CreateTlsChannelId() {
974 scoped_refptr<net::URLRequestContextGetter> request_context_getter( 974 scoped_refptr<net::URLRequestContextGetter> request_context_getter(
975 profile()->GetRequestContext()); 975 profile()->GetRequestContext());
976 std::string channel_id_private_key; 976 scoped_ptr<crypto::ECPrivateKey> channel_id_key;
977 std::string channel_id_cert; 977 net::ChannelIDService::RequestHandle request_handle;
978 net::ChannelIDService::RequestHandle request_handle;
979 content::BrowserThread::PostTask( 978 content::BrowserThread::PostTask(
980 content::BrowserThread::IO, 979 content::BrowserThread::IO, FROM_HERE,
981 FROM_HERE, 980 base::Bind(&ExternallyConnectableMessagingWithTlsChannelIdTest::
982 base::Bind( 981 CreateDomainBoundCertOnIOThread,
983 &ExternallyConnectableMessagingWithTlsChannelIdTest:: 982 base::Unretained(this), base::Unretained(&channel_id_key),
984 CreateDomainBoundCertOnIOThread, 983 base::Unretained(&request_handle), request_context_getter));
985 base::Unretained(this),
986 base::Unretained(&channel_id_private_key),
987 base::Unretained(&channel_id_cert),
988 base::Unretained(&request_handle),
989 request_context_getter));
990 tls_channel_id_created_.Wait(); 984 tls_channel_id_created_.Wait();
991 // Create the expected value. 985 // Create the expected value.
992 base::StringPiece spki; 986 std::vector<uint8> spki_vector;
993 net::asn1::ExtractSPKIFromDERCert(channel_id_cert, &spki); 987 if (!channel_id_key->ExportPublicKey(&spki_vector))
988 return std::string();
989 base::StringPiece spki(reinterpret_cast<char*>(
990 vector_as_array(&spki_vector)), spki_vector.size());
994 base::DictionaryValue jwk_value; 991 base::DictionaryValue jwk_value;
995 net::JwkSerializer::ConvertSpkiFromDerToJwk(spki, &jwk_value); 992 net::JwkSerializer::ConvertSpkiFromDerToJwk(spki, &jwk_value);
996 std::string tls_channel_id_value; 993 std::string tls_channel_id_value;
997 base::JSONWriter::Write(jwk_value, &tls_channel_id_value); 994 base::JSONWriter::Write(jwk_value, &tls_channel_id_value);
998 return tls_channel_id_value; 995 return tls_channel_id_value;
999 } 996 }
1000 997
1001 private: 998 private:
1002 void CreateDomainBoundCertOnIOThread( 999 void CreateDomainBoundCertOnIOThread(
1003 std::string* channel_id_private_key, 1000 scoped_ptr<crypto::ECPrivateKey>* channel_id_key,
1004 std::string* channel_id_cert,
1005 net::ChannelIDService::RequestHandle* request_handle, 1001 net::ChannelIDService::RequestHandle* request_handle,
1006 scoped_refptr<net::URLRequestContextGetter> request_context_getter) { 1002 scoped_refptr<net::URLRequestContextGetter> request_context_getter) {
1007 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 1003 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
1008 net::ChannelIDService* channel_id_service = 1004 net::ChannelIDService* channel_id_service =
1009 request_context_getter->GetURLRequestContext()-> 1005 request_context_getter->GetURLRequestContext()->
1010 channel_id_service(); 1006 channel_id_service();
1011 int status = channel_id_service->GetOrCreateChannelID( 1007 int status = channel_id_service->GetOrCreateChannelID(
1012 chromium_org_url().host(), 1008 chromium_org_url().host(), channel_id_key,
1013 channel_id_private_key,
1014 channel_id_cert,
1015 base::Bind(&ExternallyConnectableMessagingWithTlsChannelIdTest:: 1009 base::Bind(&ExternallyConnectableMessagingWithTlsChannelIdTest::
1016 GotDomainBoundCert, 1010 GotDomainBoundCert,
1017 base::Unretained(this)), 1011 base::Unretained(this)),
1018 request_handle); 1012 request_handle);
1019 if (status == net::ERR_IO_PENDING) 1013 if (status == net::ERR_IO_PENDING)
1020 return; 1014 return;
1021 GotDomainBoundCert(status); 1015 GotDomainBoundCert(status);
1022 } 1016 }
1023 1017
1024 void GotDomainBoundCert(int status) { 1018 void GotDomainBoundCert(int status) {
1025 ASSERT_TRUE(status == net::OK); 1019 ASSERT_TRUE(status == net::OK);
1026 tls_channel_id_created_.Signal(); 1020 tls_channel_id_created_.Signal();
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 ui_test_utils::NavigateToURL(browser(), chromium_org_url()); 1194 ui_test_utils::NavigateToURL(browser(), chromium_org_url());
1201 EXPECT_EQ(COULD_NOT_ESTABLISH_CONNECTION_ERROR, 1195 EXPECT_EQ(COULD_NOT_ESTABLISH_CONNECTION_ERROR,
1202 CanConnectAndSendMessagesToMainFrame(invalid.get())); 1196 CanConnectAndSendMessagesToMainFrame(invalid.get()));
1203 } 1197 }
1204 1198
1205 #endif // !defined(OS_WIN) - http://crbug.com/350517. 1199 #endif // !defined(OS_WIN) - http://crbug.com/350517.
1206 1200
1207 } // namespace 1201 } // namespace
1208 1202
1209 }; // namespace extensions 1203 }; // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698