1、我使用了dio库,并全局设置了如下代码,进行Https请求,但是不走badCertificateCallback回调,是什么原因?
2、上线的时候需要在badCertificateCallback中判断pem是否正确吗?
HttpOverrides.global = ProxiedHttpOverridesDebug("");
class ProxiedHttpOverridesDebug extends HttpOverrides {
String _proxy;
ProxiedHttpOverridesDebug(this._proxy);
@override
HttpClient createHttpClient(SecurityContext? context) {
return super.createHttpClient(context)
..findProxy = (uri) {
return _proxy.isNotEmpty ? "PROXY $_proxy;" : 'DIRECT';
}
..badCertificateCallback = (X509Certificate cert, String host, int port) {
if (cert.pem == ThingsboardAppConstants.X509CertificatePem) {
return true;
}
return false;
};
}
}
一次性掌握Flutter高阶技能+商业级复杂项目架构设计与开发方案
了解课程