我正在尝试使用OkHttp 3进行Http连接 我有:
Security.insertProviderAt(new BouncyCastleProvider(), 2);
ConnectionSpec spec = new ConnectionSpec.Builder(ConnectionSpec.COMPATIBLE_TLS)
.allEnabledTlsVersions()
.allEnabledCipherSuites()
.build();
clientBuilder.connectionSpecs(Collections.singletonList(spec));
}
OkHttpClient httpClient = clientBuilder.readTimeout(360, TimeUnit.SECONDS).build();
Response response = httpClient.newCall(builder.build()).execute();
这似乎有效,但偶尔我会得到这个
SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
我有什么方法可以解决这个问题吗?