Commit Graph

17 Commits

Author SHA1 Message Date
Alexander Aprelev 937a716b09 [io/ssl/mac] Retain certificates used by trust certification evaluation.
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>
2021-02-09 01:19:57 +00:00
Alexander Aprelev 316cc15a55 [io/ssl/ios] Ensure that certificate is up-referenced before it had a chance to get disposed.
This fixes https://github.com/dart-lang/sdk/issues/44590.

TEST=Running mocked-up flutter app on iphone that does 100 connects to a site that requires bad certificate callback(see the issue).

Change-Id: I6a7aff54a312821842b94c9314af5a2074d657d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/178760
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2021-01-21 20:08:03 +00:00
Alexander Aprelev e2e1c63fcd [io/ssl/mac] Move boringssl ssl data structures manipulation out of certificate evaluator.
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>
2020-12-02 02:29:57 +00:00
Alexander Aprelev 340f78eab3 [vm/io] Add a test for nonblocking ssl certification evaluation.
This is follow-up to a6dafabb88.

Fixes https://github.com/dart-lang/sdk/issues/43674

Change-Id: I4da732ab08235a1f549d45c7fa5fb87db672e2aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166701
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-10-12 15:06:52 +00:00
Alexander Aprelev a6dafabb88 [vm/io/mac] On macos/ios run trust evaluation part of ssl certification validation on separate worker thread.
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>
2020-10-01 23:40:16 +00:00
Zichang Guo d5a1b84997 Add certs from Windows root stores to SSL trust store
Bug: https://github.com/dart-lang/sdk/issues/32131
Change-Id: I5f5890e8c6d0c4ff8c51ef7017f204d73ff9c4bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159202
Commit-Queue: Zichang Guo <zichangguo@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-08-20 02:14:08 +00:00
Ben Konyi 3224a6633b [ VM / dart:io ] Replace usage of SecTrustEvaluate with SecTrustEvaluateWithError on MacOS >= 10.14
SecTrustEvaluate is now deprecated as of 10.15.

Fixes https://github.com/dart-lang/sdk/issues/38887

Change-Id: Id057ef47d4c4be0ad012203dbabc0266be58ad8a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123556
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2019-10-31 22:17:17 +00:00
Dan Field 034fce1e39 [dart:io] unbreak build
Change-Id: Ia8965e62f4b89a80aeb6db1489ca45c6db321adc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102640
Reviewed-by: Régis Crelier <regis@google.com>
Auto-Submit: Dan Field <dnfield@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2019-05-15 19:13:29 +00:00
Dan Field 7f323feefe [dart:io] Fix iOS https leaks
Add move constructor and equality operators to
ScopedCFType, add specialized destructor for arrays.

Add release to ScopedCFType.

Use ScopedCFType for SecCertificateRef.

Bug: https://github.com/dart-lang/sdk/issues/36935
Change-Id: I7b40f23fb8f0d7ab0835587e040362f883f86bd5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102560
Reviewed-by: Zach Anderson <zra@google.com>
Auto-Submit: Dan Field <dnfield@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2019-05-15 17:53:49 +00:00
Ben Konyi 1dabf0d19c [ VM / dart:io ] Removed usage of std::make_unique as C++14 is not supported in google3
Change-Id: I615bcb89ef2dec2e745a4d321a13a0a131ba7485
Reviewed-on: https://dart-review.googlesource.com/c/83230
Commit-Queue: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
Auto-Submit: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2018-11-07 01:07:23 +00:00
Ben Konyi 7aacf7e188 [ VM / dart:io ] Fixed memory leak in SecurityContext on MacOS.
Fixes #33114.

Change-Id: I6e2272c6d63b11bbd82c3d5b7c3aedf75306ba05
Reviewed-on: https://dart-review.googlesource.com/55523
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2018-05-18 20:17:49 +00:00
Zach Anderson c117aeea3b [dart:io] Check hostname when validating cert chains on MacOS
fixes #32936

Change-Id: Ic79ce7151cbeff1cf1d28908715c07c4e3b422d9
Reviewed-on: https://dart-review.googlesource.com/52342
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2018-04-23 22:39:32 +00:00
Zachary Anderson d7845c6a6f [standalone] Clean up command line argument parsing
fixes #30534

Change-Id: I5e721e5d24de32f0cb85f7bd96890913cf788f81
Reviewed-on: https://dart-review.googlesource.com/4608
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2017-09-11 18:58:39 +00:00
Zachary Anderson 747868f2b1 [dart:io] Remove DART_IO_DISABLED
This was only used by Dartium.

Review-Url: https://codereview.chromium.org/3009523002 .
2017-08-24 11:17:52 -07:00
Zachary Anderson 6cd8a79078 VM: Re-format to use at most one newline between functions
R=asiva@google.com

Review-Url: https://codereview.chromium.org/2974233002 .
2017-07-13 08:08:37 -07:00
Alexander Aprelev d86cb763b9 Add comma to the license so it matches license header in other files, doesn't result in new license text added in Flutter license inventory.
See https://github.com/flutter/engine/pull/3755.

BUG=
R=bkonyi@google.com

Review-Url: https://codereview.chromium.org/2927703007 .
2017-06-08 12:19:30 -07:00
Ben Konyi 644862bf96 Ported SecureSocket to use BoringSSL on OSX and iOS. This included registering a callback with BoringSSL using SSL_CTX_set_cert_verify_callback, which overrides the BoringSSL certificate verification process, in order to verify certificates against the system's root certificates and then proceed to let BoringSSL handle the rest of the SSL session. In addition, this change includes refactoring to share BoringSSL code that used on all platforms.
BUG=
R=zra@google.com

Review-Url: https://codereview.chromium.org/2903743002 .
2017-06-06 12:52:57 -07:00