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

Unified Diff: sdk/lib/io/secure_socket.dart

Issue 11415290: Add a callback to SecureSocket for certificates that fail to be authenticated. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Free persistent handle upon destruction. Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/secure_socket_patch.dart ('k') | tests/standalone/io/secure_builtin_roots_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..17061b47266fd8b5e359a29b22d1a0f8982a2ac8 100644
--- a/sdk/lib/io/secure_socket.dart
+++ b/sdk/lib/io/secure_socket.dart
@@ -15,6 +15,14 @@ abstract class SecureSocket implements Socket {
*/
factory SecureSocket(String host, int port) => new _SecureSocket(host, port);
+ /**
+ * 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));
+
/**
* Initializes the NSS library with the path to a certificate database
* containing root certificates for verifying certificate paths on
@@ -50,6 +58,22 @@ abstract class SecureSocket implements Socket {
}
+/**
+ * X509Certificate represents an SSL certificate, with accessors to
+ * get the fields of the certificate.
+ */
+class 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
static final int NOT_CONNECTED = 200;
@@ -159,6 +183,14 @@ class _SecureSocket implements SecureSocket {
_socket.onWrite = _secureWriteHandler;
}
+ void set onBadCertificate(bool callback(X509Certificate certificate)) {
+ if (callback is! Function && callback != null) {
+ 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 +616,7 @@ abstract class _SecureFilter {
void handshake();
void init();
int processBuffer(int bufferIndex);
+ void registerBadCertificateCallback(Function callback);
void registerHandshakeCompleteCallback(Function handshakeCompleteHandler);
List<_ExternalBuffer> get buffers;
« no previous file with comments | « runtime/bin/secure_socket_patch.dart ('k') | tests/standalone/io/secure_builtin_roots_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698