This is follow-up to https://dart-review.googlesource.com/c/sdk/+/174340, which moved construction of macos certificate list from boringssl structures from worker thread back to main thread, however it seems to have resulted in certificates in certificate list being prematurely released.
This cl explicitly passes/retains certificates lists to worker thread to be released after certificate trust is evaluated.
Avoid using deprecated SecTrustEvaluate if running on recent versions of OS.
Fixes https://github.com/flutter/flutter/issues/73971
TEST=flutter/examples/image_list on mac osx 10.13.6 simulator 10.3.1
Change-Id: I36829a9b236fab2bbbe952314ce277c436ea0e10
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183620
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Boringssl data structures are not neccessary thread-safe, so should not be handled on certificate evaluator that runs asynchronously. That leaves only (potentially long-running) SecTrust call to be done by certificate evaluator.
Fixes https://github.com/flutter/flutter/issues/70800.
TEST=io/https_connection_closed_during_handshake_test.dart
Change-Id: I6f77f1efc9ec83c50e6bcc551c0f63d6465c763e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174340
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Running trust evaluation system api call on worker thread effectively unblocks main isolate when it attempts to establish https connection.
Execution of the worker thread is implemented via dart native port infrastructure which allows to run C++ code as a dart message handler.
TrustEvaluateHandlerFunc (if provided by platform-dependent SSLCertContext) is that handler, only mac(ios) implementation provides it.
Asynchrony of CertificateVerificationCallback (for mac/ios) is implemented via [ssl_verify_retry] return code which allows to suspend ssl handshake until certificate trust is confirmed.
When dart's _RawSecureSocket.secureHandshake() method that initiated ssl's handshake received this return code it knows it has to wait for a future that is completed by another callback([rpEvaluteResponse]) that waits for trust evaluation handler response.
rpEvaluateResponse purpose is to listen for response from TrustEvaluateHandler and also invoke user-provided [badCertficateCallback] that can override trust decision for a given connection request, for a given certificate.
Once that future is completed and CertificateVerificationCallback knows whether to trust a certificate or not, _secureHandshake retries ssl handshake.
Bug: https://github.com/dart-lang/sdk/issues/41519
Change-Id: Ifee18639c78099ec77cad50000444bc6c7b9369b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165520
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>