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_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 CertVerifier; | |
| 21 struct SSLConfig; | 25 struct SSLConfig; |
| 22 class X509Certificate; | 26 class X509Certificate; |
| 27 typedef std::vector<scoped_refptr<X509Certificate>> CertificateList; | |
|
Ryan Sleevi
2015/03/19 04:38:24
ODR VIOLATION: Don't do duplicate typedefs like th
davidben
2015/03/25 00:05:33
That's actually how we forward-declare that typede
Ryan Sleevi
2015/03/25 00:14:08
Any place that is doing that is buggy; this isn't
| |
| 23 | 28 |
| 24 class SSLServerSocket : public SSLSocket { | 29 class SSLServerSocket : public SSLSocket { |
| 25 public: | 30 public: |
| 26 ~SSLServerSocket() override {} | 31 ~SSLServerSocket() override {} |
| 27 | 32 |
| 28 // Perform the SSL server handshake, and notify the supplied callback | 33 // Perform the SSL server handshake, and notify the supplied callback |
| 29 // if the process completes asynchronously. If Disconnect is called before | 34 // if the process completes asynchronously. If Disconnect is called before |
| 30 // completion then the callback will be silently, as for other StreamSocket | 35 // completion then the callback will be silently, as for other StreamSocket |
| 31 // calls. | 36 // calls. |
| 32 virtual int Handshake(const CompletionCallback& callback) = 0; | 37 virtual int Handshake(const CompletionCallback& callback) = 0; |
| 38 | |
|
davidben
2015/03/25 00:05:33
These APIs are very dangerous because of the globa
| |
| 39 // Indicates whether a client certificate is to be allowed by the upcoming | |
| 40 // Handshake. | |
| 41 virtual void SetAllowClientCert(bool allow_client_cert) = 0; | |
|
Ryan Sleevi
2015/03/19 04:38:24
The client is not allowed to presumptively send a
| |
| 42 | |
| 43 // Provides the list of certificates whose names are to be included in the | |
| 44 // CertificateRequest handshake message. Calling this function is only useful | |
| 45 // if certificates are allowed. | |
| 46 virtual void SetClientCertCAList( | |
| 47 const CertificateList& client_cert_ca_list) = 0; | |
|
Ryan Sleevi
2015/03/19 04:38:24
I'd prefer this actually be part of the constructi
| |
| 48 | |
| 49 // Indicates that a client certificate is not only allowed but required, and | |
| 50 // provides the CertificateVerifier that is to be used to verify it during the | |
| 51 // handshake. The |client_cert_verifier| continues to be owned by the caller, | |
| 52 // and must exist at least until the handshake has completed. | |
| 53 // This function is meaningful only if client certificates are allowed. | |
| 54 // NOTES: | |
| 55 // 1. If no CertificateVerifier is provided, then a client certificate may | |
| 56 // still be allowed (if ssl_config.send_client_cert is true), but in that case | |
| 57 // verification must be done after the handshake has completed, by which time | |
| 58 // the session will have been cached, and may be subject to resumption. | |
| 59 // 2. The |client_cert_verifier| must provide its response synchronously, and | |
| 60 // blocks the IO thread while it runs. This results from a limitation of NSS. | |
| 61 // If ERR_IO_PENDING is returned, this is considered a verification failure. | |
| 62 // 3. For verifying a client certificate, the CertVerifier::Verify method | |
| 63 // will be called with input parameters as follows: | |
| 64 // - cert: the cert to be verified | |
| 65 // - hostname: empty string | |
| 66 // - flags: 0 | |
| 67 // - crl_set: NULL | |
| 68 virtual void SetClientCertVerifier(CertVerifier* client_cert_verifier) = 0; | |
|
Ryan Sleevi
2015/03/19 04:38:24
From a design level, I don't think I'm comfortable
| |
| 33 }; | 69 }; |
| 34 | 70 |
| 35 // Configures the underlying SSL library for the use of SSL server sockets. | 71 // Configures the underlying SSL library for the use of SSL server sockets. |
| 36 // | 72 // |
| 37 // Due to the requirements of the underlying libraries, this should be called | 73 // Due to the requirements of the underlying libraries, this should be called |
| 38 // early in process initialization, before any SSL socket, client or server, | 74 // early in process initialization, before any SSL socket, client or server, |
| 39 // has been used. | 75 // has been used. |
| 40 // | 76 // |
| 41 // Note: If a process does not use SSL server sockets, this call may be | 77 // Note: If a process does not use SSL server sockets, this call may be |
| 42 // omitted. | 78 // omitted. |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 55 // returned socket. | 91 // returned socket. |
| 56 NET_EXPORT scoped_ptr<SSLServerSocket> CreateSSLServerSocket( | 92 NET_EXPORT scoped_ptr<SSLServerSocket> CreateSSLServerSocket( |
| 57 scoped_ptr<StreamSocket> socket, | 93 scoped_ptr<StreamSocket> socket, |
| 58 X509Certificate* certificate, | 94 X509Certificate* certificate, |
| 59 crypto::RSAPrivateKey* key, | 95 crypto::RSAPrivateKey* key, |
| 60 const SSLConfig& ssl_config); | 96 const SSLConfig& ssl_config); |
| 61 | 97 |
| 62 } // namespace net | 98 } // namespace net |
| 63 | 99 |
| 64 #endif // NET_SOCKET_SSL_SERVER_SOCKET_H_ | 100 #endif // NET_SOCKET_SSL_SERVER_SOCKET_H_ |
| OLD | NEW |