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

1. Problem description

When using cas for single sign-on, the front end jumps to the cas login page, and an error is reported after login

2. Solutions:

The above error shows that when HttpClients initiates a request, the url is https and certificate verification is required, so ssl should be ignored when creating an object. The code is as follows

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

 

Guess you like

Origin blog.csdn.net/yiye2017zhangmu/article/details/131046866