Repository navigation
π Fix validateCertificate to fire pre-emission for TLS pinning
#2512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
1ce3ee2
23aa0c0
8a66e1e
a7372d3
6eb64d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Per @AlexV525: 1. Revert dio/pubspec.yaml + dio_test/pubspec.yaml min SDK back to `>=2.18.0 <4.0.0` (the bump to 3.5.0 is no longer needed). 2. Revert dio/lib/src/dio_mixin.dart to `abstract class DioMixin` with the original TODO comment. 3. Replace the Dart-3.5+ `ConnectionTask.fromSocket(...)` call in `_pinnedConnectionFactory` with `SecureSocket.startConnect(...)` and return the stock SDK [ConnectionTask] it produces. We await `task.socket` once to do the leaf-cert validation; HttpClient re-awaits the same `Future<SecureSocket>` and gets the resolved value immediately (Future await is idempotent). This works on every Dart >=2.18.0 because `SecureSocket.startConnect` has been in `dart:io` well before the minimum SDK, and the `ConnectionTask` generic is covariant in its type parameter so `ConnectionTask<SecureSocket>` is implicitly assignable to `ConnectionTask<Socket>` at the factory's return position. No vendoring or `implements ConnectionTask` is required β and `ConnectionTask` being `final class` from Dart 3.0 onward is no longer a problem since we never inherit from it. The maintainer's suggestion to literally "copy ConnectionTask into the code base" cannot be done across the Dart 3.0β3.4 window (final class blocks implements; fromSocket didn't exist yet), but `SecureSocket.startConnect` achieves the same end with zero new types and zero SDK floor change. 4. Drop the two CHANGELOG bullets that referenced the SDK bump and the mixin migration. The rest of the entry (the actual #2418 fix) stays. No test changes β the factory's observable behavior is unchanged (approval yields a validated SecureSocket; rejection still throws `_BadCertificateException` from the same point in `_fetch`'s try block). All 222 tests pass; `dart analyze lib/` is clean.
- Loading branch information
There are no files selected for viewing
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert since we don't match the requirement here.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reverted in 8a66e1e β back to |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reverted in 8a66e1e β back to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about other adapters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix is intentionally scoped to
IOHttpClientAdaptersince that's the adapter with the bug. Quick rundown of the others:plugins/http2_adapterβ already does pre-emission validation correctly atconnection_manager_imp.dart:133-150. This PR bringsIOHttpClientAdapterto parity.plugins/web_adapterβ novalidateCertificatefield exists on the web adapter; TLS is browser-controlled and not introspectable from Dart. Not applicable.plugins/native_dio_adapterβ delegates tocronet_http/cupertino_http; TLS pinning is platform-native (Android NSC, iOS ATS/TrustKit), not a dio-level callback. Not applicable.Happy to add this as a one-line cross-reference comment in
io_adapter.dartif you'd like that captured in source.