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

Side by Side Diff: net/socket/ssl_server_socket.h

Issue 1474983003: Support for client certs in ssl_server_socket. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 #ifndef NET_SOCKET_SSL_SERVER_SOCKET_H_ 5 #ifndef NET_SOCKET_SSL_SERVER_SOCKET_H_
6 #define NET_SOCKET_SSL_SERVER_SOCKET_H_ 6 #define NET_SOCKET_SSL_SERVER_SOCKET_H_
7 7
8 #include <vector>
9
8 #include "base/basictypes.h" 10 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
10 #include "net/base/completion_callback.h" 12 #include "net/base/completion_callback.h"
11 #include "net/base/net_export.h" 13 #include "net/base/net_export.h"
12 #include "net/socket/ssl_socket.h" 14 #include "net/socket/ssl_socket.h"
13 #include "net/socket/stream_socket.h" 15 #include "net/socket/stream_socket.h"
16 #include "net/ssl/ssl_client_cert_type.h"
14 17
15 namespace crypto { 18 namespace crypto {
16 class RSAPrivateKey; 19 class RSAPrivateKey;
17 } // namespace crypto 20 } // namespace crypto
18 21
19 namespace net { 22 namespace net {
20 23
24 class ClientCertVerifier;
21 struct SSLServerConfig; 25 struct SSLServerConfig;
22 class X509Certificate; 26 class X509Certificate;
23 27
28 // This struct groups together several fields which are used by various
29 // classes related to SSLServerSocket.
30 struct SSLServerSocketContext {
davidben 2015/12/01 22:35:17 SSLClientSocketContext was kind of absurd to begin
ryanchung 2015/12/02 23:57:03 I think putting it with SSLServerConfig seem to ma
31 SSLServerSocketContext() : client_cert_verifier(NULL) {}
32
33 // Indicates that a client certificate is required, and provides the
34 // CertificateVerifier that is to be used to verify it during the handshake.
35 // The |client_cert_verifier| continues to be owned by the caller,
36 // and must exist at least until the handshake has completed.
37 // This function is meaningful only if client certificates are required.
38 // NOTES:
39 // 1. If no CertificateVerifier is provided, then a client certificate may
40 // still be allowed (if ssl_server_config.send_client_cert is true),
41 // but in that case verification must be done after the handshake
42 // has completed, by which time the session will have been cached,
43 // and may be subject to resumption.
44 // 2. The |client_cert_verifier| must provide its response synchronously, and
45 // blocks the IO thread while it runs. This results from a limitation of NSS.
46 // If ERR_IO_PENDING is returned, this is considered a verification failure.
davidben 2015/12/01 22:35:17 This isn't even implemented in NSS, no?
ryanchung 2015/12/02 23:57:03 Sorry, that was outdated. I believe OpenSSL also r
47 // 3. For verifying a client certificate, the CertVerifier::Verify method
48 // will be called with input parameters as follows:
49 // - cert: the cert to be verified
50 // - hostname: empty string
51 // - flags: 0
52 // - crl_set: NULL
davidben 2015/12/01 22:35:17 ?
ryanchung 2015/12/02 23:57:03 Sorry, that was outdated. Fixed.
53 ClientCertVerifier* client_cert_verifier;
54 };
55
24 class SSLServerSocket : public SSLSocket { 56 class SSLServerSocket : public SSLSocket {
25 public: 57 public:
26 ~SSLServerSocket() override {} 58 ~SSLServerSocket() override {}
27 59
28 // Perform the SSL server handshake, and notify the supplied callback 60 // Perform the SSL server handshake, and notify the supplied callback
29 // if the process completes asynchronously. If Disconnect is called before 61 // if the process completes asynchronously. If Disconnect is called before
30 // completion then the callback will be silently, as for other StreamSocket 62 // completion then the callback will be silently, as for other StreamSocket
31 // calls. 63 // calls.
32 virtual int Handshake(const CompletionCallback& callback) = 0; 64 virtual int Handshake(const CompletionCallback& callback) = 0;
33 }; 65 };
34 66
35 // Configures the underlying SSL library for the use of SSL server sockets. 67 // Configures the underlying SSL library for the use of SSL server sockets.
36 // 68 //
37 // Due to the requirements of the underlying libraries, this should be called 69 // Due to the requirements of the underlying libraries, this should be called
38 // early in process initialization, before any SSL socket, client or server, 70 // early in process initialization, before any SSL socket, client or server,
39 // has been used. 71 // has been used.
40 // 72 //
41 // Note: If a process does not use SSL server sockets, this call may be 73 // Note: If a process does not use SSL server sockets, this call may be
42 // omitted. 74 // omitted.
43 NET_EXPORT void EnableSSLServerSockets(); 75 NET_EXPORT void EnableSSLServerSockets();
44 76
45 // Creates an SSL server socket over an already-connected transport socket. 77 // Creates an SSL server socket over an already-connected transport socket.
46 // The caller must provide the server certificate and private key to use. 78 // The caller must provide the server certificate and private key to use.
47 // 79 //
48 // The returned SSLServerSocket takes ownership of |socket|. Stubbed versions 80 // The returned SSLServerSocket takes ownership of |socket|. Stubbed versions
49 // of CreateSSLServerSocket will delete |socket| and return NULL. 81 // of CreateSSLServerSocket will delete |socket| and return NULL.
50 // It takes a reference to |certificate|. 82 // It takes a reference to |certificate|.
51 // The |key| and |ssl_config| parameters are copied. |key| cannot be const 83 // The |key| and |ssl_server_config| parameters are copied. |key| cannot be
52 // because the methods used to copy its contents are non-const. 84 // const because the methods used to copy its contents are non-const.
53 // 85 //
54 // The caller starts the SSL server handshake by calling Handshake on the 86 // The caller starts the SSL server handshake by calling Handshake on the
55 // returned socket. 87 // returned socket.
56 NET_EXPORT scoped_ptr<SSLServerSocket> CreateSSLServerSocket( 88 NET_EXPORT scoped_ptr<SSLServerSocket> CreateSSLServerSocket(
57 scoped_ptr<StreamSocket> socket, 89 scoped_ptr<StreamSocket> socket,
58 X509Certificate* certificate, 90 X509Certificate* certificate,
59 crypto::RSAPrivateKey* key, 91 crypto::RSAPrivateKey* key,
60 const SSLServerConfig& ssl_config); 92 const SSLServerConfig& ssl_server_config);
93
94 // Creates an SSL server socket over an already-connected transport socket.
95 // Overloads the original to add an optional context
96 NET_EXPORT scoped_ptr<SSLServerSocket> CreateSSLServerSocket(
97 scoped_ptr<StreamSocket> socket,
98 X509Certificate* certificate,
99 crypto::RSAPrivateKey* key,
100 const SSLServerConfig& ssl_server_config,
101 const SSLServerSocketContext& context);
61 102
62 } // namespace net 103 } // namespace net
63 104
64 #endif // NET_SOCKET_SSL_SERVER_SOCKET_H_ 105 #endif // NET_SOCKET_SSL_SERVER_SOCKET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698