From 28fbb08f5e4e37cb77259f643c57af5f93a9fd24 Mon Sep 17 00:00:00 2001 From: Jan Romann Date: Mon, 4 Nov 2024 22:43:21 +0100 Subject: [PATCH 1/2] feat(http_config): add withTrustedRoots config parameter --- lib/src/binding_http/http_config.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/src/binding_http/http_config.dart b/lib/src/binding_http/http_config.dart index 77963610..2cc69243 100644 --- a/lib/src/binding_http/http_config.dart +++ b/lib/src/binding_http/http_config.dart @@ -25,9 +25,14 @@ class HttpConfig { class HttpClientConfig { /// Creates a new [HttpClientConfig] object. const HttpClientConfig({ + this.withTrustedRoots = true, this.trustedCertificates, }); + /// Indicates whether the security contexts created from this config will + /// incorporate trusted root certificates from the underlying platform. + final bool withTrustedRoots; + /// List of trusted certificates that will be added to the security contexts /// of newly created HTTP clients. /// From e7dc1feb331cba45a0859fdd80d99b6acbc4b273 Mon Sep 17 00:00:00 2001 From: Jan Romann Date: Mon, 4 Nov 2024 22:43:57 +0100 Subject: [PATCH 2/2] fix(binding_http): let HTTP client use the withTrustedRoots parameter --- lib/src/binding_http/http_client.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/src/binding_http/http_client.dart b/lib/src/binding_http/http_client.dart index 30b0b5b9..5be7e8a6 100644 --- a/lib/src/binding_http/http_client.dart +++ b/lib/src/binding_http/http_client.dart @@ -54,7 +54,9 @@ final class HttpClient extends ProtocolClient IOClient(io.HttpClient(context: _createContext(httpClientConfig))); static SecurityContext _createContext(HttpClientConfig? httpClientConfig) { - final context = SecurityContext(); + final context = SecurityContext( + withTrustedRoots: httpClientConfig?.withTrustedRoots ?? true, + ); final trustedCertificates = httpClientConfig?.trustedCertificates ?? [];