| 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 | 9 |
| 10 | 10 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 implements SecurityContext { | 130 implements SecurityContext { |
| 131 _SecurityContext() { | 131 _SecurityContext() { |
| 132 _createNativeContext(); | 132 _createNativeContext(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void _createNativeContext() native "SecurityContext_Allocate"; | 135 void _createNativeContext() native "SecurityContext_Allocate"; |
| 136 | 136 |
| 137 static final SecurityContext defaultContext = | 137 static final SecurityContext defaultContext = |
| 138 new _SecurityContext().._trustBuiltinRoots(); | 138 new _SecurityContext().._trustBuiltinRoots(); |
| 139 | 139 |
| 140 Future usePrivateKey(String keyFile, {String password}) { | 140 void usePrivateKeySync(String keyFile, {String password}) { |
| 141 return (new File(keyFile)).readAsBytes().then((bytes) { | 141 List<int> bytes = (new File(keyFile)).readAsBytesSync(); |
| 142 usePrivateKeyBytes(bytes, password: password); | 142 usePrivateKeyBytes(bytes, password: password); |
| 143 }); | |
| 144 } | 143 } |
| 145 void usePrivateKeyBytes(List<int> keyBytes, {String password}) | 144 void usePrivateKeyBytes(List<int> keyBytes, {String password}) |
| 146 native "SecurityContext_UsePrivateKeyBytes"; | 145 native "SecurityContext_UsePrivateKeyBytes"; |
| 147 void setTrustedCertificates({String file, String directory}) | 146 void setTrustedCertificatesSync(String file) { |
| 148 native "SecurityContext_SetTrustedCertificates"; | 147 List<int> bytes = (new File(file)).readAsBytesSync(); |
| 149 Future useCertificateChain(String chainFile) { | 148 setTrustedCertificatesBytes(bytes); |
| 150 return (new File(chainFile)).readAsBytes().then((bytes) { | 149 } |
| 151 useCertificateChainBytes(bytes); | 150 void setTrustedCertificatesBytes(List<int> certBytes) |
| 152 }); | 151 native "SecurityContext_SetTrustedCertificatesBytes"; |
| 152 void useCertificateChainSync(String chainFile) { |
| 153 List<int> bytes = (new File(chainFile)).readAsBytesSync(); |
| 154 useCertificateChainBytes(bytes); |
| 153 } | 155 } |
| 154 void useCertificateChainBytes(List<int> chainBytes) | 156 void useCertificateChainBytes(List<int> chainBytes) |
| 155 native "SecurityContext_UseCertificateChainBytes"; | 157 native "SecurityContext_UseCertificateChainBytes"; |
| 156 void setClientAuthorities(String file) | 158 void setClientAuthoritiesSync(String file) { |
| 157 native "SecurityContext_SetClientAuthorities"; | 159 List<int> bytes = (new File(file)).readAsBytesSync(); |
| 160 setClientAuthoritiesBytes(bytes); |
| 161 } |
| 162 void setClientAuthoritiesBytes(List<int> authCertBytes) |
| 163 native "SecurityContext_SetClientAuthoritiesBytes"; |
| 158 void setAlpnProtocols(List<String> protocols, bool isServer) { | 164 void setAlpnProtocols(List<String> protocols, bool isServer) { |
| 159 Uint8List encodedProtocols = | 165 Uint8List encodedProtocols = |
| 160 SecurityContext._protocolsToLengthEncoding(protocols); | 166 SecurityContext._protocolsToLengthEncoding(protocols); |
| 161 _setAlpnProtocols(encodedProtocols, isServer); | 167 _setAlpnProtocols(encodedProtocols, isServer); |
| 162 } | 168 } |
| 163 void _setAlpnProtocols(Uint8List protocols, bool isServer) | 169 void _setAlpnProtocols(Uint8List protocols, bool isServer) |
| 164 native "SecurityContext_SetAlpnProtocols"; | 170 native "SecurityContext_SetAlpnProtocols"; |
| 165 void _trustBuiltinRoots() | 171 void _trustBuiltinRoots() |
| 166 native "SecurityContext_TrustBuiltinRoots"; | 172 native "SecurityContext_TrustBuiltinRoots"; |
| 167 } | 173 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 182 return new DateTime.fromMillisecondsSinceEpoch(_startValidity(), | 188 return new DateTime.fromMillisecondsSinceEpoch(_startValidity(), |
| 183 isUtc: true); | 189 isUtc: true); |
| 184 } | 190 } |
| 185 DateTime get endValidity { | 191 DateTime get endValidity { |
| 186 return new DateTime.fromMillisecondsSinceEpoch(_endValidity(), | 192 return new DateTime.fromMillisecondsSinceEpoch(_endValidity(), |
| 187 isUtc: true); | 193 isUtc: true); |
| 188 } | 194 } |
| 189 int _startValidity() native "X509_StartValidity"; | 195 int _startValidity() native "X509_StartValidity"; |
| 190 int _endValidity() native "X509_EndValidity"; | 196 int _endValidity() native "X509_EndValidity"; |
| 191 } | 197 } |
| OLD | NEW |