Java 如何使用spring引导RestTemplate调用SSL安全api

Java 如何使用spring引导RestTemplate调用SSL安全api,java,spring,jhipster,Java,Spring,Jhipster,我正在尝试使用SpringRESTTemplate调用SSL安全api。不幸的是,我得到了以下错误。我做错了什么 org.springframework.web.client.ResourceAccessException: I/O error on GET request for "https://thedomaintocall.com": java.security.cert.CertificateException: No name matching thedomain

我正在尝试使用SpringRESTTemplate调用SSL安全api。不幸的是,我得到了以下错误。我做错了什么

org.springframework.web.client.ResourceAccessException: I/O error on GET request for "https://thedomaintocall.com": java.security.cert.CertificateException: No name matching thedomaintocall found; nested exception is javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No name matching thedomaintocall found

您的信任库可能不包含验证API服务器证书的CA(请参阅)。另外,可能服务器的证书与其域名不匹配。我的API不使用自签名证书。它使用LetsEncrypt颁发的证书。这不是应该自动工作吗,还是我仍然必须将其导入信任存储?而且名字似乎也很相配。如果我在chrome devtools中检查证书,CN与我url中的服务器名完全相同。您可能需要导入CA证书以及证书链中的所有内容,具体取决于您使用的信任库,默认情况下是来自JRE的证书,或者来自您的操作系统的证书。