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_IOS_H_ | 5 #ifndef RUNTIME_BIN_SECURE_SOCKET_IOS_H_ |
6 #define RUNTIME_BIN_SECURE_SOCKET_IOS_H_ | 6 #define RUNTIME_BIN_SECURE_SOCKET_IOS_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 trusted_certs_(NULL), | 41 trusted_certs_(NULL), |
42 identity_(NULL), | 42 identity_(NULL), |
43 cert_chain_(NULL), | 43 cert_chain_(NULL), |
44 trust_builtin_(false) {} | 44 trust_builtin_(false) {} |
45 | 45 |
46 ~SSLCertContext() { | 46 ~SSLCertContext() { |
47 { | 47 { |
48 MutexLocker m(mutex_); | 48 MutexLocker m(mutex_); |
49 if (trusted_certs_ != NULL) { | 49 if (trusted_certs_ != NULL) { |
50 CFRelease(trusted_certs_); | 50 CFRelease(trusted_certs_); |
51 } | 51 } |
52 if (identity_ != NULL) { | 52 if (identity_ != NULL) { |
53 CFRelease(identity_); | 53 CFRelease(identity_); |
54 } | 54 } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 ssl_context_(NULL), | 143 ssl_context_(NULL), |
144 peer_certs_(NULL), | 144 peer_certs_(NULL), |
145 string_start_(NULL), | 145 string_start_(NULL), |
146 string_length_(NULL), | 146 string_length_(NULL), |
147 handshake_complete_(NULL), | 147 handshake_complete_(NULL), |
148 bad_certificate_callback_(NULL), | 148 bad_certificate_callback_(NULL), |
149 in_handshake_(false), | 149 in_handshake_(false), |
150 connected_(false), | 150 connected_(false), |
151 bad_cert_(false), | 151 bad_cert_(false), |
152 is_server_(false), | 152 is_server_(false), |
153 hostname_(NULL) { | 153 hostname_(NULL) {} |
154 } | |
155 | 154 |
156 ~SSLFilter(); | 155 ~SSLFilter(); |
157 | 156 |
158 // Callback called by the IOService. | 157 // Callback called by the IOService. |
159 static CObject* ProcessFilterRequest(const CObjectArray& request); | 158 static CObject* ProcessFilterRequest(const CObjectArray& request); |
160 | 159 |
161 Dart_Handle Init(Dart_Handle dart_this); | 160 Dart_Handle Init(Dart_Handle dart_this); |
162 void Connect(Dart_Handle dart_this, | 161 void Connect(Dart_Handle dart_this, |
163 const char* hostname, | 162 const char* hostname, |
164 SSLCertContext* context, | 163 SSLCertContext* context, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 bool is_server_; | 230 bool is_server_; |
232 char* hostname_; | 231 char* hostname_; |
233 | 232 |
234 DISALLOW_COPY_AND_ASSIGN(SSLFilter); | 233 DISALLOW_COPY_AND_ASSIGN(SSLFilter); |
235 }; | 234 }; |
236 | 235 |
237 } // namespace bin | 236 } // namespace bin |
238 } // namespace dart | 237 } // namespace dart |
239 | 238 |
240 #endif // RUNTIME_BIN_SECURE_SOCKET_IOS_H_ | 239 #endif // RUNTIME_BIN_SECURE_SOCKET_IOS_H_ |
OLD | NEW |