如果是Java httpclient报的错话 解决方案是重写一下证书校验逻辑 让他不要校验
贴下代码:
X509TrustManager xtm = new X509TrustManager() { // 创建TrustManager
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
public X509Certificate[] getAcceptedIssuers() {
return null;
}
};
// TLS1.0与SSL3.0基本上没有太大的差别,可粗略理解为TLS是SSL的继承者,但它们使用的是相同的SSLContext
SSLContext ctx = null;
try {
ctx = SSLContext.getInstance("TLS");
// 使用TrustManager来初始化该上下文,TrustManager只是被SSL的Socket所使用
ctx.init(null, new TrustManager[] { xtm }, null);
// 创建SSLSocketFactory
SSLSocketFactory socketFactory = new SSLSocketFactory(ctx);
// 通过SchemeRegistry将SSLSocketFactory注册到我们的HttpClient上
client.getConnectionManager().getSchemeRegistry().register(new Scheme("https", 443, socketFactory));
// 设置超时时间
client.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, 30 * 10000);
client.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 60000 * 5);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
} catch (KeyManagementException e) {
throw new RuntimeException(e);
}
如果是Python抓包代码证书异常的话 verify 参数改成false