diff options
author | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-29 17:52:37 +0000 |
---|---|---|
committer | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-29 17:52:37 +0000 |
commit | 69921772fb52161c4f6bcf6d8048da946b3273df (patch) | |
tree | 41fcc12727579933ecd4caad0ec088e1120d879d | |
parent | 7ee0bd6829d6e2b6bdeabdcb08438157f2182b7e (diff) | |
download | chromium_src-69921772fb52161c4f6bcf6d8048da946b3273df.zip chromium_src-69921772fb52161c4f6bcf6d8048da946b3273df.tar.gz chromium_src-69921772fb52161c4f6bcf6d8048da946b3273df.tar.bz2 |
ServerBoundCertService::GetDomainBoundCert should take a host string, not an URL-string.
BUG=234417
Review URL: https://chromiumcodereview.appspot.com/14520025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@197077 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | net/socket/ssl_client_socket_nss.cc | 12 | ||||
-rw-r--r-- | net/spdy/spdy_credential_builder_unittest.cc | 2 | ||||
-rw-r--r-- | net/spdy/spdy_http_stream_spdy3_unittest.cc | 6 | ||||
-rw-r--r-- | net/spdy/spdy_stream.cc | 2 | ||||
-rw-r--r-- | net/ssl/server_bound_cert_service.cc | 8 | ||||
-rw-r--r-- | net/ssl/server_bound_cert_service.h | 4 | ||||
-rw-r--r-- | net/ssl/server_bound_cert_service_unittest.cc | 82 |
7 files changed, 58 insertions, 58 deletions
diff --git a/net/socket/ssl_client_socket_nss.cc b/net/socket/ssl_client_socket_nss.cc index 8b05f1b..b18cca7 100644 --- a/net/socket/ssl_client_socket_nss.cc +++ b/net/socket/ssl_client_socket_nss.cc @@ -777,7 +777,7 @@ class SSLClientSocketNSS::Core : public base::RefCountedThreadSafe<Core> { //////////////////////////////////////////////////////////////////////////// int DoBufferRecv(IOBuffer* buffer, int len); int DoBufferSend(IOBuffer* buffer, int len); - int DoGetDomainBoundCert(const std::string& origin, + int DoGetDomainBoundCert(const std::string& host, const std::vector<uint8>& requested_cert_types); void OnGetDomainBoundCertComplete(int result); @@ -2351,18 +2351,18 @@ SECStatus SSLClientSocketNSS::Core::ClientChannelIDHandler( // We have negotiated the TLS channel ID extension. core->channel_id_xtn_negotiated_ = true; - std::string origin = "https://" + core->host_and_port_.ToString(); + std::string host = core->host_and_port_.host(); std::vector<uint8> requested_cert_types; requested_cert_types.push_back(CLIENT_CERT_ECDSA_SIGN); int error = ERR_UNEXPECTED; if (core->OnNetworkTaskRunner()) { - error = core->DoGetDomainBoundCert(origin, requested_cert_types); + error = core->DoGetDomainBoundCert(host, requested_cert_types); } else { bool posted = core->network_task_runner_->PostTask( FROM_HERE, base::Bind( IgnoreResult(&Core::DoGetDomainBoundCert), - core, origin, requested_cert_types)); + core, host, requested_cert_types)); error = posted ? ERR_IO_PENDING : ERR_ABORTED; } @@ -2608,7 +2608,7 @@ int SSLClientSocketNSS::Core::DoBufferSend(IOBuffer* send_buffer, int len) { } int SSLClientSocketNSS::Core::DoGetDomainBoundCert( - const std::string& origin, + const std::string& host, const std::vector<uint8>& requested_cert_types) { DCHECK(OnNetworkTaskRunner()); @@ -2618,7 +2618,7 @@ int SSLClientSocketNSS::Core::DoGetDomainBoundCert( weak_net_log_->BeginEvent(NetLog::TYPE_SSL_GET_DOMAIN_BOUND_CERT); int rv = server_bound_cert_service_->GetDomainBoundCert( - origin, + host, requested_cert_types, &domain_bound_cert_type_, &domain_bound_private_key_, diff --git a/net/spdy/spdy_credential_builder_unittest.cc b/net/spdy/spdy_credential_builder_unittest.cc index 1332948..d46088c 100644 --- a/net/spdy/spdy_credential_builder_unittest.cc +++ b/net/spdy/spdy_credential_builder_unittest.cc @@ -37,7 +37,7 @@ void CreateCertAndKey(std::string* cert, std::string* key) { SSLClientCertType cert_type; ServerBoundCertService::RequestHandle request_handle; int rv = server_bound_cert_service->GetDomainBoundCert( - "https://www.google.com", requested_cert_types, &cert_type, key, cert, + "www.google.com", requested_cert_types, &cert_type, key, cert, callback.callback(), &request_handle); EXPECT_EQ(ERR_IO_PENDING, rv); EXPECT_EQ(OK, callback.WaitForResult()); diff --git a/net/spdy/spdy_http_stream_spdy3_unittest.cc b/net/spdy/spdy_http_stream_spdy3_unittest.cc index 21a5aad..8e3d85e 100644 --- a/net/spdy/spdy_http_stream_spdy3_unittest.cc +++ b/net/spdy/spdy_http_stream_spdy3_unittest.cc @@ -678,7 +678,7 @@ TEST_F(SpdyHttpStreamSpdy3Test, SpdyURLTest) { namespace { void GetECServerBoundCertAndProof( - const std::string& origin, + const std::string& host, ServerBoundCertService* server_bound_cert_service, std::string* cert, std::string* proof) { @@ -689,7 +689,7 @@ void GetECServerBoundCertAndProof( std::string key; ServerBoundCertService::RequestHandle request_handle; int rv = server_bound_cert_service->GetDomainBoundCert( - origin, requested_cert_types, &cert_type, &key, cert, callback.callback(), + host, requested_cert_types, &cert_type, &key, cert, callback.callback(), &request_handle); EXPECT_EQ(ERR_IO_PENDING, rv); EXPECT_EQ(OK, callback.WaitForResult()); @@ -893,7 +893,7 @@ TEST_F(SpdyHttpStreamSpdy3Test, SendCredentialsEC) { sequenced_worker_pool)); std::string cert; std::string proof; - GetECServerBoundCertAndProof("http://www.gmail.com/", + GetECServerBoundCertAndProof("www.gmail.com", server_bound_cert_service.get(), &cert, &proof); diff --git a/net/spdy/spdy_stream.cc b/net/spdy/spdy_stream.cc index 5c3ca2d..06d506f 100644 --- a/net/spdy/spdy_stream.cc +++ b/net/spdy/spdy_stream.cc @@ -810,7 +810,7 @@ int SpdyStream::DoGetDomainBoundCert() { std::vector<uint8> requested_cert_types; requested_cert_types.push_back(CLIENT_CERT_ECDSA_SIGN); int rv = sbc_service->GetDomainBoundCert( - GetUrl().GetOrigin().spec(), requested_cert_types, + GetUrl().GetOrigin().host(), requested_cert_types, &domain_bound_cert_type_, &domain_bound_private_key_, &domain_bound_cert_, base::Bind(&SpdyStream::OnGetDomainBoundCertComplete, weak_ptr_factory_.GetWeakPtr()), diff --git a/net/ssl/server_bound_cert_service.cc b/net/ssl/server_bound_cert_service.cc index 3a50ed6..ddaa520 100644 --- a/net/ssl/server_bound_cert_service.cc +++ b/net/ssl/server_bound_cert_service.cc @@ -417,26 +417,26 @@ std::string ServerBoundCertService::GetDomainForHost(const std::string& host) { } int ServerBoundCertService::GetDomainBoundCert( - const std::string& origin, + const std::string& host, const std::vector<uint8>& requested_types, SSLClientCertType* type, std::string* private_key, std::string* cert, const CompletionCallback& callback, RequestHandle* out_req) { - DVLOG(1) << __FUNCTION__ << " " << origin << " " + DVLOG(1) << __FUNCTION__ << " " << host << " " << (requested_types.empty() ? -1 : requested_types[0]) << (requested_types.size() > 1 ? "..." : ""); DCHECK(CalledOnValidThread()); base::TimeTicks request_start = base::TimeTicks::Now(); - if (callback.is_null() || !private_key || !cert || origin.empty() || + if (callback.is_null() || !private_key || !cert || host.empty() || requested_types.empty()) { RecordGetDomainBoundCertResult(INVALID_ARGUMENT); return ERR_INVALID_ARGUMENT; } - std::string domain = GetDomainForHost(GURL(origin).host()); + std::string domain = GetDomainForHost(host); if (domain.empty()) { RecordGetDomainBoundCertResult(INVALID_ARGUMENT); return ERR_INVALID_ARGUMENT; diff --git a/net/ssl/server_bound_cert_service.h b/net/ssl/server_bound_cert_service.h index 6663fad..825d45e 100644 --- a/net/ssl/server_bound_cert_service.h +++ b/net/ssl/server_bound_cert_service.h @@ -92,7 +92,7 @@ class NET_EXPORT ServerBoundCertService // longer hold. bool IsSystemTimeValid() const { return is_system_time_valid_; } - // Fetches the domain bound cert for the specified origin of the specified + // Fetches the domain bound cert for the specified host of the specified // type if one exists and creates one otherwise. Returns OK if successful or // an error code upon failure. // @@ -112,7 +112,7 @@ class NET_EXPORT ServerBoundCertService // RequestHandle object must be cancelled or destroyed before the // ServerBoundCertService is destroyed. int GetDomainBoundCert( - const std::string& origin, + const std::string& host, const std::vector<uint8>& requested_types, SSLClientCertType* type, std::string* private_key, diff --git a/net/ssl/server_bound_cert_service_unittest.cc b/net/ssl/server_bound_cert_service_unittest.cc index a718fa9..d36c27e 100644 --- a/net/ssl/server_bound_cert_service_unittest.cc +++ b/net/ssl/server_bound_cert_service_unittest.cc @@ -66,7 +66,7 @@ TEST_F(ServerBoundCertServiceTest, GetDomainForHost) { #if !defined(USE_OPENSSL) TEST_F(ServerBoundCertServiceTest, CacheHit) { - std::string origin("https://encrypted.google.com:443"); + std::string host("encrypted.google.com"); int error; std::vector<uint8> types; @@ -79,7 +79,7 @@ TEST_F(ServerBoundCertServiceTest, CacheHit) { std::string private_key_info1, der_cert1; EXPECT_EQ(0, service_->cert_count()); error = service_->GetDomainBoundCert( - origin, types, &type1, &private_key_info1, &der_cert1, + host, types, &type1, &private_key_info1, &der_cert1, callback.callback(), &request_handle); EXPECT_EQ(ERR_IO_PENDING, error); EXPECT_TRUE(request_handle.is_active()); @@ -95,7 +95,7 @@ TEST_F(ServerBoundCertServiceTest, CacheHit) { SSLClientCertType type2; std::string private_key_info2, der_cert2; error = service_->GetDomainBoundCert( - origin, types, &type2, &private_key_info2, &der_cert2, + host, types, &type2, &private_key_info2, &der_cert2, callback.callback(), &request_handle); EXPECT_FALSE(request_handle.is_active()); EXPECT_EQ(OK, error); @@ -110,7 +110,7 @@ TEST_F(ServerBoundCertServiceTest, CacheHit) { } TEST_F(ServerBoundCertServiceTest, UnsupportedTypes) { - std::string origin("https://encrypted.google.com:443"); + std::string host("encrypted.google.com"); int error; std::vector<uint8> types; @@ -121,7 +121,7 @@ TEST_F(ServerBoundCertServiceTest, UnsupportedTypes) { SSLClientCertType type1; std::string private_key_info1, der_cert1; error = service_->GetDomainBoundCert( - origin, types, &type1, &private_key_info1, &der_cert1, + host, types, &type1, &private_key_info1, &der_cert1, callback.callback(), &request_handle); EXPECT_EQ(ERR_INVALID_ARGUMENT, error); EXPECT_FALSE(request_handle.is_active()); @@ -131,7 +131,7 @@ TEST_F(ServerBoundCertServiceTest, UnsupportedTypes) { types.push_back(2); types.push_back(3); error = service_->GetDomainBoundCert( - origin, types, &type1, &private_key_info1, &der_cert1, + host, types, &type1, &private_key_info1, &der_cert1, callback.callback(), &request_handle); EXPECT_EQ(ERR_CLIENT_AUTH_CERT_TYPE_UNSUPPORTED, error); EXPECT_FALSE(request_handle.is_active()); @@ -141,7 +141,7 @@ TEST_F(ServerBoundCertServiceTest, UnsupportedTypes) { // Asynchronous completion. EXPECT_EQ(0, service_->cert_count()); error = service_->GetDomainBoundCert( - origin, types, &type1, &private_key_info1, &der_cert1, + host, types, &type1, &private_key_info1, &der_cert1, callback.callback(), &request_handle); EXPECT_EQ(ERR_IO_PENDING, error); EXPECT_TRUE(request_handle.is_active()); @@ -159,7 +159,7 @@ TEST_F(ServerBoundCertServiceTest, UnsupportedTypes) { SSLClientCertType type2; std::string private_key_info2, der_cert2; error = service_->GetDomainBoundCert( - origin, types, &type2, &private_key_info2, &der_cert2, + host, types, &type2, &private_key_info2, &der_cert2, callback.callback(), &request_handle); EXPECT_EQ(ERR_INVALID_ARGUMENT, error); EXPECT_FALSE(request_handle.is_active()); @@ -169,7 +169,7 @@ TEST_F(ServerBoundCertServiceTest, UnsupportedTypes) { types.push_back(2); types.push_back(3); error = service_->GetDomainBoundCert( - origin, types, &type2, &private_key_info2, &der_cert2, + host, types, &type2, &private_key_info2, &der_cert2, callback.callback(), &request_handle); EXPECT_EQ(ERR_CLIENT_AUTH_CERT_TYPE_UNSUPPORTED, error); EXPECT_FALSE(request_handle.is_active()); @@ -177,7 +177,7 @@ TEST_F(ServerBoundCertServiceTest, UnsupportedTypes) { // If we request EC, the cert we created before should still be there. types.push_back(CLIENT_CERT_ECDSA_SIGN); error = service_->GetDomainBoundCert( - origin, types, &type2, &private_key_info2, &der_cert2, + host, types, &type2, &private_key_info2, &der_cert2, callback.callback(), &request_handle); EXPECT_FALSE(request_handle.is_active()); EXPECT_EQ(OK, error); @@ -194,12 +194,12 @@ TEST_F(ServerBoundCertServiceTest, StoreCerts) { TestCompletionCallback callback; ServerBoundCertService::RequestHandle request_handle; - std::string origin1("https://encrypted.google.com:443"); + std::string host1("encrypted.google.com"); SSLClientCertType type1; std::string private_key_info1, der_cert1; EXPECT_EQ(0, service_->cert_count()); error = service_->GetDomainBoundCert( - origin1, types, &type1, &private_key_info1, &der_cert1, + host1, types, &type1, &private_key_info1, &der_cert1, callback.callback(), &request_handle); EXPECT_EQ(ERR_IO_PENDING, error); EXPECT_TRUE(request_handle.is_active()); @@ -207,11 +207,11 @@ TEST_F(ServerBoundCertServiceTest, StoreCerts) { EXPECT_EQ(OK, error); EXPECT_EQ(1, service_->cert_count()); - std::string origin2("https://www.verisign.com:443"); + std::string host2("www.verisign.com"); SSLClientCertType type2; std::string private_key_info2, der_cert2; error = service_->GetDomainBoundCert( - origin2, types, &type2, &private_key_info2, &der_cert2, + host2, types, &type2, &private_key_info2, &der_cert2, callback.callback(), &request_handle); EXPECT_EQ(ERR_IO_PENDING, error); EXPECT_TRUE(request_handle.is_active()); @@ -219,11 +219,11 @@ TEST_F(ServerBoundCertServiceTest, StoreCerts) { EXPECT_EQ(OK, error); EXPECT_EQ(2, service_->cert_count()); - std::string origin3("https://www.twitter.com:443"); + std::string host3("www.twitter.com"); SSLClientCertType type3; std::string private_key_info3, der_cert3; error = service_->GetDomainBoundCert( - origin3, types, &type3, &private_key_info3, &der_cert3, + host3, types, &type3, &private_key_info3, &der_cert3, callback.callback(), &request_handle); EXPECT_EQ(ERR_IO_PENDING, error); EXPECT_TRUE(request_handle.is_active()); @@ -244,7 +244,7 @@ TEST_F(ServerBoundCertServiceTest, StoreCerts) { // Tests an inflight join. TEST_F(ServerBoundCertServiceTest, InflightJoin) { - std::string origin("https://encrypted.google.com:443"); + std::string host("encrypted.google.com"); int error; std::vector<uint8> types; types.push_back(CLIENT_CERT_ECDSA_SIGN); @@ -260,7 +260,7 @@ TEST_F(ServerBoundCertServiceTest, InflightJoin) { ServerBoundCertService::RequestHandle request_handle2; error = service_->GetDomainBoundCert( - origin, types, &type1, &private_key_info1, &der_cert1, + host, types, &type1, &private_key_info1, &der_cert1, callback1.callback(), &request_handle1); EXPECT_EQ(ERR_IO_PENDING, error); EXPECT_TRUE(request_handle1.is_active()); @@ -268,7 +268,7 @@ TEST_F(ServerBoundCertServiceTest, InflightJoin) { // original request. types.insert(types.begin(), CLIENT_CERT_RSA_SIGN); error = service_->GetDomainBoundCert( - origin, types, &type2, &private_key_info2, &der_cert2, + host, types, &type2, &private_key_info2, &der_cert2, callback2.callback(), &request_handle2); EXPECT_EQ(ERR_IO_PENDING, error); EXPECT_TRUE(request_handle2.is_active()); @@ -286,7 +286,7 @@ TEST_F(ServerBoundCertServiceTest, InflightJoin) { } TEST_F(ServerBoundCertServiceTest, ExtractValuesFromBytesEC) { - std::string origin("https://encrypted.google.com:443"); + std::string host("encrypted.google.com"); SSLClientCertType type; std::string private_key_info, der_cert; int error; @@ -296,7 +296,7 @@ TEST_F(ServerBoundCertServiceTest, ExtractValuesFromBytesEC) { ServerBoundCertService::RequestHandle request_handle; error = service_->GetDomainBoundCert( - origin, types, &type, &private_key_info, &der_cert, callback.callback(), + host, types, &type, &private_key_info, &der_cert, callback.callback(), &request_handle); EXPECT_EQ(ERR_IO_PENDING, error); EXPECT_TRUE(request_handle.is_active()); @@ -324,7 +324,7 @@ TEST_F(ServerBoundCertServiceTest, ExtractValuesFromBytesEC) { // Tests that the callback of a canceled request is never made. TEST_F(ServerBoundCertServiceTest, CancelRequest) { - std::string origin("https://encrypted.google.com:443"); + std::string host("encrypted.google.com"); SSLClientCertType type; std::string private_key_info, der_cert; int error; @@ -332,7 +332,7 @@ TEST_F(ServerBoundCertServiceTest, CancelRequest) { types.push_back(CLIENT_CERT_ECDSA_SIGN); ServerBoundCertService::RequestHandle request_handle; - error = service_->GetDomainBoundCert(origin, + error = service_->GetDomainBoundCert(host, types, &type, &private_key_info, @@ -357,7 +357,7 @@ TEST_F(ServerBoundCertServiceTest, CancelRequest) { // Tests that destructing the RequestHandle cancels the request. TEST_F(ServerBoundCertServiceTest, CancelRequestByHandleDestruction) { - std::string origin("https://encrypted.google.com:443"); + std::string host("encrypted.google.com"); SSLClientCertType type; std::string private_key_info, der_cert; int error; @@ -366,7 +366,7 @@ TEST_F(ServerBoundCertServiceTest, CancelRequestByHandleDestruction) { { ServerBoundCertService::RequestHandle request_handle; - error = service_->GetDomainBoundCert(origin, + error = service_->GetDomainBoundCert(host, types, &type, &private_key_info, @@ -389,7 +389,7 @@ TEST_F(ServerBoundCertServiceTest, CancelRequestByHandleDestruction) { } TEST_F(ServerBoundCertServiceTest, DestructionWithPendingRequest) { - std::string origin("https://encrypted.google.com:443"); + std::string host("encrypted.google.com"); SSLClientCertType type; std::string private_key_info, der_cert; int error; @@ -397,13 +397,13 @@ TEST_F(ServerBoundCertServiceTest, DestructionWithPendingRequest) { types.push_back(CLIENT_CERT_ECDSA_SIGN); ServerBoundCertService::RequestHandle request_handle; - error = service_->GetDomainBoundCert(origin, - types, - &type, - &private_key_info, - &der_cert, - base::Bind(&FailTest), - &request_handle); + error = service_->GetDomainBoundCert(host, + types, + &type, + &private_key_info, + &der_cert, + base::Bind(&FailTest), + &request_handle); EXPECT_EQ(ERR_IO_PENDING, error); EXPECT_TRUE(request_handle.is_active()); @@ -427,25 +427,25 @@ TEST_F(ServerBoundCertServiceTest, SimultaneousCreation) { std::vector<uint8> types; types.push_back(CLIENT_CERT_ECDSA_SIGN); - std::string origin1("https://encrypted.google.com:443"); + std::string host1("encrypted.google.com"); SSLClientCertType type1; std::string private_key_info1, der_cert1; TestCompletionCallback callback1; ServerBoundCertService::RequestHandle request_handle1; - std::string origin2("https://foo.com:443"); + std::string host2("foo.com"); SSLClientCertType type2; std::string private_key_info2, der_cert2; TestCompletionCallback callback2; ServerBoundCertService::RequestHandle request_handle2; - std::string origin3("https://bar.com:443"); + std::string host3("bar.com"); SSLClientCertType type3; std::string private_key_info3, der_cert3; TestCompletionCallback callback3; ServerBoundCertService::RequestHandle request_handle3; - error = service_->GetDomainBoundCert(origin1, + error = service_->GetDomainBoundCert(host1, types, &type1, &private_key_info1, @@ -455,7 +455,7 @@ TEST_F(ServerBoundCertServiceTest, SimultaneousCreation) { EXPECT_EQ(ERR_IO_PENDING, error); EXPECT_TRUE(request_handle1.is_active()); - error = service_->GetDomainBoundCert(origin2, + error = service_->GetDomainBoundCert(host2, types, &type2, &private_key_info2, @@ -465,7 +465,7 @@ TEST_F(ServerBoundCertServiceTest, SimultaneousCreation) { EXPECT_EQ(ERR_IO_PENDING, error); EXPECT_TRUE(request_handle2.is_active()); - error = service_->GetDomainBoundCert(origin3, + error = service_->GetDomainBoundCert(host3, types, &type3, &private_key_info3, @@ -532,7 +532,7 @@ TEST_F(ServerBoundCertServiceTest, Expiration) { SSLClientCertType type1; std::string private_key_info1, der_cert1; error = service_->GetDomainBoundCert( - "https://good", types, &type1, &private_key_info1, &der_cert1, + "good", types, &type1, &private_key_info1, &der_cert1, callback.callback(), &request_handle); EXPECT_EQ(OK, error); EXPECT_FALSE(request_handle.is_active()); @@ -545,7 +545,7 @@ TEST_F(ServerBoundCertServiceTest, Expiration) { SSLClientCertType type2; std::string private_key_info2, der_cert2; error = service_->GetDomainBoundCert( - "https://expired", types, &type2, &private_key_info2, &der_cert2, + "expired", types, &type2, &private_key_info2, &der_cert2, callback.callback(), &request_handle); EXPECT_EQ(OK, error); EXPECT_FALSE(request_handle.is_active()); |