Websphere中的证书链接错误

Aya*_*was 5 ssl-certificate websphere-7

我正在尝试从url https://someurl.com使用RESTful服务.我在代码中添加了以下属性:

 Security.setProperty("ssl.SocketFactory.provider", "com.ibm.jsse2.SSLSocketFactoryImpl");
 Security.setProperty("ssl.ServerSocketFactory.provider", "com.ibm.jsse2.SSLServerSocketFactoryImpl");
 Security.setProperty("javax.net.ssl.trustStore", "cacerts.jks");
 Security.setProperty("javax.net.ssl.keyStore", "keystore.jks");
 Security.setProperty("javax.net.ssl.keyStoreType", "pkcs12");
 Security.setProperty("javax.net.ssl.trustStoreType", "JKS");
Run Code Online (Sandbox Code Playgroud)

到目前为止我所做的配置更改是:

  1. 设置com.ibm.websphere.ssl.retrieveLeafCerttrue
  2. 使用url作为someurl和端口443检索证书并将其添加到信任库.
  3. 重启服务器

但我得到以下异常:

java.security.cert.CertPathValidatorException: Certificate chaining error
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=Walmart Root CA, O=Wal-Mart Stores Inc is not trusted; internal cause is:
  java.security.cert.CertPathValidatorException: Certificate chaining error
  at com.ibm.jsse2.o.a(o.java:22)
  at com.ibm.jsse2.SSLSocketImpl.a(SSLSocketImpl.java:423)
  at com.ibm.jsse2.kb.a(kb.java:192)
  at com.ibm.jsse2.kb.a(kb.java:176)
  at com.ibm.jsse2.lb.a(lb.java:53)
  at com.ibm.jsse2.lb.a(lb.java:464)
  at com.ibm.jsse2.kb.s(kb.java:545)
  at com.ibm.jsse2.kb.a(kb.java:530)
  at com.ibm.jsse2.SSLSocketImpl.a(SSLSocketImpl.java:79)
  at com.ibm.jsse2.SSLSocketImpl.h(SSLSocketImpl.java:437)
  at com.ibm.jsse2.SSLSocketImpl.a(SSLSocketImpl.java:142)
  at com.ibm.jsse2.SSLSocketImpl.startHandshake(SSLSocketImpl.java:686)
  at com.ibm.net.ssl.www2.protocol.https.c.afterConnect(c.java:98)
  at com.ibm.net.ssl.www2.protocol.https.d.connect(d.java:13)
  at com.ibm.net.ssl.www2.protocol.https.b.connect(b.java:6)
  at com.dwl.tcrm.tester.RESTClient_2.main(RESTClient_2.java:76)
Run Code Online (Sandbox Code Playgroud)

Gas*_*Gas 17

我假设你有一个Web应用程序,它试图访问该宁静的服务.

首先,您不应该通过javax.net.ssl.*属性设置商店,而是使用WebSphere中提供的SSL配置.所以请评论所有这些setProperty()电话.其次,您必须将服务服务器证书添加到信任库.

登录Web管理控制台:

  • Security > SSL certificate and key management > Key stores and certificates > NodeDefaultTrustStore > Signer certificates
  • 单击Retrieve from port按钮,然后指定主机名,443端口和别名.
  • 点击Retrieve singer information按钮.
  • 验证是否导入了正确的证书(父级).
  • 保存并重新启动.

在某些版本中,子证书是导入的(而不是根目录),在这种情况下,您必须手动下载根证书和中间证书(例如通过浏览器,并将其导入到NodeDefaultTrustStore,但这次使用Add按钮,而不是Retrieve..