欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Spring5 WebClient忽略https证书认证

程序员文章站 2022-05-31 16:12:26
...

 

public static WebClient createWebClient()  {
    SslContext sslContext = null;
    try {
        sslContext = SslContextBuilder
                .forClient()
                .trustManager(InsecureTrustManagerFactory.INSTANCE)
                .build();
} catch (SSLException e) {
        e.printStackTrace();
}

    SslContext finalSslContext = sslContext;
ClientHttpConnector httpConnector = new ReactorClientHttpConnector(opt -> {
        opt.sslContext(finalSslContext);
});
    return WebClient.builder().clientConnector(httpConnector).build();
}