Certificate for <域名> doesn‘t match any of the subject alternative names

一.问题描述

用cas做单点登录时,前端跳转到cas登录页面,登录后报错

二.解决思路:

上面报错显示的是HttpClients发起请求时,url是https需要证书验证,所以在创建对象时要忽略掉ssl,代码如下

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

猜你喜欢

转载自blog.csdn.net/yiye2017zhangmu/article/details/131046866