Chromium Code Reviews| Index: sdk/lib/io/secure_socket.dart |
| diff --git a/sdk/lib/io/secure_socket.dart b/sdk/lib/io/secure_socket.dart |
| index 2a28e1356387974a21fb702d7ac973e160f75c1c..d673ff8815029cacc9b2fa0a71f5eeed4fa0a407 100644 |
| --- a/sdk/lib/io/secure_socket.dart |
| +++ b/sdk/lib/io/secure_socket.dart |
| @@ -14,7 +14,13 @@ abstract class SecureSocket implements Socket { |
| * but ready for registration of callbacks. |
| */ |
| factory SecureSocket(String host, int port) => new _SecureSocket(host, port); |
| - |
| + /** |
|
Mads Ager (google)
2012/12/05 07:30:53
Please add a blank line between members.
Bill Hesse
2012/12/05 12:35:38
Done.
|
| + * Install a handler for unverifiable certificates. The handler can inspect |
| + * the certificate, and decide (or let the user decide) whether to accept |
| + * the connection or not. The callback should return true |
| + * to continue the SecureSocket connection. |
| + */ |
| + void set onBadCertificate(bool callback(X509Certificate certificate)); |
| /** |
|
Mads Ager (google)
2012/12/05 07:30:53
Ditto.
|
| * Initializes the NSS library with the path to a certificate database |
| * containing root certificates for verifying certificate paths on |
| @@ -49,6 +55,29 @@ abstract class SecureSocket implements Socket { |
| bool useBuiltinRoots: true}); |
| } |
| +/** |
| + * X509Certificate represents an SSL certificate, with accessors to |
| + * get the fields of the certificate. |
| + */ |
| +abstract class X509Certificate { |
|
Mads Ager (google)
2012/12/05 07:30:53
I think we should just remove the abstract class.
Bill Hesse
2012/12/05 12:35:38
Done.
|
| + String get subject; |
| + String get issuer; |
| + Date get startValidity; |
| + Date get endValidity; |
| +} |
| + |
| + |
| +class _X509Certificate implements X509Certificate { |
| + _X509Certificate(this.subject, |
| + this.issuer, |
| + this.startValidity, |
| + this.endValidity); |
| + final String subject; |
| + final String issuer; |
| + final Date startValidity; |
| + final Date endValidity; |
| +} |
| + |
| class _SecureSocket implements SecureSocket { |
| // Status states |
| @@ -159,6 +188,14 @@ class _SecureSocket implements SecureSocket { |
| _socket.onWrite = _secureWriteHandler; |
| } |
| + void set onBadCertificate(bool callback(X509Certificate certificate)) { |
| + if (callback is! Function && callback != null) { |
|
Mads Ager (google)
2012/12/05 07:30:53
Remove extra space before '&&'
|
| + throw new SocketIOException( |
| + "Callback provided to onBadCertificate is not a function or null"); |
| + } |
| + _secureFilter.registerBadCertificateCallback(callback); |
| + } |
| + |
| InputStream get inputStream { |
| if (_inputStream == null) { |
| if (_socketDataHandler != null || _socketCloseHandler != null) { |
| @@ -584,6 +621,7 @@ abstract class _SecureFilter { |
| void handshake(); |
| void init(); |
| int processBuffer(int bufferIndex); |
| + void registerBadCertificateCallback(Function callback); |
| void registerHandshakeCompleteCallback(Function handshakeCompleteHandler); |
| List<_ExternalBuffer> get buffers; |