方法1: 在Java代码中设置代理服务器
在运行程序前加上如下代码:
System.setProperty("http.proxyHost", "localhost");
System.setProperty("http.proxyPort", "8888");
System.setProperty("https.proxyHost", "localhost");
System.setProperty("https.proxyPort", "8888");
遇到的问题:
SSL报错,报错如下:
PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target; nested exception is javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
解决:
1、重写方法 ,信任所有SSL证书,新建一个工具类SslUtil.java
public class SslUtils {
private static void trus