OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 #ifndef RUNTIME_BIN_SECURE_SOCKET_MACOS_H_ | 5 #ifndef RUNTIME_BIN_SECURE_SOCKET_MACOS_H_ |
6 #define RUNTIME_BIN_SECURE_SOCKET_MACOS_H_ | 6 #define RUNTIME_BIN_SECURE_SOCKET_MACOS_H_ |
7 | 7 |
8 #if !defined(RUNTIME_BIN_SECURE_SOCKET_H_) | 8 #if !defined(RUNTIME_BIN_SECURE_SOCKET_H_) |
9 #error Do not include secure_socket_macos.h directly. Use secure_socket.h. | 9 #error Do not include secure_socket_macos.h directly. Use secure_socket.h. |
10 #endif | 10 #endif |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 namespace dart { | 29 namespace dart { |
30 namespace bin { | 30 namespace bin { |
31 | 31 |
32 // SSLCertContext wraps the certificates needed for a SecureTransport | 32 // SSLCertContext wraps the certificates needed for a SecureTransport |
33 // connection. Fields are protected by the mutex_ field, and may only be set | 33 // connection. Fields are protected by the mutex_ field, and may only be set |
34 // once. This is to allow access by both the Dart thread and the IOService | 34 // once. This is to allow access by both the Dart thread and the IOService |
35 // thread. Setters return false if the field was already set. | 35 // thread. Setters return false if the field was already set. |
36 class SSLCertContext : public ReferenceCounted<SSLCertContext> { | 36 class SSLCertContext : public ReferenceCounted<SSLCertContext> { |
37 public: | 37 public: |
38 SSLCertContext() : | 38 SSLCertContext() |
39 ReferenceCounted(), | 39 : ReferenceCounted(), |
40 mutex_(new Mutex()), | 40 mutex_(new Mutex()), |
41 private_key_(NULL), | 41 private_key_(NULL), |
42 keychain_(NULL), | 42 keychain_(NULL), |
43 cert_chain_(NULL), | 43 cert_chain_(NULL), |
44 trusted_certs_(NULL), | 44 trusted_certs_(NULL), |
45 cert_authorities_(NULL), | 45 cert_authorities_(NULL), |
46 trust_builtin_(false) { | 46 trust_builtin_(false) {} |
47 } | |
48 | 47 |
49 ~SSLCertContext() { | 48 ~SSLCertContext() { |
50 { | 49 { |
51 MutexLocker m(mutex_); | 50 MutexLocker m(mutex_); |
52 if (private_key_ != NULL) { | 51 if (private_key_ != NULL) { |
53 CFRelease(private_key_); | 52 CFRelease(private_key_); |
54 } | 53 } |
55 if (keychain_ != NULL) { | 54 if (keychain_ != NULL) { |
56 SecKeychainDelete(keychain_); | 55 SecKeychainDelete(keychain_); |
57 CFRelease(keychain_); | 56 CFRelease(keychain_); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 ssl_context_(NULL), | 183 ssl_context_(NULL), |
185 peer_certs_(NULL), | 184 peer_certs_(NULL), |
186 string_start_(NULL), | 185 string_start_(NULL), |
187 string_length_(NULL), | 186 string_length_(NULL), |
188 handshake_complete_(NULL), | 187 handshake_complete_(NULL), |
189 bad_certificate_callback_(NULL), | 188 bad_certificate_callback_(NULL), |
190 in_handshake_(false), | 189 in_handshake_(false), |
191 connected_(false), | 190 connected_(false), |
192 bad_cert_(false), | 191 bad_cert_(false), |
193 is_server_(false), | 192 is_server_(false), |
194 hostname_(NULL) { | 193 hostname_(NULL) {} |
195 } | |
196 | 194 |
197 ~SSLFilter(); | 195 ~SSLFilter(); |
198 | 196 |
199 // Callback called by the IOService. | 197 // Callback called by the IOService. |
200 static CObject* ProcessFilterRequest(const CObjectArray& request); | 198 static CObject* ProcessFilterRequest(const CObjectArray& request); |
201 | 199 |
202 Dart_Handle Init(Dart_Handle dart_this); | 200 Dart_Handle Init(Dart_Handle dart_this); |
203 void Connect(Dart_Handle dart_this, | 201 void Connect(Dart_Handle dart_this, |
204 const char* hostname, | 202 const char* hostname, |
205 SSLCertContext* context, | 203 SSLCertContext* context, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 bool is_server_; | 270 bool is_server_; |
273 char* hostname_; | 271 char* hostname_; |
274 | 272 |
275 DISALLOW_COPY_AND_ASSIGN(SSLFilter); | 273 DISALLOW_COPY_AND_ASSIGN(SSLFilter); |
276 }; | 274 }; |
277 | 275 |
278 } // namespace bin | 276 } // namespace bin |
279 } // namespace dart | 277 } // namespace dart |
280 | 278 |
281 #endif // RUNTIME_BIN_SECURE_SOCKET_MACOS_H_ | 279 #endif // RUNTIME_BIN_SECURE_SOCKET_MACOS_H_ |
OLD | NEW |