final HostnameVerifier PROMISCUOUS_VERIFIER = (s, sslSession) -> true; //跳过验证
final RestTemplate restTemplate = new RestTemplate();
restTemplate.setRequestFactory(new SimpleClientHttpRequestFactory() {
@Override
protected void prepareConnection(HttpURLConnection connection, String httpMethod) throws IOException {
if (connection instanceof HttpsURLConnection) {
((HttpsURLConnection) connection).setHostnameVerifier(PROMISCUOUS_VERIFIER);
}
super.prepareConnection(connection, httpMethod);
}
});
//请求接口
resultMap = restTemplate.postForObject(path, requestEntity, JSONObject.class);
resttemplate 跳过安全验证
最新推荐文章于 2024-04-16 22:45:31 发布