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

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

Issue 11308271: Add built-in root certificates to dart:io SecureSocket. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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
Index: sdk/lib/io/secure_socket.dart
diff --git a/sdk/lib/io/secure_socket.dart b/sdk/lib/io/secure_socket.dart
index d76b5ada3f2168949c078a75938e3e5eaede004d..af3b9f3e4943942e89f271407a877f6ec00e31ec 100644
--- a/sdk/lib/io/secure_socket.dart
+++ b/sdk/lib/io/secure_socket.dart
@@ -23,7 +23,9 @@ abstract class SecureSocket implements Socket {
* client connections, and server certificates to provide on server
* connections. The password argument should be used when creating
* secure server sockets, to allow the private key of the server
- * certificate to be fetched.
+ * certificate to be fetched. If useBuiltinRoots is true (the default),
+ * then an built-in set of root certificates for trusted certificate
Mads Ager (google) 2012/11/29 20:13:05 an built-in set -> a built-in set?
Bill Hesse 2012/11/30 12:51:16 Done.
+ * authorities is merged with the certificates in the database.
*
* The database should be an NSS certificate database directory
* containing a cert9.db file, not a cert8.db file. This version of
@@ -32,7 +34,8 @@ abstract class SecureSocket implements Socket {
* environment variable NSS_DEFAULT_DB_TYPE to "sql".
*/
external static void setCertificateDatabase(String certificateDatabase,
Mads Ager (google) 2012/11/29 20:13:05 How do you get away with only using the built-in s
Bill Hesse 2012/11/30 12:51:16 Done.
- [String password]);
+ {String password,
+ bool useBuiltinRoots: true});
}
@@ -299,21 +302,31 @@ class _SecureSocket implements SecureSocket {
}
void _secureDataHandler() {
- if (_status == HANDSHAKE) {
- _secureHandshake();
- } else {
- _writeEncryptedData(); // TODO(whesse): Removing this causes a failure.
- _readEncryptedData();
- if (!_filterReadEmpty) {
- // Call the onData event.
- if (scheduledDataEvent != null) {
- scheduledDataEvent.cancel();
- scheduledDataEvent = null;
- }
- if (_socketDataHandler != null) {
- _socketDataHandler();
+ bool inUserCode = false;
+ try {
Mads Ager (google) 2012/11/29 20:13:05 I think we should do our best to avoid this type o
Bill Hesse 2012/11/30 12:51:16 In the socket class, the onError handler can be ca
+ if (_status == HANDSHAKE) {
+ _secureHandshake();
+ } else {
+ _writeEncryptedData(); // TODO(whesse): Removing this causes a failure.
+ _readEncryptedData();
+ if (!_filterReadEmpty) {
+ // Call the onData event.
+ if (scheduledDataEvent != null) {
+ scheduledDataEvent.cancel();
+ scheduledDataEvent = null;
+ }
+ if (_socketDataHandler != null) {
+ inUserCode = true;
+ _socketDataHandler();
+ }
}
}
+ } catch (e) {
+ if (inUserCode) {
+ throw e;
+ } else {
+ _reportError(e, "SecureSocket error");
+ }
}
}
@@ -331,6 +344,7 @@ class _SecureSocket implements SecureSocket {
} else {
e = new SocketIOException('$message (${error.toString()})', null);
}
+ close(false);
bool reported = false;
if (_socketErrorHandler != null) {
reported = true;
@@ -342,7 +356,6 @@ class _SecureSocket implements SecureSocket {
if (_outputStream != null) {
reported = reported || _outputStream._onSocketError(e);
}
-
if (!reported) throw e;
}

Powered by Google App Engine
This is Rietveld 408576698