Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: runtime/bin/secure_socket_macos.cc

Issue 1852783003: Implements remaining SecurityContext calls for iOS (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/bin/secure_socket_macos.h ('k') | sdk/lib/io/secure_socket.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #if !defined(DART_IO_DISABLED) && !defined(DART_IO_SECURE_SOCKET_DISABLED) 5 #if !defined(DART_IO_DISABLED) && !defined(DART_IO_SECURE_SOCKET_DISABLED)
6 6
7 #include "platform/globals.h" 7 #include "platform/globals.h"
8 #if defined(TARGET_OS_MACOS) && !TARGET_OS_IOS 8 #if defined(TARGET_OS_MACOS) && !TARGET_OS_IOS
9 9
10 #include "bin/secure_socket.h" 10 #include "bin/secure_socket.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 static const int kSSLFilterNativeFieldIndex = 0; 59 static const int kSSLFilterNativeFieldIndex = 0;
60 static const int kSecurityContextNativeFieldIndex = 0; 60 static const int kSecurityContextNativeFieldIndex = 0;
61 static const int kX509NativeFieldIndex = 0; 61 static const int kX509NativeFieldIndex = 0;
62 62
63 static const bool SSL_LOG_STATUS = false; 63 static const bool SSL_LOG_STATUS = false;
64 static const bool SSL_LOG_DATA = false; 64 static const bool SSL_LOG_DATA = false;
65 static const bool SSL_LOG_CERTS = false; 65 static const bool SSL_LOG_CERTS = false;
66 static const int SSL_ERROR_MESSAGE_BUFFER_SIZE = 1000; 66 static const int SSL_ERROR_MESSAGE_BUFFER_SIZE = 1000;
67 static const intptr_t PEM_BUFSIZE = 1024; 67 static const intptr_t PEM_BUFSIZE = 1024;
68 68
69 // SSLCertContext wraps the certificates needed for a SecureTransport
70 // connection. Fields are protected by the mutex_ field, and may only be set
71 // once. This is to allow access by both the Dart thread and the IOService
72 // thread. Setters return false if the field was already set.
73 class SSLCertContext {
74 public:
75 SSLCertContext() :
76 mutex_(new Mutex()),
77 private_key_(NULL),
78 keychain_(NULL),
79 cert_chain_(NULL),
80 trusted_certs_(NULL),
81 cert_authorities_(NULL),
82 trust_builtin_(false) {}
83
84 ~SSLCertContext() {
85 if (private_key_ != NULL) {
86 CFRelease(private_key_);
87 }
88 if (keychain_ != NULL) {
89 SecKeychainDelete(keychain_);
90 CFRelease(keychain_);
91 }
92 if (cert_chain_ != NULL) {
93 CFRelease(cert_chain_);
94 }
95 if (trusted_certs_ != NULL) {
96 CFRelease(trusted_certs_);
97 }
98 if (cert_authorities_ != NULL) {
99 CFRelease(cert_authorities_);
100 }
101 delete mutex_;
102 }
103
104 SecKeyRef private_key() {
105 MutexLocker m(mutex_);
106 return private_key_;
107 }
108 bool set_private_key(SecKeyRef private_key) {
109 MutexLocker m(mutex_);
110 if (private_key_ != NULL) {
111 return false;
112 }
113 private_key_ = private_key;
114 return true;
115 }
116
117 SecKeychainRef keychain() {
118 MutexLocker m(mutex_);
119 return keychain_;
120 }
121 bool set_keychain(SecKeychainRef keychain) {
122 MutexLocker m(mutex_);
123 if (keychain_ != NULL) {
124 return false;
125 }
126 keychain_ = keychain;
127 return true;
128 }
129
130 CFArrayRef cert_chain() {
131 MutexLocker m(mutex_);
132 return cert_chain_;
133 }
134 bool set_cert_chain(CFArrayRef cert_chain) {
135 MutexLocker m(mutex_);
136 if (cert_chain_ != NULL) {
137 return false;
138 }
139 cert_chain_ = cert_chain;
140 return true;
141 }
142
143 CFArrayRef trusted_certs() {
144 MutexLocker m(mutex_);
145 return trusted_certs_;
146 }
147 bool set_trusted_certs(CFArrayRef trusted_certs) {
148 MutexLocker m(mutex_);
149 if (trusted_certs_ != NULL) {
150 return false;
151 }
152 trusted_certs_ = trusted_certs;
153 return true;
154 }
155
156 CFArrayRef cert_authorities() {
157 MutexLocker m(mutex_);
158 return cert_authorities_;
159 }
160 bool set_cert_authorities(CFArrayRef cert_authorities) {
161 MutexLocker m(mutex_);
162 if (cert_authorities_ != NULL) {
163 return false;
164 }
165 cert_authorities_ = cert_authorities;
166 return true;
167 }
168
169 bool trust_builtin() {
170 MutexLocker m(mutex_);
171 return trust_builtin_;
172 }
173 void set_trust_builtin(bool trust_builtin) {
174 MutexLocker m(mutex_);
175 trust_builtin_ = trust_builtin;
176 }
177
178 private:
179 // The context is accessed both by Dart code and the IOService. This mutex
180 // protects all fields.
181 Mutex* mutex_;
182
183 SecKeyRef private_key_;
184 SecKeychainRef keychain_;
185
186 // CFArrays of SecCertificateRef.
187 CFArrayRef cert_chain_;
188 CFArrayRef trusted_certs_;
189 CFArrayRef cert_authorities_;
190
191 bool trust_builtin_;
192
193 DISALLOW_COPY_AND_ASSIGN(SSLCertContext);
194 };
195
196
197 static char* CFStringRefToCString(CFStringRef cfstring) { 69 static char* CFStringRefToCString(CFStringRef cfstring) {
198 CFIndex len = CFStringGetLength(cfstring); 70 CFIndex len = CFStringGetLength(cfstring);
199 CFIndex max_len = 71 CFIndex max_len =
200 CFStringGetMaximumSizeForEncoding(len, kCFStringEncodingUTF8) + 1; 72 CFStringGetMaximumSizeForEncoding(len, kCFStringEncodingUTF8) + 1;
201 char* result = reinterpret_cast<char*>(Dart_ScopeAllocate(max_len)); 73 char* result = reinterpret_cast<char*>(Dart_ScopeAllocate(max_len));
202 ASSERT(result != NULL); 74 ASSERT(result != NULL);
203 bool success = 75 bool success =
204 CFStringGetCString(cfstring, result, max_len, kCFStringEncodingUTF8); 76 CFStringGetCString(cfstring, result, max_len, kCFStringEncodingUTF8);
205 return success ? result : NULL; 77 return success ? result : NULL;
206 } 78 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 kSSLFilterNativeFieldIndex, 122 kSSLFilterNativeFieldIndex,
251 reinterpret_cast<intptr_t*>(&filter))); 123 reinterpret_cast<intptr_t*>(&filter)));
252 return filter; 124 return filter;
253 } 125 }
254 126
255 127
256 static void DeleteFilter(void* isolate_data, 128 static void DeleteFilter(void* isolate_data,
257 Dart_WeakPersistentHandle handle, 129 Dart_WeakPersistentHandle handle,
258 void* context_pointer) { 130 void* context_pointer) {
259 SSLFilter* filter = reinterpret_cast<SSLFilter*>(context_pointer); 131 SSLFilter* filter = reinterpret_cast<SSLFilter*>(context_pointer);
260 delete filter; 132 filter->Release();
261 } 133 }
262 134
263 135
264 static Dart_Handle SetFilter(Dart_NativeArguments args, SSLFilter* filter) { 136 static Dart_Handle SetFilter(Dart_NativeArguments args, SSLFilter* filter) {
265 ASSERT(filter != NULL); 137 ASSERT(filter != NULL);
266 const int approximate_size_of_filter = 1500; 138 const int approximate_size_of_filter = 1500;
267 Dart_Handle dart_this = Dart_GetNativeArgument(args, 0); 139 Dart_Handle dart_this = Dart_GetNativeArgument(args, 0);
268 RETURN_IF_ERROR(dart_this); 140 RETURN_IF_ERROR(dart_this);
269 ASSERT(Dart_IsInstance(dart_this)); 141 ASSERT(Dart_IsInstance(dart_this));
270 Dart_Handle err = Dart_SetNativeInstanceField( 142 Dart_Handle err = Dart_SetNativeInstanceField(
(...skipping 18 matching lines...) Expand all
289 kSecurityContextNativeFieldIndex, 161 kSecurityContextNativeFieldIndex,
290 reinterpret_cast<intptr_t*>(&context))); 162 reinterpret_cast<intptr_t*>(&context)));
291 return context; 163 return context;
292 } 164 }
293 165
294 166
295 static void DeleteCertContext(void* isolate_data, 167 static void DeleteCertContext(void* isolate_data,
296 Dart_WeakPersistentHandle handle, 168 Dart_WeakPersistentHandle handle,
297 void* context_pointer) { 169 void* context_pointer) {
298 SSLCertContext* context = static_cast<SSLCertContext*>(context_pointer); 170 SSLCertContext* context = static_cast<SSLCertContext*>(context_pointer);
299 delete context; 171 context->Release();
300 } 172 }
301 173
302 174
303 static Dart_Handle SetSecurityContext(Dart_NativeArguments args, 175 static Dart_Handle SetSecurityContext(Dart_NativeArguments args,
304 SSLCertContext* context) { 176 SSLCertContext* context) {
305 const int approximate_size_of_context = 1500; 177 const int approximate_size_of_context = 1500;
306 Dart_Handle dart_this = Dart_GetNativeArgument(args, 0); 178 Dart_Handle dart_this = Dart_GetNativeArgument(args, 0);
307 RETURN_IF_ERROR(dart_this); 179 RETURN_IF_ERROR(dart_this);
308 ASSERT(Dart_IsInstance(dart_this)); 180 ASSERT(Dart_IsInstance(dart_this));
309 Dart_Handle err = Dart_SetNativeInstanceField( 181 Dart_Handle err = Dart_SetNativeInstanceField(
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 CFRelease(cfpassword); 544 CFRelease(cfpassword);
673 return status; 545 return status;
674 } 546 }
675 547
676 548
677 void FUNCTION_NAME(SecureSocket_Init)(Dart_NativeArguments args) { 549 void FUNCTION_NAME(SecureSocket_Init)(Dart_NativeArguments args) {
678 Dart_Handle dart_this = ThrowIfError(Dart_GetNativeArgument(args, 0)); 550 Dart_Handle dart_this = ThrowIfError(Dart_GetNativeArgument(args, 0));
679 SSLFilter* filter = new SSLFilter(); // Deleted in DeleteFilter finalizer. 551 SSLFilter* filter = new SSLFilter(); // Deleted in DeleteFilter finalizer.
680 Dart_Handle err = SetFilter(args, filter); 552 Dart_Handle err = SetFilter(args, filter);
681 if (Dart_IsError(err)) { 553 if (Dart_IsError(err)) {
682 delete filter; 554 filter->Release();
683 Dart_PropagateError(err); 555 Dart_PropagateError(err);
684 } 556 }
685 err = filter->Init(dart_this); 557 err = filter->Init(dart_this);
686 if (Dart_IsError(err)) { 558 if (Dart_IsError(err)) {
687 // The finalizer was set up by SetFilter. It will delete `filter` if there 559 // The finalizer was set up by SetFilter. It will delete `filter` if there
688 // is an error. 560 // is an error.
689 filter->Destroy(); 561 filter->Destroy();
690 Dart_PropagateError(err); 562 Dart_PropagateError(err);
691 } 563 }
692 } 564 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 } 656 }
785 657
786 658
787 void FUNCTION_NAME(SecureSocket_PeerCertificate) 659 void FUNCTION_NAME(SecureSocket_PeerCertificate)
788 (Dart_NativeArguments args) { 660 (Dart_NativeArguments args) {
789 Dart_SetReturnValue(args, GetFilter(args)->PeerCertificate()); 661 Dart_SetReturnValue(args, GetFilter(args)->PeerCertificate());
790 } 662 }
791 663
792 664
793 void FUNCTION_NAME(SecureSocket_FilterPointer)(Dart_NativeArguments args) { 665 void FUNCTION_NAME(SecureSocket_FilterPointer)(Dart_NativeArguments args) {
794 intptr_t filter_pointer = reinterpret_cast<intptr_t>(GetFilter(args)); 666 SSLFilter* filter = GetFilter(args);
667 // This filter pointer is passed to the IO Service thread. The IO Service
668 // thread must Release() the pointer when it is done with it.
669 filter->Retain();
670 intptr_t filter_pointer = reinterpret_cast<intptr_t>(filter);
795 Dart_SetReturnValue(args, Dart_NewInteger(filter_pointer)); 671 Dart_SetReturnValue(args, Dart_NewInteger(filter_pointer));
796 } 672 }
797 673
798 674
799 void FUNCTION_NAME(SecurityContext_Allocate)(Dart_NativeArguments args) { 675 void FUNCTION_NAME(SecurityContext_Allocate)(Dart_NativeArguments args) {
800 SSLCertContext* cert_context = new SSLCertContext(); 676 SSLCertContext* cert_context = new SSLCertContext();
801 // cert_context deleted in DeleteCertContext finalizer. 677 // cert_context deleted in DeleteCertContext finalizer.
802 Dart_Handle err = SetSecurityContext(args, cert_context); 678 Dart_Handle err = SetSecurityContext(args, cert_context);
803 if (Dart_IsError(err)) { 679 if (Dart_IsError(err)) {
804 delete cert_context; 680 cert_context->Release();
805 Dart_PropagateError(err); 681 Dart_PropagateError(err);
806 } 682 }
807 } 683 }
808 684
809 685
810 void FUNCTION_NAME(SecurityContext_UsePrivateKeyBytes)( 686 void FUNCTION_NAME(SecurityContext_UsePrivateKeyBytes)(
811 Dart_NativeArguments args) { 687 Dart_NativeArguments args) {
812 SSLCertContext* context = GetSecurityContext(args); 688 SSLCertContext* context = GetSecurityContext(args);
813 const char* password = GetPasswordArgument(args, 2); 689 const char* password = GetPasswordArgument(args, 2);
814 690
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 864
989 865
990 void FUNCTION_NAME(X509_Subject)(Dart_NativeArguments args) { 866 void FUNCTION_NAME(X509_Subject)(Dart_NativeArguments args) {
991 SecCertificateRef certificate = GetX509Certificate(args); 867 SecCertificateRef certificate = GetX509Certificate(args);
992 char* subject_name = GetNameFromCert( 868 char* subject_name = GetNameFromCert(
993 certificate, 869 certificate,
994 kSecOIDX509V1SubjectName, 870 kSecOIDX509V1SubjectName,
995 reinterpret_cast<CFStringRef>(kSecOIDCommonName)); 871 reinterpret_cast<CFStringRef>(kSecOIDCommonName));
996 if (subject_name == NULL) { 872 if (subject_name == NULL) {
997 Dart_ThrowException(DartUtils::NewDartArgumentError( 873 Dart_ThrowException(DartUtils::NewDartArgumentError(
998 "X509.subject failed to find issuer's common name.")); 874 "X509.subject failed to find subject's common name."));
999 } else { 875 } else {
1000 Dart_SetReturnValue(args, Dart_NewStringFromCString(subject_name)); 876 Dart_SetReturnValue(args, Dart_NewStringFromCString(subject_name));
1001 } 877 }
1002 } 878 }
1003 879
1004 880
1005 void FUNCTION_NAME(X509_Issuer)(Dart_NativeArguments args) { 881 void FUNCTION_NAME(X509_Issuer)(Dart_NativeArguments args) {
1006 SecCertificateRef certificate = GetX509Certificate(args); 882 SecCertificateRef certificate = GetX509Certificate(args);
1007 char* issuer_name = GetNameFromCert( 883 char* issuer_name = GetNameFromCert(
1008 certificate, 884 certificate,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 // end for output buffers. Therefore, the Dart thread can simultaneously 955 // end for output buffers. Therefore, the Dart thread can simultaneously
1080 // write to the free space and end pointer of input buffers, and read from 956 // write to the free space and end pointer of input buffers, and read from
1081 // the data space of output buffers, and modify the start pointer. 957 // the data space of output buffers, and modify the start pointer.
1082 // 958 //
1083 // When ProcessFilter returns, the Dart thread is responsible for combining 959 // When ProcessFilter returns, the Dart thread is responsible for combining
1084 // the updated pointers from Dart and C++, to make the new valid state of 960 // the updated pointers from Dart and C++, to make the new valid state of
1085 // the circular buffer. 961 // the circular buffer.
1086 CObject* SSLFilter::ProcessFilterRequest(const CObjectArray& request) { 962 CObject* SSLFilter::ProcessFilterRequest(const CObjectArray& request) {
1087 CObjectIntptr filter_object(request[0]); 963 CObjectIntptr filter_object(request[0]);
1088 SSLFilter* filter = reinterpret_cast<SSLFilter*>(filter_object.Value()); 964 SSLFilter* filter = reinterpret_cast<SSLFilter*>(filter_object.Value());
965 RefCntReleaseScope<SSLFilter> rs(filter);
966
1089 bool in_handshake = CObjectBool(request[1]).Value(); 967 bool in_handshake = CObjectBool(request[1]).Value();
1090 intptr_t starts[SSLFilter::kNumBuffers]; 968 intptr_t starts[SSLFilter::kNumBuffers];
1091 intptr_t ends[SSLFilter::kNumBuffers]; 969 intptr_t ends[SSLFilter::kNumBuffers];
1092 for (intptr_t i = 0; i < SSLFilter::kNumBuffers; ++i) { 970 for (intptr_t i = 0; i < SSLFilter::kNumBuffers; ++i) {
1093 starts[i] = CObjectInt32(request[2 * i + 2]).Value(); 971 starts[i] = CObjectInt32(request[2 * i + 2]).Value();
1094 ends[i] = CObjectInt32(request[2 * i + 3]).Value(); 972 ends[i] = CObjectInt32(request[2 * i + 3]).Value();
1095 } 973 }
1096 974
1097 OSStatus status = filter->ProcessAllBuffers(starts, ends, in_handshake); 975 OSStatus status = filter->ProcessAllBuffers(starts, ends, in_handshake);
1098 if (status == noErr) { 976 if (status == noErr) {
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 if (auth != kNeverAuthenticate) { 1385 if (auth != kNeverAuthenticate) {
1508 status = SSLSetSessionOption( 1386 status = SSLSetSessionOption(
1509 ssl_context, kSSLSessionOptionBreakOnClientAuth, true); 1387 ssl_context, kSSLSessionOptionBreakOnClientAuth, true);
1510 CheckStatus(status, 1388 CheckStatus(status,
1511 "TlsException", 1389 "TlsException",
1512 "Failed to set client authentication mode"); 1390 "Failed to set client authentication mode");
1513 } 1391 }
1514 } 1392 }
1515 1393
1516 // Add the contexts to our wrapper. 1394 // Add the contexts to our wrapper.
1517 cert_context_ = context; 1395 cert_context_.set(context);
1518 ssl_context_ = ssl_context; 1396 ssl_context_ = ssl_context;
1519 is_server_ = is_server; 1397 is_server_ = is_server;
1520 1398
1521 // Kick-off the handshake. Expect the handshake to need more data. 1399 // Kick-off the handshake. Expect the handshake to need more data.
1522 // SSLHandshake calls our SSLReadCallback and SSLWriteCallback. 1400 // SSLHandshake calls our SSLReadCallback and SSLWriteCallback.
1523 status = SSLHandshake(ssl_context); 1401 status = SSLHandshake(ssl_context);
1524 ASSERT(status != noErr); 1402 ASSERT(status != noErr);
1525 if (status == errSSLWouldBlock) { 1403 if (status == errSSLWouldBlock) {
1526 status = noErr; 1404 status = noErr;
1527 in_handshake_ = true; 1405 in_handshake_ = true;
(...skipping 18 matching lines...) Expand all
1546 return noErr; 1424 return noErr;
1547 } 1425 }
1548 if (SSL_LOG_STATUS) { 1426 if (SSL_LOG_STATUS) {
1549 Log::Print("Handshake error from SSLCopyPeerTrust(): %ld.\n", 1427 Log::Print("Handshake error from SSLCopyPeerTrust(): %ld.\n",
1550 static_cast<intptr_t>(status)); 1428 static_cast<intptr_t>(status));
1551 } 1429 }
1552 return status; 1430 return status;
1553 } 1431 }
1554 1432
1555 CFArrayRef trusted_certs = NULL; 1433 CFArrayRef trusted_certs = NULL;
1556 if (cert_context_->trusted_certs() != NULL) { 1434 if (cert_context_.get()->trusted_certs() != NULL) {
1557 trusted_certs = CFArrayCreateCopy(NULL, cert_context_->trusted_certs()); 1435 trusted_certs =
1436 CFArrayCreateCopy(NULL, cert_context_.get()->trusted_certs());
1558 } else { 1437 } else {
1559 trusted_certs = CFArrayCreate(NULL, NULL, 0, &kCFTypeArrayCallBacks); 1438 trusted_certs = CFArrayCreate(NULL, NULL, 0, &kCFTypeArrayCallBacks);
1560 } 1439 }
1561 1440
1562 status = SecTrustSetAnchorCertificates(peer_trust, trusted_certs); 1441 status = SecTrustSetAnchorCertificates(peer_trust, trusted_certs);
1563 if (status != noErr) { 1442 if (status != noErr) {
1564 if (SSL_LOG_STATUS) { 1443 if (SSL_LOG_STATUS) {
1565 Log::Print("Handshake error from SecTrustSetAnchorCertificates: %ld\n", 1444 Log::Print("Handshake error from SecTrustSetAnchorCertificates: %ld\n",
1566 static_cast<intptr_t>(status)); 1445 static_cast<intptr_t>(status));
1567 } 1446 }
1568 CFRelease(trusted_certs); 1447 CFRelease(trusted_certs);
1569 CFRelease(peer_trust); 1448 CFRelease(peer_trust);
1570 return status; 1449 return status;
1571 } 1450 }
1572 1451
1573 if (SSL_LOG_STATUS) { 1452 if (SSL_LOG_STATUS) {
1574 Log::Print("Handshake %s built in root certs\n", 1453 Log::Print("Handshake %s built in root certs\n",
1575 cert_context_->trust_builtin() ? "trusting" : "not trusting"); 1454 cert_context_.get()->trust_builtin() ? "trusting" : "not trusting");
1576 } 1455 }
1577 1456
1578 status = SecTrustSetAnchorCertificatesOnly( 1457 status = SecTrustSetAnchorCertificatesOnly(
1579 peer_trust, !cert_context_->trust_builtin()); 1458 peer_trust, !cert_context_.get()->trust_builtin());
1580 if (status != noErr) { 1459 if (status != noErr) {
1581 CFRelease(trusted_certs); 1460 CFRelease(trusted_certs);
1582 CFRelease(peer_trust); 1461 CFRelease(peer_trust);
1583 return status; 1462 return status;
1584 } 1463 }
1585 1464
1586 SecTrustResultType trust_result; 1465 SecTrustResultType trust_result;
1587 status = SecTrustEvaluate(peer_trust, &trust_result); 1466 status = SecTrustEvaluate(peer_trust, &trust_result);
1588 if (status != noErr) { 1467 if (status != noErr) {
1589 CFRelease(trusted_certs); 1468 CFRelease(trusted_certs);
(...skipping 22 matching lines...) Expand all
1612 if (SSL_LOG_STATUS) { 1491 if (SSL_LOG_STATUS) {
1613 Log::Print("Trust eval failed: trust_restul = %d\n", trust_result); 1492 Log::Print("Trust eval failed: trust_restul = %d\n", trust_result);
1614 } 1493 }
1615 bad_cert_ = true; 1494 bad_cert_ = true;
1616 return errSSLBadCert; 1495 return errSSLBadCert;
1617 } 1496 }
1618 } 1497 }
1619 1498
1620 1499
1621 OSStatus SSLFilter::Handshake() { 1500 OSStatus SSLFilter::Handshake() {
1622 ASSERT(cert_context_ != NULL); 1501 ASSERT(cert_context_.get() != NULL);
1623 ASSERT(ssl_context_ != NULL); 1502 ASSERT(ssl_context_ != NULL);
1624 // Try and push handshake along. 1503 // Try and push handshake along.
1625 if (SSL_LOG_STATUS) { 1504 if (SSL_LOG_STATUS) {
1626 Log::Print("Doing SSLHandshake\n"); 1505 Log::Print("Doing SSLHandshake\n");
1627 } 1506 }
1628 OSStatus status = SSLHandshake(ssl_context_); 1507 OSStatus status = SSLHandshake(ssl_context_);
1629 if (SSL_LOG_STATUS) { 1508 if (SSL_LOG_STATUS) {
1630 Log::Print("SSLHandshake returned %ld\n", static_cast<intptr_t>(status)); 1509 Log::Print("SSLHandshake returned %ld\n", static_cast<intptr_t>(status));
1631 } 1510 }
1632 1511
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 // The SSL_REQUIRE_CERTIFICATE option only takes effect if the 1604 // The SSL_REQUIRE_CERTIFICATE option only takes effect if the
1726 // SSL_REQUEST_CERTIFICATE option is also set, so set it. 1605 // SSL_REQUEST_CERTIFICATE option is also set, so set it.
1727 request_client_certificate = 1606 request_client_certificate =
1728 request_client_certificate || require_client_certificate; 1607 request_client_certificate || require_client_certificate;
1729 // TODO(24070, 24069): Implement setting the client certificate parameters, 1608 // TODO(24070, 24069): Implement setting the client certificate parameters,
1730 // and triggering rehandshake. 1609 // and triggering rehandshake.
1731 } 1610 }
1732 1611
1733 1612
1734 SSLFilter::~SSLFilter() { 1613 SSLFilter::~SSLFilter() {
1735 // cert_context_ deleted by finalizer. Don't delete here.
1736 cert_context_ = NULL;
1737 if (ssl_context_ != NULL) { 1614 if (ssl_context_ != NULL) {
1738 CFRelease(ssl_context_); 1615 CFRelease(ssl_context_);
1739 ssl_context_ = NULL; 1616 ssl_context_ = NULL;
1740 } 1617 }
1741 if (peer_certs_ != NULL) { 1618 if (peer_certs_ != NULL) {
1742 CFRelease(peer_certs_); 1619 CFRelease(peer_certs_);
1743 peer_certs_ = NULL; 1620 peer_certs_ = NULL;
1744 } 1621 }
1745 if (hostname_ != NULL) { 1622 if (hostname_ != NULL) {
1746 free(hostname_); 1623 free(hostname_);
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1960 return status; 1837 return status;
1961 } 1838 }
1962 1839
1963 } // namespace bin 1840 } // namespace bin
1964 } // namespace dart 1841 } // namespace dart
1965 1842
1966 #endif // defined(TARGET_OS_MACOS) && !TARGET_OS_IOS 1843 #endif // defined(TARGET_OS_MACOS) && !TARGET_OS_IOS
1967 1844
1968 #endif // !defined(DART_IO_DISABLED) && 1845 #endif // !defined(DART_IO_DISABLED) &&
1969 // !defined(DART_IO_SECURE_SOCKET_DISABLED) 1846 // !defined(DART_IO_SECURE_SOCKET_DISABLED)
OLDNEW
« no previous file with comments | « runtime/bin/secure_socket_macos.h ('k') | sdk/lib/io/secure_socket.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698