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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Future usePrivateKey(String keyFile, {String password}) { |
141 return (new File(keyFile)).readAsBytes().then((bytes) { | 141 return (new File(keyFile)).readAsBytes().then((bytes) { |
142 usePrivateKeyAsBytes(bytes, password: password); | 142 usePrivateKeyBytes(bytes, password: password); |
143 }); | 143 }); |
144 } | 144 } |
145 void usePrivateKeyAsBytes(List<int> keyBytes, {String password}) | 145 void usePrivateKeyBytes(List<int> keyBytes, {String password}) |
146 native "SecurityContext_UsePrivateKeyAsBytes"; | 146 native "SecurityContext_UsePrivateKeyBytes"; |
147 void setTrustedCertificates({String file, String directory}) | 147 void setTrustedCertificates({String file, String directory}) |
148 native "SecurityContext_SetTrustedCertificates"; | 148 native "SecurityContext_SetTrustedCertificates"; |
149 void useCertificateChain(String file) | 149 Future useCertificateChain(String chainFile) { |
150 native "SecurityContext_UseCertificateChain"; | 150 return (new File(chainFile)).readAsBytes().then((bytes) { |
| 151 useCertificateChainBytes(bytes); |
| 152 }); |
| 153 } |
| 154 void useCertificateChainBytes(List<int> chainBytes) |
| 155 native "SecurityContext_UseCertificateChainBytes"; |
151 void setClientAuthorities(String file) | 156 void setClientAuthorities(String file) |
152 native "SecurityContext_SetClientAuthorities"; | 157 native "SecurityContext_SetClientAuthorities"; |
153 void setAlpnProtocols(List<String> protocols, bool isServer) { | 158 void setAlpnProtocols(List<String> protocols, bool isServer) { |
154 Uint8List encodedProtocols = | 159 Uint8List encodedProtocols = |
155 SecurityContext._protocolsToLengthEncoding(protocols); | 160 SecurityContext._protocolsToLengthEncoding(protocols); |
156 _setAlpnProtocols(encodedProtocols, isServer); | 161 _setAlpnProtocols(encodedProtocols, isServer); |
157 } | 162 } |
158 void _setAlpnProtocols(Uint8List protocols, bool isServer) | 163 void _setAlpnProtocols(Uint8List protocols, bool isServer) |
159 native "SecurityContext_SetAlpnProtocols"; | 164 native "SecurityContext_SetAlpnProtocols"; |
160 void _trustBuiltinRoots() | 165 void _trustBuiltinRoots() |
(...skipping 16 matching lines...) Expand all Loading... |
177 return new DateTime.fromMillisecondsSinceEpoch(_startValidity(), | 182 return new DateTime.fromMillisecondsSinceEpoch(_startValidity(), |
178 isUtc: true); | 183 isUtc: true); |
179 } | 184 } |
180 DateTime get endValidity { | 185 DateTime get endValidity { |
181 return new DateTime.fromMillisecondsSinceEpoch(_endValidity(), | 186 return new DateTime.fromMillisecondsSinceEpoch(_endValidity(), |
182 isUtc: true); | 187 isUtc: true); |
183 } | 188 } |
184 int _startValidity() native "X509_StartValidity"; | 189 int _startValidity() native "X509_StartValidity"; |
185 int _endValidity() native "X509_EndValidity"; | 190 int _endValidity() native "X509_EndValidity"; |
186 } | 191 } |
OLD | NEW |