赞
踩
绕过ssl证书检查
话不多说上代码
// 构建WebClient
public static WebClient createWebClient() throws SSLException {
SslContext context = SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build();
HttpClient httpClient = HttpClient.create().secure(t -> t.sslContext(context));
return WebClient.builder().clientConnector(new ReactorClientHttpConnector(httpClient)).build();
相关import
import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslContextBuilder;
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
import org.springframework.http.MediaType;
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.netty.http.client.HttpClient;
import javax.net.ssl.SSLException;
使用createWebClient()方法来构建WebClient进行SDK调用即可。
WebClient webClient = xxxx.createWebClient();
webClient.post()…
webClient.get()…
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。