且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法找到所请求目标的有效证书路径 - java

更新时间:2022-02-26 22:27:37

当我使用了 TrustSelfSignedStrategy 对象作为信任材料 HttpClient

Problem was solved when I used a TrustSelfSignedStrategy object as the Trust material to HttpClient.

        httpClient = HttpClients.custom()
            .setSSLSocketFactory(new SSLConnectionSocketFactory(SSLContexts.custom()
                    .loadTrustMaterial(null, new TrustSelfSignedStrategy())
                    .build()
                )
            ).build();

我使用的代码如上所示..

The code I used is shown above..