【问题标题】:Websphere trust.p12 vs cacert storeWebsphere trust.p12 vs cacert 存储
【发布时间】:2019-07-07 12:47:54
【问题描述】:

我们使用 Spring Integration 连接到 https/ssl 外部系统。使用外部主机和端口 443 添加证书后,从端口检索。证书存在。

但应用程序总是失败

>     ERROR 2886 --- [ebContainer : 1] c.i.w.w.servlet.ServletWrapper           : SRVE0014E: Uncaught service() exception root cause
> dispatcherServlet:
> org.springframework.web.util.NestedServletException: Request
> processing failed; nested exception is
> org.springframework.ws.client.WebServiceIOException: I/O error:
> com.ibm.jsse2.util.h: 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=ODC somest Root CA - G1, O=ODC sonst, C=TR is
> not trusted; internal cause is:
>             java.security.cert.CertPathValidatorException: Certificate chaining error; nested exception is
> javax.net.ssl.SSLHandshakeException: com.ibm.jsse2.util.h: 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=ODC somest Root CA - G1, O=ODC sonst, C=PR is
> not trusted; internal cause is:
>             java.security.cert.CertPathValidatorException: Certificate chaining error

如果我运行 keytool 并将证书导入 cacert,则应用程序可以工作。但是这个解决方案不被维护团队接受,因为它没有出现在 websphere 控制台中。 在春季集成请求中有什么可以改变的吗 那么我可以请任何人帮助我了解问题和解决方法吗?

更新

/srv/opt/IBM/WebSphere/AppServer/java/bin/keytool -list -v -keystore /srv/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/config/cells/K1Node01Cell/nodes/K1Node01/trust.p12 -storepass WebAS -storetype PKCS12

显示证书条目...不确定如何确认它是否完整或不正确

问题:

是否应该从端口更新 cacert 文件中检索? cacert 在 websphere jre security 中,而 trust.p12 在 profile/../nodes 中

更新 2

我已启用跟踪并查看以下日志。是 spring 试图调查 cacerts...还是正常,因为它是 WebSphere 使用的 JRE 的一部分

> [18-2-19 13:44:59:154 ] 00000063 SystemOut     O 2019-02-18
> 13:44:59.153  INFO 30426 --- [ver.startup : 0]
> pertySourcedRequestMappingHandlerMapping : Mapped URL path
> [/v2/api-docs] onto method [public
> org.springframework.http.ResponseEntity<springfox.documentation.spring.web.json.Json>
> springfox.documentation.swagger2.web.Swagger2Controller.getDocumentation(java.lang.String,javax.servlet.http.HttpServletRequest)]
> [18-2-19 13:44:59:826 ] 00000063 SystemOut     O keyStore is:
> /srv/opt/IBM/WebSphere/AppServer/java/8.0/jre/lib/security/cacerts
> [18-2-19 13:44:59:826 ] 00000063 SystemOut     O keyStore type is: jks
> [18-2-19 13:44:59:827 ] 00000063 SystemOut     O keyStore provider is:
> [18-2-19 13:44:59:827 ] 00000063 SystemOut     O init keystore
> [18-2-19 13:44:59:906 ] 00000063 SystemOut     O SSLContextImpl: 
> Using X509ExtendedKeyManager com.ibm.jsse2.ay [18-2-19 13:44:59:908 ]
> 00000063 SystemOut     O trustStore is:
> /srv/opt/IBM/WebSphere/AppServer/java/8.0/jre/lib/security/cacerts

【问题讨论】:

  • 为了确定,您确实执行了节点同步并重新启动了应用程序部署到的服务器,对吗?我认为这是应用程序在信任库中获取新证书所必需的。
  • 不知道节点同步,但是重启了很多次[每次小改动后]
  • 您是否还添加了 CA 的根证书和中间证书?
  • 既然您在谈论控制台,我认为这是传统的 WAS 而不是 Liberty?该错误中提到的证书 您在 WebSphere 信任存储签名者证书中看到的证书吗?您检索到哪个信任库?我的猜测是,您将其检索到的不是正在检查的那个;我以前见过这种情况。
  • 如果在您将证书添加到 cacerts 时它可以工作,那么您可能错误地创建了 SSL 连接,覆盖了 WebSphere 的默认设置。确保您的应用程序中没有类似 Security.setProperty("javax.net.ssl.trustStore", "cacerts.jks"); 的代码。还要确保如果证书不是自签名证书,则您已将所有父证书添加到信任库中。

标签: ssl websphere spring-integration truststore


【解决方案1】:

回答你最后一个问题,不,从端口检索不应该更新cacerts。它应该更新您提到的 trust.p12 文件之类的文件。

但是,您的路径表明您确实有一个带有单元和节点的 ND 环境。并且您已导入 NodeDefaultTrustStore。我们总是导入 CellDefaultTrustStore。你可以试试吗?

【讨论】:

  • NodeDefaultTrustStore 具有管理范围 (cell):...:(node):... 我没有看到 cellDefaultTrustStore
  • Hmmm... 是 Cell 的 Node 部分,但根本没有 cell:... 范围内的密钥/信任存储?如果是这样,问题可能与此有关。
  • 对不起,如果圆点让您感到困惑。我使用 ... 而不是节点和单元的名称。我可以屏蔽姓名并明天更新
  • 不,我明白,我在做同样的事情。我在问您是否根本没有任何单元范围的密钥/信任存储?你只有单元和节点范围的?
【解决方案2】:

我关注了 IBM 链接并使用了 useSystemProperties()。这将使用 websphere 中的证书,否则它将在服务器 Java 中查找证书

https://developer.ibm.com/answers/questions/394270/im-using-an-apache-httpclient-to-make-an-outbound/

HttpClient theClient = HttpClientBuilder.create().useSystemProperties().addInterceptorFirst(new RemoveSoapHeadersInterceptor()).build();

【讨论】: