diff options
author | rch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-19 17:55:17 +0000 |
---|---|---|
committer | rch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-19 17:55:17 +0000 |
commit | 2d88e7d8b4c382e0ef178c52a87450c226150ef2 (patch) | |
tree | b76d5921ed1ed5c2321570306779aab993f74568 /net/socket | |
parent | f7b2b6a665c130d4ca6b08fdec87b2fad3198f3d (diff) | |
download | chromium_src-2d88e7d8b4c382e0ef178c52a87450c226150ef2.zip chromium_src-2d88e7d8b4c382e0ef178c52a87450c226150ef2.tar.gz chromium_src-2d88e7d8b4c382e0ef178c52a87450c226150ef2.tar.bz2 |
Change SpdySession::GetSSLInfo to get the SSLInfo from the underlying socket
even if the session is not "secure". This required refactoring StreamSocket
to add WasNpnNegotiated() and GetSSLInfo() methods.
This allows for a change to SpdySession::GetSSLInfo to accurately return the correct SSLInfo in the case of SPDY Proxy sessions.
BUG=134690
TEST=\*DoNotUseSpdySessionIfCertDoesNotMatch\*
Review URL: https://chromiumcodereview.appspot.com/10690122
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147479 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket')
29 files changed, 180 insertions, 45 deletions
diff --git a/net/socket/buffered_write_stream_socket.cc b/net/socket/buffered_write_stream_socket.cc index ed7ce2e..3119985 100644 --- a/net/socket/buffered_write_stream_socket.cc +++ b/net/socket/buffered_write_stream_socket.cc @@ -119,10 +119,18 @@ base::TimeDelta BufferedWriteStreamSocket::GetConnectTimeMicros() const { return wrapped_socket_->GetConnectTimeMicros(); } +bool BufferedWriteStreamSocket::WasNpnNegotiated() const { + return wrapped_socket_->WasNpnNegotiated(); +} + NextProto BufferedWriteStreamSocket::GetNegotiatedProtocol() const { return wrapped_socket_->GetNegotiatedProtocol(); } +bool BufferedWriteStreamSocket::GetSSLInfo(SSLInfo* ssl_info) { + return wrapped_socket_->GetSSLInfo(ssl_info); +} + void BufferedWriteStreamSocket::DoDelayedWrite() { int result = wrapped_socket_->Write( io_buffer_, io_buffer_->RemainingCapacity(), diff --git a/net/socket/buffered_write_stream_socket.h b/net/socket/buffered_write_stream_socket.h index 6d41c07..5651d2a 100644 --- a/net/socket/buffered_write_stream_socket.h +++ b/net/socket/buffered_write_stream_socket.h @@ -58,7 +58,9 @@ class NET_EXPORT_PRIVATE BufferedWriteStreamSocket : public StreamSocket { virtual bool UsingTCPFastOpen() const OVERRIDE; virtual int64 NumBytesRead() const OVERRIDE; virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; + virtual bool WasNpnNegotiated() const OVERRIDE; virtual NextProto GetNegotiatedProtocol() const OVERRIDE; + virtual bool GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; private: void DoDelayedWrite(); diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc index b53c775..363010a 100644 --- a/net/socket/client_socket_pool_base_unittest.cc +++ b/net/socket/client_socket_pool_base_unittest.cc @@ -116,9 +116,15 @@ class MockClientSocket : public StreamSocket { base::TimeDelta::FromMicroseconds(10); return kDummyConnectTimeMicros; // Dummy value. } + virtual bool WasNpnNegotiated() const { + return false; + } virtual NextProto GetNegotiatedProtocol() const { return kProtoUnknown; } + virtual bool GetSSLInfo(SSLInfo* ssl_info) { + return false; + } private: bool connected_; diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc index ef6d38c..ff66830 100644 --- a/net/socket/socket_test_util.cc +++ b/net/socket/socket_test_util.cc @@ -704,10 +704,6 @@ const BoundNetLog& MockClientSocket::NetLog() const { return net_log_; } -void MockClientSocket::GetSSLInfo(SSLInfo* ssl_info) { - NOTREACHED(); -} - void MockClientSocket::GetSSLCertRequestInfo( SSLCertRequestInfo* cert_request_info) { } @@ -872,6 +868,14 @@ base::TimeDelta MockTCPClientSocket::GetConnectTimeMicros() const { return kTestingConnectTimeMicros; } +bool MockTCPClientSocket::WasNpnNegotiated() const { + return false; +} + +bool MockTCPClientSocket::GetSSLInfo(SSLInfo* ssl_info) { + return false; +} + void MockTCPClientSocket::OnReadComplete(const MockRead& data) { // There must be a read pending. DCHECK(pending_buf_); @@ -1071,6 +1075,14 @@ base::TimeDelta DeterministicMockTCPClientSocket::GetConnectTimeMicros() const { return base::TimeDelta::FromMicroseconds(-1); } +bool DeterministicMockTCPClientSocket::WasNpnNegotiated() const { + return false; +} + +bool DeterministicMockTCPClientSocket::GetSSLInfo(SSLInfo* ssl_info) { + return false; +} + void DeterministicMockTCPClientSocket::OnReadComplete(const MockRead& data) {} // static @@ -1158,11 +1170,12 @@ base::TimeDelta MockSSLClientSocket::GetConnectTimeMicros() const { return base::TimeDelta::FromMicroseconds(-1); } -void MockSSLClientSocket::GetSSLInfo(SSLInfo* ssl_info) { +bool MockSSLClientSocket::GetSSLInfo(SSLInfo* ssl_info) { ssl_info->Reset(); ssl_info->cert = data_->cert; ssl_info->client_cert_sent = data_->client_cert_sent; ssl_info->channel_id_sent = data_->channel_id_sent; + return true; } void MockSSLClientSocket::GetSSLCertRequestInfo( @@ -1184,17 +1197,17 @@ SSLClientSocket::NextProtoStatus MockSSLClientSocket::GetNextProto( return data_->next_proto_status; } -bool MockSSLClientSocket::was_npn_negotiated() const { - if (is_npn_state_set_) - return new_npn_value_; - return data_->was_npn_negotiated; -} - bool MockSSLClientSocket::set_was_npn_negotiated(bool negotiated) { is_npn_state_set_ = true; return new_npn_value_ = negotiated; } +bool MockSSLClientSocket::WasNpnNegotiated() const { + if (is_npn_state_set_) + return new_npn_value_; + return data_->was_npn_negotiated; +} + NextProto MockSSLClientSocket::GetNegotiatedProtocol() const { if (is_protocol_negotiated_set_) return protocol_negotiated_; diff --git a/net/socket/socket_test_util.h b/net/socket/socket_test_util.h index 384452c..0c7e4cf 100644 --- a/net/socket/socket_test_util.h +++ b/net/socket/socket_test_util.h @@ -595,7 +595,6 @@ class MockClientSocket : public SSLClientSocket { virtual void SetOmniboxSpeculation() OVERRIDE {} // SSLClientSocket implementation. - virtual void GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; virtual void GetSSLCertRequestInfo( SSLCertRequestInfo* cert_request_info) OVERRIDE; virtual int ExportKeyingMaterial(const base::StringPiece& label, @@ -647,6 +646,8 @@ class MockTCPClientSocket : public MockClientSocket, public AsyncSocket { virtual bool UsingTCPFastOpen() const OVERRIDE; virtual int64 NumBytesRead() const OVERRIDE; virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; + virtual bool WasNpnNegotiated() const OVERRIDE; + virtual bool GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; // AsyncSocket: virtual void OnReadComplete(const MockRead& data) OVERRIDE; @@ -705,6 +706,8 @@ class DeterministicMockTCPClientSocket virtual bool UsingTCPFastOpen() const OVERRIDE; virtual int64 NumBytesRead() const OVERRIDE; virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; + virtual bool WasNpnNegotiated() const OVERRIDE; + virtual bool GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; // AsyncSocket: virtual void OnReadComplete(const MockRead& data) OVERRIDE; @@ -748,14 +751,15 @@ class MockSSLClientSocket : public MockClientSocket, public AsyncSocket { virtual int64 NumBytesRead() const OVERRIDE; virtual int GetPeerAddress(IPEndPoint* address) const OVERRIDE; virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; + virtual bool WasNpnNegotiated() const OVERRIDE; + virtual bool GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; // SSLClientSocket implementation. - virtual void GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; virtual void GetSSLCertRequestInfo( SSLCertRequestInfo* cert_request_info) OVERRIDE; virtual NextProtoStatus GetNextProto(std::string* proto, std::string* server_protos) OVERRIDE; - virtual bool was_npn_negotiated() const OVERRIDE; + //virtual bool was_npn_negotiated() const OVERRIDE; virtual bool set_was_npn_negotiated(bool negotiated) OVERRIDE; virtual void set_protocol_negotiated( NextProto protocol_negotiated) OVERRIDE; diff --git a/net/socket/socks5_client_socket.cc b/net/socket/socks5_client_socket.cc index 1b020d7..409968c 100644 --- a/net/socket/socks5_client_socket.cc +++ b/net/socket/socks5_client_socket.cc @@ -158,6 +158,14 @@ base::TimeDelta SOCKS5ClientSocket::GetConnectTimeMicros() const { return base::TimeDelta::FromMicroseconds(-1); } +bool SOCKS5ClientSocket::WasNpnNegotiated() const { + if (transport_.get() && transport_->socket()) { + return transport_->socket()->WasNpnNegotiated(); + } + NOTREACHED(); + return false; +} + NextProto SOCKS5ClientSocket::GetNegotiatedProtocol() const { if (transport_.get() && transport_->socket()) { return transport_->socket()->GetNegotiatedProtocol(); @@ -166,6 +174,15 @@ NextProto SOCKS5ClientSocket::GetNegotiatedProtocol() const { return kProtoUnknown; } +bool SOCKS5ClientSocket::GetSSLInfo(SSLInfo* ssl_info) { + if (transport_.get() && transport_->socket()) { + return transport_->socket()->GetSSLInfo(ssl_info); + } + NOTREACHED(); + return false; + +} + // Read is called by the transport layer above to read. This can only be done // if the SOCKS handshake is complete. int SOCKS5ClientSocket::Read(IOBuffer* buf, int buf_len, diff --git a/net/socket/socks5_client_socket.h b/net/socket/socks5_client_socket.h index fa76be2..38810df 100644 --- a/net/socket/socks5_client_socket.h +++ b/net/socket/socks5_client_socket.h @@ -61,7 +61,9 @@ class NET_EXPORT_PRIVATE SOCKS5ClientSocket : public StreamSocket { virtual bool UsingTCPFastOpen() const OVERRIDE; virtual int64 NumBytesRead() const OVERRIDE; virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; + virtual bool WasNpnNegotiated() const OVERRIDE; virtual NextProto GetNegotiatedProtocol() const OVERRIDE; + virtual bool GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; // Socket implementation. virtual int Read(IOBuffer* buf, diff --git a/net/socket/socks_client_socket.cc b/net/socket/socks_client_socket.cc index 6776b71..2842fd1 100644 --- a/net/socket/socks_client_socket.cc +++ b/net/socket/socks_client_socket.cc @@ -180,6 +180,14 @@ base::TimeDelta SOCKSClientSocket::GetConnectTimeMicros() const { return base::TimeDelta::FromMicroseconds(-1); } +bool SOCKSClientSocket::WasNpnNegotiated() const { + if (transport_.get() && transport_->socket()) { + return transport_->socket()->WasNpnNegotiated(); + } + NOTREACHED(); + return false; +} + NextProto SOCKSClientSocket::GetNegotiatedProtocol() const { if (transport_.get() && transport_->socket()) { return transport_->socket()->GetNegotiatedProtocol(); @@ -188,6 +196,15 @@ NextProto SOCKSClientSocket::GetNegotiatedProtocol() const { return kProtoUnknown; } +bool SOCKSClientSocket::GetSSLInfo(SSLInfo* ssl_info) { + if (transport_.get() && transport_->socket()) { + return transport_->socket()->GetSSLInfo(ssl_info); + } + NOTREACHED(); + return false; + +} + // Read is called by the transport layer above to read. This can only be done // if the SOCKS handshake is complete. int SOCKSClientSocket::Read(IOBuffer* buf, int buf_len, diff --git a/net/socket/socks_client_socket.h b/net/socket/socks_client_socket.h index 3f0a086..6e74409 100644 --- a/net/socket/socks_client_socket.h +++ b/net/socket/socks_client_socket.h @@ -58,7 +58,9 @@ class NET_EXPORT_PRIVATE SOCKSClientSocket : public StreamSocket { virtual bool UsingTCPFastOpen() const OVERRIDE; virtual int64 NumBytesRead() const OVERRIDE; virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; + virtual bool WasNpnNegotiated() const OVERRIDE; virtual NextProto GetNegotiatedProtocol() const OVERRIDE; + virtual bool GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; // Socket implementation. virtual int Read(IOBuffer* buf, diff --git a/net/socket/ssl_client_socket.cc b/net/socket/ssl_client_socket.cc index 6bcc96e..7f23258 100644 --- a/net/socket/ssl_client_socket.cc +++ b/net/socket/ssl_client_socket.cc @@ -77,6 +77,10 @@ std::string SSLClientSocket::ServerProtosToString( return JoinString(server_protos_with_commas, ','); } +bool SSLClientSocket::WasNpnNegotiated() const { + return was_npn_negotiated_; +} + NextProto SSLClientSocket::GetNegotiatedProtocol() const { return protocol_negotiated_; } @@ -100,10 +104,6 @@ bool SSLClientSocket::IgnoreCertError(int error, int load_flags) { return false; } -bool SSLClientSocket::was_npn_negotiated() const { - return was_npn_negotiated_; -} - bool SSLClientSocket::set_was_npn_negotiated(bool negotiated) { return was_npn_negotiated_ = negotiated; } diff --git a/net/socket/ssl_client_socket.h b/net/socket/ssl_client_socket.h index 6748e6e..41ee087 100644 --- a/net/socket/ssl_client_socket.h +++ b/net/socket/ssl_client_socket.h @@ -69,20 +69,15 @@ class NET_EXPORT SSLClientSocket : public SSLSocket { // the first protocol in our list. }; - // Gets the SSL connection information of the socket. - // - // TODO(sergeyu): Move this method to the SSLSocket interface and - // implemented in SSLServerSocket too. - virtual void GetSSLInfo(SSLInfo* ssl_info) = 0; + // StreamSocket: + virtual bool WasNpnNegotiated() const OVERRIDE; + virtual NextProto GetNegotiatedProtocol() const OVERRIDE; // Gets the SSL CertificateRequest info of the socket after Connect failed // with ERR_SSL_CLIENT_AUTH_CERT_NEEDED. virtual void GetSSLCertRequestInfo( SSLCertRequestInfo* cert_request_info) = 0; - // StreamSocket: - virtual NextProto GetNegotiatedProtocol() const OVERRIDE; - // Get the application level protocol that we negotiated with the server. // *proto is set to the resulting protocol (n.b. that the string may have // embedded NULs). @@ -110,8 +105,6 @@ class NET_EXPORT SSLClientSocket : public SSLSocket { // sessions. static void ClearSessionCache(); - virtual bool was_npn_negotiated() const; - virtual bool set_was_npn_negotiated(bool negotiated); virtual bool was_spdy_negotiated() const; diff --git a/net/socket/ssl_client_socket_mac.cc b/net/socket/ssl_client_socket_mac.cc index bdca223..ff43849 100644 --- a/net/socket/ssl_client_socket_mac.cc +++ b/net/socket/ssl_client_socket_mac.cc @@ -715,10 +715,10 @@ bool SSLClientSocketMac::SetSendBufferSize(int32 size) { return transport_->socket()->SetSendBufferSize(size); } -void SSLClientSocketMac::GetSSLInfo(SSLInfo* ssl_info) { +bool SSLClientSocketMac::GetSSLInfo(SSLInfo* ssl_info) { ssl_info->Reset(); if (!server_cert_) - return; + return false; ssl_info->cert = server_cert_verify_result_.verified_cert; ssl_info->cert_status = server_cert_verify_result_.cert_status; @@ -741,6 +741,8 @@ void SSLClientSocketMac::GetSSLInfo(SSLInfo* ssl_info) { if (ssl_config_.version_fallback) ssl_info->connection_status |= SSL_CONNECTION_VERSION_FALLBACK; + + return true; } void SSLClientSocketMac::GetSSLCertRequestInfo( diff --git a/net/socket/ssl_client_socket_mac.h b/net/socket/ssl_client_socket_mac.h index f923f3a..d7ced45 100644 --- a/net/socket/ssl_client_socket_mac.h +++ b/net/socket/ssl_client_socket_mac.h @@ -40,7 +40,6 @@ class SSLClientSocketMac : public SSLClientSocket { virtual ~SSLClientSocketMac(); // SSLClientSocket implementation. - virtual void GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; virtual void GetSSLCertRequestInfo( SSLCertRequestInfo* cert_request_info) OVERRIDE; virtual int ExportKeyingMaterial(const base::StringPiece& label, @@ -66,6 +65,7 @@ class SSLClientSocketMac : public SSLClientSocket { virtual bool UsingTCPFastOpen() const OVERRIDE; virtual int64 NumBytesRead() const OVERRIDE; virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; + virtual bool GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; // Socket implementation. virtual int Read(IOBuffer* buf, diff --git a/net/socket/ssl_client_socket_nss.cc b/net/socket/ssl_client_socket_nss.cc index 0c3ea4e..9d0eea2 100644 --- a/net/socket/ssl_client_socket_nss.cc +++ b/net/socket/ssl_client_socket_nss.cc @@ -2750,12 +2750,12 @@ void SSLClientSocket::ClearSessionCache() { SSL_ClearSessionCache(); } -void SSLClientSocketNSS::GetSSLInfo(SSLInfo* ssl_info) { +bool SSLClientSocketNSS::GetSSLInfo(SSLInfo* ssl_info) { EnterFunction(""); ssl_info->Reset(); if (core_->state().server_cert_chain.empty() || !core_->state().server_cert_chain[0]) { - return; + return false; } ssl_info->cert_status = server_cert_verify_result_.cert_status; @@ -2791,6 +2791,7 @@ void SSLClientSocketNSS::GetSSLInfo(SSLInfo* ssl_info) { SSLInfo::HANDSHAKE_RESUME : SSLInfo::HANDSHAKE_FULL; LeaveFunction(""); + return true; } void SSLClientSocketNSS::GetSSLCertRequestInfo( diff --git a/net/socket/ssl_client_socket_nss.h b/net/socket/ssl_client_socket_nss.h index 79a72fe..434b7c6 100644 --- a/net/socket/ssl_client_socket_nss.h +++ b/net/socket/ssl_client_socket_nss.h @@ -66,7 +66,6 @@ class SSLClientSocketNSS : public SSLClientSocket { virtual ~SSLClientSocketNSS(); // SSLClientSocket implementation. - virtual void GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; virtual void GetSSLCertRequestInfo( SSLCertRequestInfo* cert_request_info) OVERRIDE; virtual int ExportKeyingMaterial(const base::StringPiece& label, @@ -91,6 +90,7 @@ class SSLClientSocketNSS : public SSLClientSocket { virtual bool UsingTCPFastOpen() const OVERRIDE; virtual int64 NumBytesRead() const OVERRIDE; virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; + virtual bool GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; // Socket implementation. virtual int Read(IOBuffer* buf, diff --git a/net/socket/ssl_client_socket_openssl.cc b/net/socket/ssl_client_socket_openssl.cc index e350ded..85d0d65 100644 --- a/net/socket/ssl_client_socket_openssl.cc +++ b/net/socket/ssl_client_socket_openssl.cc @@ -591,10 +591,10 @@ int SSLClientSocketOpenSSL::ClientCertRequestCallback(SSL* ssl, // SSLClientSocket methods -void SSLClientSocketOpenSSL::GetSSLInfo(SSLInfo* ssl_info) { +bool SSLClientSocketOpenSSL::GetSSLInfo(SSLInfo* ssl_info) { ssl_info->Reset(); if (!server_cert_) - return; + return false; ssl_info->cert = server_cert_verify_result_.verified_cert; ssl_info->cert_status = server_cert_verify_result_.cert_status; @@ -631,6 +631,7 @@ void SSLClientSocketOpenSSL::GetSSLInfo(SSLInfo* ssl_info) { << SSLConnectionStatusToCompression(ssl_info->connection_status) << " version = " << SSLConnectionStatusToVersion(ssl_info->connection_status); + return true; } void SSLClientSocketOpenSSL::GetSSLCertRequestInfo( diff --git a/net/socket/ssl_client_socket_openssl.h b/net/socket/ssl_client_socket_openssl.h index 129d30e..d113f82 100644 --- a/net/socket/ssl_client_socket_openssl.h +++ b/net/socket/ssl_client_socket_openssl.h @@ -55,7 +55,6 @@ class SSLClientSocketOpenSSL : public SSLClientSocket { const unsigned char* in, unsigned int inlen); // SSLClientSocket implementation. - virtual void GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; virtual void GetSSLCertRequestInfo( SSLCertRequestInfo* cert_request_info) OVERRIDE; virtual int ExportKeyingMaterial(const base::StringPiece& label, @@ -81,6 +80,7 @@ class SSLClientSocketOpenSSL : public SSLClientSocket { virtual bool UsingTCPFastOpen() const OVERRIDE; virtual int64 NumBytesRead() const OVERRIDE; virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; + virtual bool GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; // Socket implementation. virtual int Read(IOBuffer* buf, int buf_len, diff --git a/net/socket/ssl_client_socket_pool_unittest.cc b/net/socket/ssl_client_socket_pool_unittest.cc index 34b9951..1dd9e55 100644 --- a/net/socket/ssl_client_socket_pool_unittest.cc +++ b/net/socket/ssl_client_socket_pool_unittest.cc @@ -330,7 +330,7 @@ TEST_F(SSLClientSocketPoolTest, DirectWithNPN) { EXPECT_TRUE(handle.is_initialized()); EXPECT_TRUE(handle.socket()); SSLClientSocket* ssl_socket = static_cast<SSLClientSocket*>(handle.socket()); - EXPECT_TRUE(ssl_socket->was_npn_negotiated()); + EXPECT_TRUE(ssl_socket->WasNpnNegotiated()); } TEST_F(SSLClientSocketPoolTest, DirectNoSPDY) { @@ -382,7 +382,7 @@ TEST_F(SSLClientSocketPoolTest, DirectGotSPDY) { EXPECT_TRUE(handle.socket()); SSLClientSocket* ssl_socket = static_cast<SSLClientSocket*>(handle.socket()); - EXPECT_TRUE(ssl_socket->was_npn_negotiated()); + EXPECT_TRUE(ssl_socket->WasNpnNegotiated()); std::string proto; std::string server_protos; ssl_socket->GetNextProto(&proto, &server_protos); @@ -414,7 +414,7 @@ TEST_F(SSLClientSocketPoolTest, DirectGotBonusSPDY) { EXPECT_TRUE(handle.socket()); SSLClientSocket* ssl_socket = static_cast<SSLClientSocket*>(handle.socket()); - EXPECT_TRUE(ssl_socket->was_npn_negotiated()); + EXPECT_TRUE(ssl_socket->WasNpnNegotiated()); std::string proto; std::string server_protos; ssl_socket->GetNextProto(&proto, &server_protos); @@ -714,7 +714,7 @@ TEST_F(SSLClientSocketPoolTest, IPPooling) { EXPECT_TRUE(handle->socket()); SSLClientSocket* ssl_socket = static_cast<SSLClientSocket*>(handle->socket()); - EXPECT_TRUE(ssl_socket->was_npn_negotiated()); + EXPECT_TRUE(ssl_socket->WasNpnNegotiated()); std::string proto; std::string server_protos; ssl_socket->GetNextProto(&proto, &server_protos); @@ -793,7 +793,7 @@ void SSLClientSocketPoolTest::TestIPPoolingDisabled( EXPECT_TRUE(handle->socket()); SSLClientSocket* ssl_socket = static_cast<SSLClientSocket*>(handle->socket()); - EXPECT_TRUE(ssl_socket->was_npn_negotiated()); + EXPECT_TRUE(ssl_socket->WasNpnNegotiated()); std::string proto; std::string server_protos; ssl_socket->GetNextProto(&proto, &server_protos); diff --git a/net/socket/ssl_client_socket_win.cc b/net/socket/ssl_client_socket_win.cc index 3edad6b..d997380 100644 --- a/net/socket/ssl_client_socket_win.cc +++ b/net/socket/ssl_client_socket_win.cc @@ -404,10 +404,10 @@ SSLClientSocketWin::~SSLClientSocketWin() { Disconnect(); } -void SSLClientSocketWin::GetSSLInfo(SSLInfo* ssl_info) { +bool SSLClientSocketWin::GetSSLInfo(SSLInfo* ssl_info) { ssl_info->Reset(); if (!server_cert_) - return; + return false; ssl_info->cert = server_cert_verify_result_.verified_cert; ssl_info->cert_status = server_cert_verify_result_.cert_status; @@ -448,6 +448,8 @@ void SSLClientSocketWin::GetSSLInfo(SSLInfo* ssl_info) { if (ssl_config_.version_fallback) ssl_info->connection_status |= SSL_CONNECTION_VERSION_FALLBACK; + + return true; } void SSLClientSocketWin::GetSSLCertRequestInfo( diff --git a/net/socket/ssl_client_socket_win.h b/net/socket/ssl_client_socket_win.h index 9013a9e..f5c0a4d 100644 --- a/net/socket/ssl_client_socket_win.h +++ b/net/socket/ssl_client_socket_win.h @@ -45,7 +45,6 @@ class SSLClientSocketWin : public SSLClientSocket { ~SSLClientSocketWin(); // SSLClientSocket implementation. - virtual void GetSSLInfo(SSLInfo* ssl_info); virtual void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info); virtual int ExportKeyingMaterial(const base::StringPiece& label, bool has_context, @@ -70,6 +69,7 @@ class SSLClientSocketWin : public SSLClientSocket { virtual bool UsingTCPFastOpen() const OVERRIDE; virtual int64 NumBytesRead() const OVERRIDE; virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; + virtual bool GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; // Socket implementation. virtual int Read(IOBuffer* buf, int buf_len, diff --git a/net/socket/ssl_server_socket_nss.cc b/net/socket/ssl_server_socket_nss.cc index 35ccdd6..a43dbfe 100644 --- a/net/socket/ssl_server_socket_nss.cc +++ b/net/socket/ssl_server_socket_nss.cc @@ -279,11 +279,20 @@ base::TimeDelta SSLServerSocketNSS::GetConnectTimeMicros() const { return transport_socket_->GetConnectTimeMicros(); } +bool SSLServerSocketNSS::WasNpnNegotiated() const { + return false; +} + NextProto SSLServerSocketNSS::GetNegotiatedProtocol() const { // NPN is not supported by this class. return kProtoUnknown; } +bool SSLServerSocketNSS::GetSSLInfo(SSLInfo* ssl_info) { + NOTIMPLEMENTED(); + return false; +} + int SSLServerSocketNSS::InitializeSSLOptions() { // Transport connected, now hook it up to nss // TODO(port): specify rx and tx buffer sizes separately diff --git a/net/socket/ssl_server_socket_nss.h b/net/socket/ssl_server_socket_nss.h index e7da5ac..ba55649 100644 --- a/net/socket/ssl_server_socket_nss.h +++ b/net/socket/ssl_server_socket_nss.h @@ -60,7 +60,9 @@ class SSLServerSocketNSS : public SSLServerSocket { virtual bool UsingTCPFastOpen() const OVERRIDE; virtual int64 NumBytesRead() const OVERRIDE; virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; + virtual bool WasNpnNegotiated() const OVERRIDE; virtual NextProto GetNegotiatedProtocol() const OVERRIDE; + virtual bool GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; private: enum State { diff --git a/net/socket/ssl_server_socket_unittest.cc b/net/socket/ssl_server_socket_unittest.cc index 03a6db0..f93d7c6 100644 --- a/net/socket/ssl_server_socket_unittest.cc +++ b/net/socket/ssl_server_socket_unittest.cc @@ -236,10 +236,18 @@ class FakeSocket : public StreamSocket { return base::TimeDelta::FromMicroseconds(-1); } + virtual bool WasNpnNegotiated() const { + return false; + } + virtual NextProto GetNegotiatedProtocol() const { return kProtoUnknown; } + virtual bool GetSSLInfo(SSLInfo* ssl_info) { + return false; + } + private: net::BoundNetLog net_log_; FakeDataChannel* incoming_; diff --git a/net/socket/stream_socket.h b/net/socket/stream_socket.h index a513099..9a7d153 100644 --- a/net/socket/stream_socket.h +++ b/net/socket/stream_socket.h @@ -14,6 +14,7 @@ namespace net { class AddressList; class IPEndPoint; +class SSLInfo; class NET_EXPORT_PRIVATE StreamSocket : public Socket { public: @@ -86,10 +87,17 @@ class NET_EXPORT_PRIVATE StreamSocket : public Socket { // Returns the connection setup time of this socket. virtual base::TimeDelta GetConnectTimeMicros() const = 0; + // Returns true if NPN was negotiated during the connection of this socket. + virtual bool WasNpnNegotiated() const = 0; + // Returns the protocol negotiated via NPN for this socket, or // kProtoUnknown will be returned if NPN is not applicable. virtual NextProto GetNegotiatedProtocol() const = 0; + // Gets the SSL connection information of the socket. Returns false if + // SSL was not used by this socket. + virtual bool GetSSLInfo(SSLInfo* ssl_info) = 0; + protected: // The following class is only used to gather statistics about the history of // a socket. It is only instantiated and used in basic sockets, such as diff --git a/net/socket/tcp_client_socket_libevent.cc b/net/socket/tcp_client_socket_libevent.cc index d139a54..e54eb1e 100644 --- a/net/socket/tcp_client_socket_libevent.cc +++ b/net/socket/tcp_client_socket_libevent.cc @@ -758,8 +758,16 @@ base::TimeDelta TCPClientSocketLibevent::GetConnectTimeMicros() const { return connect_time_micros_; } +bool TCPClientSocketLibevent::WasNpnNegotiated() const { + return false; +} + NextProto TCPClientSocketLibevent::GetNegotiatedProtocol() const { return kProtoUnknown; } +bool TCPClientSocketLibevent::GetSSLInfo(SSLInfo* ssl_info) { + return false; +} + } // namespace net diff --git a/net/socket/tcp_client_socket_libevent.h b/net/socket/tcp_client_socket_libevent.h index 653ffe3..8ddb61b 100644 --- a/net/socket/tcp_client_socket_libevent.h +++ b/net/socket/tcp_client_socket_libevent.h @@ -55,7 +55,9 @@ class NET_EXPORT_PRIVATE TCPClientSocketLibevent : public StreamSocket, virtual bool UsingTCPFastOpen() const OVERRIDE; virtual int64 NumBytesRead() const OVERRIDE; virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; + virtual bool WasNpnNegotiated() const OVERRIDE; virtual NextProto GetNegotiatedProtocol() const OVERRIDE; + virtual bool GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; // Socket implementation. // Multiple outstanding requests are not supported. diff --git a/net/socket/tcp_client_socket_win.cc b/net/socket/tcp_client_socket_win.cc index aed2adb..74fa99e 100644 --- a/net/socket/tcp_client_socket_win.cc +++ b/net/socket/tcp_client_socket_win.cc @@ -684,10 +684,18 @@ base::TimeDelta TCPClientSocketWin::GetConnectTimeMicros() const { return connect_time_micros_; } +bool TCPClientSocketWin::WasNpnNegotiated() const { + return false; +} + NextProto TCPClientSocketWin::GetNegotiatedProtocol() const { return kProtoUnknown; } +bool TCPClientSocketWin::GetSSLInfo(SSLInfo* ssl_info) { + return false; +} + int TCPClientSocketWin::Read(IOBuffer* buf, int buf_len, const CompletionCallback& callback) { diff --git a/net/socket/tcp_client_socket_win.h b/net/socket/tcp_client_socket_win.h index 1ca957f..9e95aae 100644 --- a/net/socket/tcp_client_socket_win.h +++ b/net/socket/tcp_client_socket_win.h @@ -54,7 +54,9 @@ class NET_EXPORT TCPClientSocketWin : public StreamSocket, virtual bool UsingTCPFastOpen() const; virtual int64 NumBytesRead() const; virtual base::TimeDelta GetConnectTimeMicros() const; + virtual bool WasNpnNegotiated() const OVERRIDE; virtual NextProto GetNegotiatedProtocol() const OVERRIDE; + virtual bool GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; // Socket implementation. // Multiple outstanding requests are not supported. diff --git a/net/socket/transport_client_socket_pool_unittest.cc b/net/socket/transport_client_socket_pool_unittest.cc index 93e7d11..d7ff4e6 100644 --- a/net/socket/transport_client_socket_pool_unittest.cc +++ b/net/socket/transport_client_socket_pool_unittest.cc @@ -89,9 +89,15 @@ class MockClientSocket : public StreamSocket { virtual base::TimeDelta GetConnectTimeMicros() const { return base::TimeDelta::FromMicroseconds(-1); } + virtual bool WasNpnNegotiated() const { + return false; + } virtual NextProto GetNegotiatedProtocol() const { return kProtoUnknown; } + virtual bool GetSSLInfo(SSLInfo* ssl_info) { + return false; + } // Socket implementation. virtual int Read(IOBuffer* buf, int buf_len, @@ -146,9 +152,15 @@ class MockFailingClientSocket : public StreamSocket { virtual base::TimeDelta GetConnectTimeMicros() const { return base::TimeDelta::FromMicroseconds(-1); } + virtual bool WasNpnNegotiated() const { + return false; + } virtual NextProto GetNegotiatedProtocol() const { return kProtoUnknown; } + virtual bool GetSSLInfo(SSLInfo* ssl_info) { + return false; + } // Socket implementation. virtual int Read(IOBuffer* buf, int buf_len, @@ -228,9 +240,15 @@ class MockPendingClientSocket : public StreamSocket { virtual base::TimeDelta GetConnectTimeMicros() const { return base::TimeDelta::FromMicroseconds(-1); } + virtual bool WasNpnNegotiated() const { + return false; + } virtual NextProto GetNegotiatedProtocol() const { return kProtoUnknown; } + virtual bool GetSSLInfo(SSLInfo* ssl_info) { + return false; + } // Socket implementation. virtual int Read(IOBuffer* buf, int buf_len, |