PKIX路径构建失败,但我接受所有密码套件

时间:2017-03-29 18:05:08

标签: java bouncycastle okhttp3

我正在尝试使用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

我有什么方法可以解决这个问题吗?

0 个答案:

没有答案