I'm trying to load a client certificate to a http.client from the http.dart package.
I'v seen multiple answers on how to do it using the HttpClient class, like this answer: Flutter add self signed certificate from asset folder, which basicaly suggests to do the following code
ByteData data = await rootBundle.load('assets/raw/certificate.pfx');
SecurityContext context = SecurityContext.defaultContext;
context.useCertificateChainBytes(data.buffer.asUint8List());
context.usePrivateKeyBytes(data.buffer.asUint8List());
client = HttpClient(context: context);
But I must use the http.dart package since i have a function that accepts a http.client
something like this
import 'package:http/http.dart' as http;
var httpClient = http.Client();
// i'd like to configure this httpClient to use a specific client certificate
var client = MyClient(httpClient);
....
MyClient (http.Client? httpClient) {
-- some constructor logic --
}
Is there any way to configure a http.client
to use a client certificate?
Thanks.