我正在尝试将客户端证书从http.dart包加载到 http.client。
我已经看到了关于如何使用HttpClient类的多个答案,例如这个答案:Flutter add self signed certificate from assets folder,这基本上建议执行以下代码
ByteData data = await rootBundle.load('assets/raw/certificate.crt');
SecurityContext context = SecurityContext.defaultContext;
context.useCertificateChainBytes(data.buffer.asUint8List());
client = HttpClient(context: context);
但我必须使用http.dart包,因为我有一个函数可以接受这样的http.client
东西
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 --
}
有没有办法配置 ahttp.client
以使用客户端证书?
谢谢。