用HttpClient发送HTTPS请求报SSLException: Certificate for <域名> doesn‘t match any of the subject alternative

错误 :

httpclient 版本

处理方式:

        CloseableHttpClient httpclient = null;
        try {
            SSLConnectionSocketFactory scsf = new SSLConnectionSocketFactory(
                    SSLContexts.custom().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build(),
                    NoopHostnameVerifier.INSTANCE
            );

            httpclient = HttpClients.custom().setSSLSocketFactory(scsf).build();
  //        CloseableHttpClient httpclient = HttpClients.createDefault();
        } catch (NoSuchAlgorithmException e) {
           throw new RuntimeException(e);
        } catch (KeyStoreException e) {
           throw new RuntimeException(e);
        } catch (KeyManagementException e) {
           throw new RuntimeException(e);
        }