Chromium Code Reviews| Index: sdk/lib/io/secure_server_socket.dart |
| diff --git a/sdk/lib/io/secure_server_socket.dart b/sdk/lib/io/secure_server_socket.dart |
| index 2ab290aaa287952179a9ec7727a5bc9d51febd21..f51f0f994c3465bc591142cd8d2b22aad794f69a 100644 |
| --- a/sdk/lib/io/secure_server_socket.dart |
| +++ b/sdk/lib/io/secure_server_socket.dart |
| @@ -13,24 +13,43 @@ abstract class SecureServerSocket implements ServerSocket { |
| * the certificate, such as "CN=localhost" or "CN=myserver.mydomain.com". |
| * The certificate is looked up in the NSS certificate database set by |
| * SecureSocket.setCertificateDatabase. |
| + * |
| + * To request or require that clients authenticate by providing an SSL (TLS) |
| + * client certificate, set the optional parameters requestClientCertificate or |
| + * requireClientCertificate to true. Require implies request, so one doesn't |
| + * need to specify both. To check whether a client certificate was received, |
| + * check SecureSocket.peerCertificate after connecting. If no certificate |
| + * was received, the result will be null. |
| */ |
| factory SecureServerSocket(String bindAddress, |
| - int port, |
| - int backlog, |
| - String certificate_name) => |
| - new _SecureServerSocket(bindAddress, port, backlog, certificate_name); |
| + int port, |
| + int backlog, |
| + String certificate_name, |
| + {bool requestClientCertificate: false, |
|
Søren Gjesse
2012/12/07 13:00:23
How about using an "enum" here with the following
Bill Hesse
2012/12/10 15:15:48
I strongly feel that for the user of the API, choo
|
| + bool requireClientCertificate: false}) { |
| + return new _SecureServerSocket(bindAddress, |
| + port, |
| + backlog, |
| + certificate_name, |
| + requestClientCertificate, |
| + requireClientCertificate); |
| + } |
| } |
| class _SecureServerSocket implements SecureServerSocket { |
| _SecureServerSocket(String bindAddress, |
| - int port, |
| - int backlog, |
| - String certificate_name) { |
| + int port, |
| + int backlog, |
| + String certificate_name, |
| + bool requestClientCertificate, |
| + bool requireClientCertificate) |
| + : _certificate_name = certificate_name, |
| + _requestClientCertificate = requestClientCertificate, |
| + _requireClientCertificate = requireClientCertificate { |
| _socket = new ServerSocket(bindAddress, port, backlog); |
| _socket.onConnection = this._onConnectionHandler; |
| - _certificate_name = certificate_name; |
| } |
| void set onConnection(void callback(Socket connection)) { |
| @@ -65,13 +84,16 @@ class _SecureServerSocket implements SecureServerSocket { |
| "SecureServerSocket with server certificate not set connected to"); |
| } |
| var secure_connection = new _SecureSocket.server(connection.remoteHost, |
| - connection.remotePort, |
| - connection, |
| - _certificate_name); |
| + connection.remotePort, |
| + connection, |
| + _certificate_name, |
| + _requestClientCertificate, |
| + _requireClientCertificate); |
| _onConnectionCallback(secure_connection); |
| } |
| ServerSocket _socket; |
| var _onConnectionCallback; |
| - String _certificate_name; |
| -} |
| + final String _certificate_name; |
| + final bool _requestClientCertificate; |
| + final bool _requireClientCertificate;} |