本来的代码是忽略证书
///忽略https证书校验,也就是能请求https的地址了
(_dio?.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate =
(HttpClient client) {
client.badCertificateCallback =
(X509Certificate cert, String host, int port) => true;
return client;
};
实际上还是抓不了包,因为要填代理IP和端口号,且要支持证书信任(不加的话只能抓到http,不能抓到https)
(_dio?.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (client) {
client.badCertificateCallback =
(X509Certificate cert, String host, int port) => true;//证书信任
client.findProxy = (Uri) {
// 用1个开关设置是否开启代理
Log.d('NetUtils _init=> ${Global.isProduction} IP地址:PROXY ${SPHelper.getTextIp}:${SPHelper.getTextPort}');
return !Global.isProduction ? 'PROXY ${SPHelper.getTextIp}:${SPHelper.getTextPort}' : 'DIRECT';
};
};
平时的测试包可以用上面这个代理方式给测试人员测试,当发版的时候要改会第一个校验
本文含有隐藏内容,请 开通VIP 后查看