OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_OPENSSL_H_ | 5 #ifndef NET_SOCKET_SSL_CLIENT_SOCKET_OPENSSL_H_ |
6 #define NET_SOCKET_SSL_CLIENT_SOCKET_OPENSSL_H_ | 6 #define NET_SOCKET_SSL_CLIENT_SOCKET_OPENSSL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "net/base/cert_verify_result.h" | 10 #include "net/base/cert_verify_result.h" |
11 #include "net/base/completion_callback.h" | 11 #include "net/base/completion_callback.h" |
12 #include "net/base/io_buffer.h" | 12 #include "net/base/io_buffer.h" |
13 #include "net/base/ssl_config_service.h" | 13 #include "net/base/ssl_config_service.h" |
14 #include "net/socket/ssl_client_socket.h" | 14 #include "net/socket/ssl_client_socket.h" |
15 #include "net/socket/client_socket_handle.h" | 15 #include "net/socket/client_socket_handle.h" |
16 | 16 |
17 typedef struct bio_st BIO; | 17 typedef struct bio_st BIO; |
18 typedef struct evp_pkey_st EVP_PKEY; | |
18 typedef struct ssl_st SSL; | 19 typedef struct ssl_st SSL; |
20 typedef struct x509_st X509; | |
19 | 21 |
20 namespace net { | 22 namespace net { |
21 | 23 |
22 class CertVerifier; | 24 class CertVerifier; |
23 class SSLCertRequestInfo; | 25 class SSLCertRequestInfo; |
24 class SSLConfig; | 26 class SSLConfig; |
25 class SSLInfo; | 27 class SSLInfo; |
26 | 28 |
27 // An SSL client socket implemented with OpenSSL. | 29 // An SSL client socket implemented with OpenSSL. |
28 class SSLClientSocketOpenSSL : public SSLClientSocket { | 30 class SSLClientSocketOpenSSL : public SSLClientSocket { |
29 public: | 31 public: |
30 // Takes ownership of the transport_socket, which may already be connected. | 32 // Takes ownership of the transport_socket, which may already be connected. |
31 // The given hostname will be compared with the name(s) in the server's | 33 // The given hostname will be compared with the name(s) in the server's |
32 // certificate during the SSL handshake. ssl_config specifies the SSL | 34 // certificate during the SSL handshake. ssl_config specifies the SSL |
33 // settings. | 35 // settings. |
34 SSLClientSocketOpenSSL(ClientSocketHandle* transport_socket, | 36 SSLClientSocketOpenSSL(ClientSocketHandle* transport_socket, |
35 const HostPortPair& host_and_port, | 37 const HostPortPair& host_and_port, |
36 const SSLConfig& ssl_config); | 38 const SSLConfig& ssl_config); |
37 ~SSLClientSocketOpenSSL(); | 39 ~SSLClientSocketOpenSSL(); |
38 | 40 |
39 const HostPortPair& host_and_port() const { return host_and_port_; } | 41 const HostPortPair& host_and_port() const { return host_and_port_; } |
40 | 42 |
43 // Callback from the SSL layer that indicates the remote server is requesting | |
44 // a certificate for this client. | |
45 int ClientCertRequestCallback(SSL* ssl, X509** x509, EVP_PKEY** pkey); | |
wtc
2010/12/01 22:50:05
Nit: match the method declaration and definition o
joth
2010/12/02 17:12:01
Done as near as I can.
The .cc has slipped quite a
wtc
2010/12/03 18:56:05
YES! This is the right call. Do not make gratuit
| |
46 | |
41 // SSLClientSocket methods: | 47 // SSLClientSocket methods: |
42 virtual void GetSSLInfo(SSLInfo* ssl_info); | 48 virtual void GetSSLInfo(SSLInfo* ssl_info); |
43 virtual void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info); | 49 virtual void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info); |
44 virtual NextProtoStatus GetNextProto(std::string* proto); | 50 virtual NextProtoStatus GetNextProto(std::string* proto); |
45 | 51 |
46 // ClientSocket methods: | 52 // ClientSocket methods: |
47 virtual int Connect(CompletionCallback* callback); | 53 virtual int Connect(CompletionCallback* callback); |
48 virtual void Disconnect(); | 54 virtual void Disconnect(); |
49 virtual bool IsConnected() const; | 55 virtual bool IsConnected() const; |
50 virtual bool IsConnectedAndIdle() const; | 56 virtual bool IsConnectedAndIdle() const; |
(...skipping 13 matching lines...) Expand all Loading... | |
64 private: | 70 private: |
65 bool Init(); | 71 bool Init(); |
66 void DoReadCallback(int result); | 72 void DoReadCallback(int result); |
67 void DoWriteCallback(int result); | 73 void DoWriteCallback(int result); |
68 | 74 |
69 bool DoTransportIO(); | 75 bool DoTransportIO(); |
70 int DoHandshake(); | 76 int DoHandshake(); |
71 int DoVerifyCert(int result); | 77 int DoVerifyCert(int result); |
72 int DoVerifyCertComplete(int result); | 78 int DoVerifyCertComplete(int result); |
73 void DoConnectCallback(int result); | 79 void DoConnectCallback(int result); |
74 void InvalidateSessionIfBadCertificate(); | |
75 X509Certificate* UpdateServerCert(); | 80 X509Certificate* UpdateServerCert(); |
76 | 81 |
77 void OnHandshakeIOComplete(int result); | 82 void OnHandshakeIOComplete(int result); |
78 void OnSendComplete(int result); | 83 void OnSendComplete(int result); |
79 void OnRecvComplete(int result); | 84 void OnRecvComplete(int result); |
80 | 85 |
81 int DoHandshakeLoop(int last_io_result); | 86 int DoHandshakeLoop(int last_io_result); |
82 int DoReadLoop(int result); | 87 int DoReadLoop(int result); |
83 int DoWriteLoop(int result); | 88 int DoWriteLoop(int result); |
84 int DoPayloadRead(); | 89 int DoPayloadRead(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 STATE_VERIFY_CERT_COMPLETE, | 146 STATE_VERIFY_CERT_COMPLETE, |
142 }; | 147 }; |
143 State next_handshake_state_; | 148 State next_handshake_state_; |
144 BoundNetLog net_log_; | 149 BoundNetLog net_log_; |
145 }; | 150 }; |
146 | 151 |
147 } // namespace net | 152 } // namespace net |
148 | 153 |
149 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_OPENSSL_H_ | 154 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_OPENSSL_H_ |
150 | 155 |
OLD | NEW |