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 ?? []; 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. ///