首页 > 解决方案 > Websphere - 休息服务 - 证书链接错误

问题描述

我正在尝试从我的应用程序连接 Rest 服务。我的应用程序被部署到 WAS 服务器。

我正在使用 Spring RestTemplate 来消费其余服务,并且在我的本地 WAS 设置中一切正常。

但是,当我将代码部署到 QA 环境(较低的环境区域)时,我的日志文件中出现以下错误。

    [4/30/18 17:18:22:355 EDT] 00000207 SystemErr     R org.springframework.web.client.ResourceAccessException: I/O error on POST request for "https://host:port/resourcename": com.ibm.jsse2.util.j: PKIX path building failed: java.security.cert.CertPathBuilderException: PKIXCertPathBuilderImpl could not build a valid CertPath.; internal cause is: 
    java.security.cert.CertPathValidatorException: The certificate issued by CN=XXX Root CA, O="The XXX Services Group, Inc." is not trusted; internal cause is: 
    java.security.cert.CertPathValidatorException: Certificate chaining error; nested exception is javax.net.ssl.SSLHandshakeException: com.ibm.jsse2.util.j: PKIX path building failed: java.security.cert.CertPathBuilderException: PKIXCertPathBuilderImpl could not build a valid CertPath.; internal cause is: 
    java.security.cert.CertPathValidatorException: The certificate issued by CN=XXX Root CA, O="The XXX Services Group, Inc." is not trusted; internal cause is: 
    java.security.cert.CertPathValidatorException: Certificate chaining error
[4/30/18 17:18:22:355 EDT] 00000207 SystemErr     R     at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:607)
[4/30/18 17:18:22:356 EDT] 00000207 SystemErr     R     at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:557)
[4/30/18 17:18:22:357 EDT] 00000207 SystemErr     R     at org.springframework.web.client.RestTemplate.postForObject(RestTemplate.java:357)

我已经使用签名者证书选项导入了端口和主机的证书,但问题仍未解决(还尝试导入根证书)。谁能让我知道可能是什么问题?

标签: springrestcertificateresttemplate

解决方案


正如错误所暗示的,这看起来像您使用的 JVM 不信任其中一个中间证书。

您需要检索整个证书链,而不仅仅是根 CA 证书和服务器证书。您可以使用浏览器或openssl检索证书链。您的客户端 JVM 必须信任证书链中的每个证书。

请参阅以下内容: https ://unix.stackexchange.com/questions/368123/how-to-extract-the-root-ca-and-subordinate-ca-from-a-certificate-chain-in-linux


推荐阅读