| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 patch class SecureSocket { | 5 patch class SecureSocket { |
| 6 /* patch */ factory SecureSocket._(RawSecureSocket rawSocket) => | 6 /* patch */ factory SecureSocket._(RawSecureSocket rawSocket) => |
| 7 new _SecureSocket(rawSocket); | 7 new _SecureSocket(rawSocket); |
| 8 | 8 |
| 9 /* patch */ static void initialize({String database, | 9 /* patch */ static void initialize({String database, |
| 10 String password, | 10 String password, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 requestClientCertificate: requestClientCertificate, | 35 requestClientCertificate: requestClientCertificate, |
| 36 requireClientCertificate: requireClientCertificate); | 36 requireClientCertificate: requireClientCertificate); |
| 37 } | 37 } |
| 38 | 38 |
| 39 X509Certificate get peerCertificate { | 39 X509Certificate get peerCertificate { |
| 40 if (_raw == null) { | 40 if (_raw == null) { |
| 41 throw new StateError("peerCertificate called on destroyed SecureSocket"); | 41 throw new StateError("peerCertificate called on destroyed SecureSocket"); |
| 42 } | 42 } |
| 43 return _raw.peerCertificate; | 43 return _raw.peerCertificate; |
| 44 } | 44 } |
| 45 |
| 46 String get selectedProtocol { |
| 47 if (_raw == null) { |
| 48 throw new StateError("selectedProtocol called on destroyed SecureSocket"); |
| 49 } |
| 50 return _raw.selectedProtocol; |
| 51 } |
| 45 } | 52 } |
| 46 | 53 |
| 47 | 54 |
| 48 /** | 55 /** |
| 49 * _SecureFilterImpl wraps a filter that encrypts and decrypts data travelling | 56 * _SecureFilterImpl wraps a filter that encrypts and decrypts data travelling |
| 50 * over an encrypted socket. The filter also handles the handshaking | 57 * over an encrypted socket. The filter also handles the handshaking |
| 51 * and certificate verification. | 58 * and certificate verification. |
| 52 * | 59 * |
| 53 * The filter exposes its input and output buffers as Dart objects that | 60 * The filter exposes its input and output buffers as Dart objects that |
| 54 * are backed by an external C array of bytes, so that both Dart code and | 61 * are backed by an external C array of bytes, so that both Dart code and |
| (...skipping 16 matching lines...) Expand all Loading... |
| 71 } | 78 } |
| 72 } | 79 } |
| 73 | 80 |
| 74 void connect(String hostName, | 81 void connect(String hostName, |
| 75 Uint8List sockaddrStorage, | 82 Uint8List sockaddrStorage, |
| 76 int port, | 83 int port, |
| 77 bool is_server, | 84 bool is_server, |
| 78 String certificateName, | 85 String certificateName, |
| 79 bool requestClientCertificate, | 86 bool requestClientCertificate, |
| 80 bool requireClientCertificate, | 87 bool requireClientCertificate, |
| 81 bool sendClientCertificate) native "SecureSocket_Connect"; | 88 bool sendClientCertificate, |
| 89 Uint8List protocols) native "SecureSocket_Connect"; |
| 82 | 90 |
| 83 void destroy() { | 91 void destroy() { |
| 84 buffers = null; | 92 buffers = null; |
| 85 _destroy(); | 93 _destroy(); |
| 86 } | 94 } |
| 87 | 95 |
| 88 void _destroy() native "SecureSocket_Destroy"; | 96 void _destroy() native "SecureSocket_Destroy"; |
| 89 | 97 |
| 90 void handshake() native "SecureSocket_Handshake"; | 98 void handshake() native "SecureSocket_Handshake"; |
| 91 | 99 |
| 100 String selectedProtocol() native "SecureSocket_GetSelectedProtocol"; |
| 101 |
| 92 void renegotiate(bool useSessionCache, | 102 void renegotiate(bool useSessionCache, |
| 93 bool requestClientCertificate, | 103 bool requestClientCertificate, |
| 94 bool requireClientCertificate) | 104 bool requireClientCertificate) |
| 95 native "SecureSocket_Renegotiate"; | 105 native "SecureSocket_Renegotiate"; |
| 106 |
| 96 void init() native "SecureSocket_Init"; | 107 void init() native "SecureSocket_Init"; |
| 97 | 108 |
| 98 X509Certificate get peerCertificate native "SecureSocket_PeerCertificate"; | 109 X509Certificate get peerCertificate native "SecureSocket_PeerCertificate"; |
| 99 | 110 |
| 100 void registerBadCertificateCallback(Function callback) | 111 void registerBadCertificateCallback(Function callback) |
| 101 native "SecureSocket_RegisterBadCertificateCallback"; | 112 native "SecureSocket_RegisterBadCertificateCallback"; |
| 102 | 113 |
| 103 void registerHandshakeCompleteCallback(Function handshakeCompleteHandler) | 114 void registerHandshakeCompleteCallback(Function handshakeCompleteHandler) |
| 104 native "SecureSocket_RegisterHandshakeCompleteCallback"; | 115 native "SecureSocket_RegisterHandshakeCompleteCallback"; |
| 105 | 116 |
| 106 // This is a security issue, as it exposes a raw pointer to Dart code. | 117 // This is a security issue, as it exposes a raw pointer to Dart code. |
| 107 int _pointer() native "SecureSocket_FilterPointer"; | 118 int _pointer() native "SecureSocket_FilterPointer"; |
| 108 | 119 |
| 109 List<_ExternalBuffer> buffers; | 120 List<_ExternalBuffer> buffers; |
| 110 } | 121 } |
| OLD | NEW |