Chromium Code Reviews| 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 #ifndef NET_SOCKET_SSL_CLIENT_SOCKET_H_ | 5 #ifndef NET_SOCKET_SSL_CLIENT_SOCKET_H_ |
| 6 #define NET_SOCKET_SSL_CLIENT_SOCKET_H_ | 6 #define NET_SOCKET_SSL_CLIENT_SOCKET_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| 11 #include "net/base/completion_callback.h" | 11 #include "net/base/completion_callback.h" |
| 12 #include "net/base/load_flags.h" | 12 #include "net/base/load_flags.h" |
| 13 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
| 14 #include "net/socket/ssl_socket.h" | 14 #include "net/socket/ssl_socket.h" |
| 15 #include "net/socket/stream_socket.h" | 15 #include "net/socket/stream_socket.h" |
| 16 | 16 |
| 17 namespace net { | 17 namespace net { |
| 18 | 18 |
| 19 class CertVerifier; | 19 class CertVerifier; |
| 20 class CTVerifier; | 20 class CTVerifier; |
| 21 class HostPortPair; | |
| 22 class ServerBoundCertService; | |
|
wtc
2014/07/31 23:05:24
Sort in alphabetical order.
mshelley
2014/08/02 23:59:15
Done.
| |
| 21 class ChannelIDService; | 23 class ChannelIDService; |
| 22 class SSLCertRequestInfo; | 24 class SSLCertRequestInfo; |
| 23 struct SSLConfig; | 25 struct SSLConfig; |
| 24 class SSLInfo; | 26 class SSLInfo; |
| 25 class TransportSecurityState; | 27 class TransportSecurityState; |
| 26 class X509Certificate; | 28 class X509Certificate; |
| 27 | 29 |
| 28 // This struct groups together several fields which are used by various | 30 // This struct groups together several fields which are used by various |
| 29 // classes related to SSLClientSocket. | 31 // classes related to SSLClientSocket. |
| 30 struct SSLClientSocketContext { | 32 struct SSLClientSocketContext { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 kNextProtoUnsupported = 0, // The server doesn't support NPN. | 76 kNextProtoUnsupported = 0, // The server doesn't support NPN. |
| 75 kNextProtoNegotiated = 1, // We agreed on a protocol. | 77 kNextProtoNegotiated = 1, // We agreed on a protocol. |
| 76 kNextProtoNoOverlap = 2, // No protocols in common. We requested | 78 kNextProtoNoOverlap = 2, // No protocols in common. We requested |
| 77 // the first protocol in our list. | 79 // the first protocol in our list. |
| 78 }; | 80 }; |
| 79 | 81 |
| 80 // StreamSocket: | 82 // StreamSocket: |
| 81 virtual bool WasNpnNegotiated() const OVERRIDE; | 83 virtual bool WasNpnNegotiated() const OVERRIDE; |
| 82 virtual NextProto GetNegotiatedProtocol() const OVERRIDE; | 84 virtual NextProto GetNegotiatedProtocol() const OVERRIDE; |
| 83 | 85 |
| 86 // Formats a unique key for the SSL session cache. This method | |
| 87 // is necessary so that all classes create cache keys in a consistent | |
| 88 // manner. | |
| 89 // TODO(mshelley) This method will be deleted in an upcoming CL when | |
| 90 // it will no longer be necessary to generate a cache key outside of | |
| 91 // an SSLClientSocket. | |
| 92 static std::string CreateSessionCacheKey( | |
| 93 const HostPortPair& host_and_port, | |
| 94 const std::string& ssl_session_cache_shard); | |
| 95 | |
| 96 // Returns true if there is a cache entry in the SSL session cache | |
| 97 // for the cache key of the SSL socket. | |
| 98 // | |
| 99 // The cache key consists of a host and port concatenated with a session | |
| 100 // cache shard. These two strings are passed to the constructor of most | |
| 101 // subclasses of SSLClientSocket. | |
| 102 virtual bool InSessionCache() const = 0; | |
| 103 | |
| 104 // Sets |callback| to be run when the handshake has fully completed. | |
| 105 // For example, in the case of False Start, Connect() will return | |
| 106 // early, before the peer's TLS Finished message has been verified, | |
| 107 // in order to allow the caller to call Write() and send application | |
| 108 // data with the client's Finished message. | |
| 109 // In such situations, |callback| will be invoked sometime after | |
| 110 // Connect() - either during a Write() or Read() call, and before | |
| 111 // invoking the Read() or Write() callback. | |
| 112 // Otherwise, during a traditional TLS connection (i.e. no False | |
| 113 // Start), this will be called right before the Connect() callback | |
| 114 // is called. | |
| 115 // | |
| 116 // Note that it's not valid to mutate this socket during such | |
| 117 // callbacks, including deleting the socket. | |
| 118 // | |
| 119 // TODO(mshelley): Provide additional details about whether or not | |
| 120 // the handshake actually succeeded or not. This can be inferred | |
| 121 // from the result to Connect()/Read()/Write(), but may be useful | |
| 122 // to inform here as well. | |
| 123 virtual void SetHandshakeCompletionCallback( | |
| 124 const base::Closure& callback) = 0; | |
| 125 | |
| 84 // Gets the SSL CertificateRequest info of the socket after Connect failed | 126 // Gets the SSL CertificateRequest info of the socket after Connect failed |
| 85 // with ERR_SSL_CLIENT_AUTH_CERT_NEEDED. | 127 // with ERR_SSL_CLIENT_AUTH_CERT_NEEDED. |
| 86 virtual void GetSSLCertRequestInfo( | 128 virtual void GetSSLCertRequestInfo( |
| 87 SSLCertRequestInfo* cert_request_info) = 0; | 129 SSLCertRequestInfo* cert_request_info) = 0; |
| 88 | 130 |
| 89 // Get the application level protocol that we negotiated with the server. | 131 // Get the application level protocol that we negotiated with the server. |
| 90 // *proto is set to the resulting protocol (n.b. that the string may have | 132 // *proto is set to the resulting protocol (n.b. that the string may have |
| 91 // embedded NULs). | 133 // embedded NULs). |
| 92 // kNextProtoUnsupported: *proto is cleared. | 134 // kNextProtoUnsupported: *proto is cleared. |
| 93 // kNextProtoNegotiated: *proto is set to the negotiated protocol. | 135 // kNextProtoNegotiated: *proto is set to the negotiated protocol. |
| 94 // kNextProtoNoOverlap: *proto is set to the first protocol in the | 136 // kNextProtoNoOverlap: *proto is set to the first protocol in the |
| 95 // supported list. | 137 // supported list. |
| 96 virtual NextProtoStatus GetNextProto(std::string* proto) = 0; | 138 virtual NextProtoStatus GetNextProto(std::string* proto, |
| 139 std::string* serer_protos) = 0; | |
|
wtc
2014/07/31 23:05:24
IMPORTANT: is this part of the CL?
mshelley
2014/08/02 23:59:15
Done.
| |
| 97 | 140 |
| 98 static NextProto NextProtoFromString(const std::string& proto_string); | 141 static NextProto NextProtoFromString(const std::string& proto_string); |
| 99 | 142 |
| 100 static const char* NextProtoToString(NextProto next_proto); | 143 static const char* NextProtoToString(NextProto next_proto); |
| 101 | 144 |
| 102 static const char* NextProtoStatusToString(const NextProtoStatus status); | 145 static const char* NextProtoStatusToString(const NextProtoStatus status); |
| 103 | 146 |
| 104 static bool IgnoreCertError(int error, int load_flags); | 147 static bool IgnoreCertError(int error, int load_flags); |
| 105 | 148 |
| 106 // ClearSessionCache clears the SSL session cache, used to resume SSL | 149 // ClearSessionCache clears the SSL session cache, used to resume SSL |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 bool channel_id_sent_; | 225 bool channel_id_sent_; |
| 183 // True if SCTs were received via a TLS extension. | 226 // True if SCTs were received via a TLS extension. |
| 184 bool signed_cert_timestamps_received_; | 227 bool signed_cert_timestamps_received_; |
| 185 // True if a stapled OCSP response was received. | 228 // True if a stapled OCSP response was received. |
| 186 bool stapled_ocsp_response_received_; | 229 bool stapled_ocsp_response_received_; |
| 187 }; | 230 }; |
| 188 | 231 |
| 189 } // namespace net | 232 } // namespace net |
| 190 | 233 |
| 191 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_H_ | 234 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_H_ |
| OLD | NEW |