问题中没有足够的细节,所以这个答案是基于一些假设:
package:http
用作 http 客户端package:http
dart:io HttpClient
在引擎盖下使用,并HttpClient
具有多个允许证书验证的功能。由于客户端不信任自签名服务器证书,客户端将调用badCertificateCallback
允许您自己验证服务器证书,例如:
HttpClient httpClient = new HttpClient()
..badCertificateCallback =
((X509Certificate cert, String host, int port) {
// tests that cert is self signed, correct subject and correct date(s)
return (cert.issuer == cert.subject &&
cert.subject == 'MySelfSignedCertCN' &&
cert.endValidity.millisecondsSinceEpoch == 1234567890);
});
IOClient ioClient = new IOClient(httpClient);
// use ioClient to perform get/post operations from package:http
// don't forget to call ioClient.close() when done
// note, this also closes the underlying HttpClient
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6433 次 |
最近记录: |