【发布时间】:2018-05-01 13:04:11
【问题描述】:
我正在尝试从我的应用程序连接 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)
我已使用签署者证书选项导入端口和主机的证书,但问题仍未解决(还尝试导入根证书)。谁能让我知道可能是什么问题?
【问题讨论】:
-
这看起来像您使用的 JVM 不信任中间证书之一,如错误所示。我的问题是,客户端(您的代码)和服务器(Rest 服务提供者)是否在同一个 WAS 上?如果没有,并且您使用了“从端口检索”选项,那并不总是检索整个证书链......在这里,您似乎缺少中间证书。如果您使用“添加本地证书”,您是否拥有所有中间证书? ibm.com/support/knowledgecenter/en/SSYGQH_6.0.0/admin/install/…
-
@thecarpy - 客户端和服务器都在不同的服务器上。我已经使用浏览器下载了根证书,并使用签名者证书选项下的添加按钮安装了该证书。
标签: spring rest certificate resttemplate