ssl 证书不受WebSphere信任

fruv7luv  于 2023-10-19  发布在  其他
关注(0)|答案(6)|浏览(137)

我有一个Web应用程序,它调用通过SSL保护的SOAP Web服务。(https://zzzzzzzzzzzz/xxxxx)。
服务器发送两个证书(根和叶),所以我使用属性导入两个证书:com.ibm.websphere.ssl.retrieveLeafCert
要在websphere上启用ssl验证,我只需将证书添加到websphere:
SSL证书和密钥管理->密钥存储和证书-> NodeDefaultTrustStore ->签名者证书->来自端口的证书:

  • host:主机名称
  • 端口:443
  • 别名:alias

问题是webshipper不信任证书并给我给予此堆栈跟踪,

used by: javax.net.ssl.SSLHandshakeException: SSLHandshakeException invoking `https://------------------------------` : 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: T`he certificate issued by CN=-------------------------------------------------------------------- is not trusted`; internal cause is: 
    java.security.cert.CertPathValidatorException: Certificate chaining error
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.6.0]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:56) ~[na:1.6.0]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:39) ~[na:1.6.0]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:527) ~[na:1.6.0]
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:1338) ~[cxf-rt-transports-http-2.7.4.jar:2.7.4]
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1322) ~[cxf-rt-transports-http-2.7.4.jar:2.7.4]
    at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56) ~[cxf-api-2.7.4.jar:2.7.4]
    at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:622) ~[cxf-rt-transports-http-2.7.4.jar:2.7.4]
    at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62) ~[cxf-api-2.7.4.jar:2.7.4]
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271) ~[cxf-api-2.7.4.jar:2.7.4]
    at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:530) ~[cxf-api-2.7.4.jar:2.7.4]
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:463) ~[cxf-api-2.7.4.jar:2.7.4]
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:366) ~[cxf-api-2.7.4.jar:2.7.4]
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:319) ~[cxf-api-2.7.4.jar:2.7.4]
    at org.apache.cxf.endpoint.ClientImpl.invokeWrapped(ClientImpl.java:354) ~[cxf-api-2.7.4.jar:2.7.4]
    at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:385) ~[cxf-rt-frontend-jaxws-2.7.4.jar:2.7.4]
    ... 100 common frames omitted
`Caused by: 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=--------------------------------------------------------- is not trusted`; internal cause is: 
    java.security.cert.CertPathValidatorException: Certificate chaining error
    at com.ibm.jsse2.o.a(o.java:8) ~[na:6.0 build_20130515]
    at com.ibm.jsse2.SSLSocketImpl.a(SSLSocketImpl.java:549) ~[na:6.0 build_20130515]
    at com.ibm.jsse2.kb.a(kb.java:355) ~[na:6.0 build_20130515]
    at com.ibm.jsse2.kb.a(kb.java:130) ~[na:6.0 build_20130515]
    at com.ibm.jsse2.lb.a(lb.java:135) ~[na:6.0 build_20130515]
    at com.ibm.jsse2.lb.a(lb.java:368) ~[na:6.0 build_20130515]
    at com.ibm.jsse2.kb.s(kb.java:442) ~[na:6.0 build_20130515]
    at com.ibm.jsse2.kb.a(kb.java:136) ~[na:6.0 build_20130515]
    at com.ibm.jsse2.SSLSocketImpl.a(SSLSocketImpl.java:495) ~[na:6.0 build_20130515]
    at com.ibm.jsse2.SSLSocketImpl.h(SSLSocketImpl.java:223) ~[na:6.0 build_20130515]
    at com.ibm.jsse2.SSLSocketImpl.a(SSLSocketImpl.java:724) ~[na:6.0 build_20130515]
    at com.ibm.jsse2.SSLSocketImpl.startHandshake(SSLSocketImpl.java:81) ~[na:6.0 build_20130515]
    at com.ibm.net.ssl.www2.protocol.https.c.afterConnect(c.java:8) ~[na:6.0 build_20130515]
    at com.ibm.net.ssl.www2.protocol.https.d.connect(d.java:20) ~[na:6.0 build_20130515]
    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1043) ~[na:1.6.0]
    at com.ibm.net.ssl.www2.protocol.https.b.getOutputStream(b.java:85) ~[na:6.0 build_20130515]
    at org.apache.cxf.transport.http.URLConnectionHTTPConduit$URLConnectionWrappedOutputStream.setupWrappedStream(URLConnectionHTTPConduit.java:168) ~[cxf-rt-transports-http-2.7.4.jar:2.7.4]
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleHeadersTrustCaching(HTTPConduit.java:1282) ~[cxf-rt-transports-http-2.7.4.jar:2.7.4]
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.onFirstWrite(HTTPConduit.java:1233) ~[cxf-rt-transports-http-2.7.4.jar:2.7.4]
    at org.apache.cxf.transport.http.URLConnectionHTTPConduit$URLConnectionWrappedOutputStream.onFirstWrite(URLConnectionHTTPConduit.java:195) ~[cxf-rt-transports-http-2.7.4.jar:2.7.4]
    at org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:47) ~[cxf-api-2.7.4.jar:2.7.4]
    at org.apache.cxf.io.AbstractThresholdOutputStream.write(AbstractThresholdOutputStream.java:69) ~[cxf-api-2.7.4.jar:2.7.4]
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1295) ~[cxf-rt-transports-http-2.7.4.jar:2.7.4]
    ... 110 common frames omitted
`Caused by: 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: T`he certificate issued by CN=--------------------------------------------  is not trusted`; internal cause is: 
    java.security.cert.CertPathValidatorException: Certificate chaining error
    at com.ibm.jsse2.util.h.b(h.java:39) ~[na:6.0 build_20130515]
    at com.ibm.jsse2.util.h.b(h.java:21) ~[na:6.0 build_20130515]
    at com.ibm.jsse2.util.g.a(g.java:1) ~[na:6.0 build_20130515]
    at com.ibm.jsse2.pc.a(pc.java:36) ~[na:6.0 build_20130515]
    at com.ibm.jsse2.pc.checkServerTrusted(pc.java:19) ~[na:6.0 build_20130515]
    at com.ibm.jsse2.pc.b(pc.java:51) ~[na:6.0 build_20130515]
    at com.ibm.jsse2.lb.a(lb.java:65) ~[na:6.0 build_20130515]
    ... 128 common frames omitted
Caused by: java.security.cert.CertPathBuilderException: PKIXCertPathBuilderImpl could not build a valid CertPath.
    at com.ibm.security.cert.PKIXCertPathBuilderImpl.engineBuild(PKIXCertPathBuilderImpl.java:411) ~[na:na]
    at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:258) ~[na:na]
    at com.ibm.jsse2.util.h.b(h.java:107) ~[na:6.0 build_20130515]
    ... 134 common frames omitted
Caused by: java.security.cert.CertPathValidatorException: The certificate issued by CN=-------------------------------------------------------
    at com.ibm.security.cert.BasicChecker.<init>(BasicChecker.java:111) ~[na:na]
    at com.ibm.security.cert.PKIXCertPathValidatorImpl.engineValidate(PKIXCertPathValidatorImpl.java:178) ~[na:na]
    at com.ibm.security.cert.PKIXCertPathBuilderImpl.myValidator(PKIXCertPathBuilderImpl.java:737) ~[na:na]
    at com.ibm.security.cert.PKIXCertPathBuilderImpl.buildCertPath(PKIXCertPathBuilderImpl.java:649) ~[na:na]
    at com.ibm.security.cert.PKIXCertPathBuilderImpl.buildCertPath(PKIXCertPathBuilderImpl.java:595) ~[na:na]
    at com.ibm.security.cert.PKIXCertPathBuilderImpl.engineBuild(PKIXCertPathBuilderImpl.java:357) ~[na:na]
    ... 136 common frames omitted
Caused by: java.security.cert.CertPathValidatorException: Certificate chaining error
    at com.ibm.security.cert.CertPathUtil.findIssuer(CertPathUtil.java:298) ~[na:na]
    at com.ibm.security.cert.BasicChecker.<init>(BasicChecker.java:108) ~[na:na]
    ... 141 common frames omitted

同样的代码在我的本地示例中进行了测试,简单地使用了Installcert.java,并使用-Djavax.net.ssl.trustStore= jssecaccounts(jssecaccounts是由InstallCert.java生成的文件)运行了我的测试。

bn31dyow

bn31dyow1#

感谢以上所有的回应。能够解决java.security.cert.CertPathValidatorException问题:以下配置的证书链接错误。

  • 发现以下javax属性在WebSphere中返回空值。
  • javax.net.ssl.trustStore,
  • javax.net.ssl.trustStorePassword
  • javax.net.ssl.trustStoreType

欲了解更多详情,请参阅此链接,
java - path to trustStore - set property doesn't work?
1.在WebSphere中配置了如下属性
选择服务器>应用程序服务器> server_name >进程定义> Java虚拟机>自定义属性>新建。
a)javax.net.ssl.trustStore = jre_install_dir\lib\security\caching
示例:C:\Program Files\WebSphere\AppServer\java\jre\lib\security\caclets
B)javax.net.ssl.trustStorePassword = changeit(默认)
c)javax.net.ssl.trustStoreType = jks
欲了解更多详情,请参阅此链接,
http://publib.boulder.ibm.com/infocenter/tivihelp/v2r1/index.jsp?topic=%2Fcom.ibm.isim.doc_6.0%2Finstalling%2Ftsk%2Ftsk_ic_ins_first_security_truststore.htm
配置后,可以在日志中看到证书被添加到信任存储区。
谢谢,乌代·尼拉吉卡

izkcnapc

izkcnapc2#

我测试了上百万个websphere配置。
唯一有效的程序是此链接中描述的程序:
https://xebia.com/blog/mutual-ssl-authentication-using-websphere-application-server-and-cxf/
通过定义cxf intercpter:

<cxf:bus>
 <cxf:outInterceptors>
   <bean class="---------------------.WebsphereSslOutInterceptor" />
</cxf:outInterceptors>
</cxf:bus>

更多详情请参阅:
https://github.com/vlussenburg/websphere-cxf-extensions#websphere-cxf-extensions

bvk5enib

bvk5enib3#

您应该在配置中添加所有证书链。通常证书至少有授权中心的根证书或链类似的证书。
默认情况下,WAS需要签名证书。

oxiaedzo

oxiaedzo4#

这里的问题是证书路径构建器(Java Cert路径API的一部分)无法在SSL握手期间构建证书链。在握手过程中,SSL对等主机将其证书(身份)发送给客户端,为了让客户端信任该特定证书,必须在客户端建立一个信任链,即当您遇到故障时发生的情况。这里的问题是无法创建信任链,因为您在信任库(信任锚)中缺少签名者证书和/或根证书。
请注意,PKIX信任管理器执行“信任范围”验证,这意味着您不需要客户端上的完整证书链来实现与SSL对等体的信任关系,您只需要信任库中的签名者/中间证书。事实上,如果你把叶子证书放在信任库中,这也应该使事情正常工作,因为这表明你对该特定证书有显式的信任,并且不需要证书链验证。

eivnm1vs

eivnm1vs5#

你可以看看下面的technote
如果您处于某个修复包级别,则可以将值com.ibm.websphere.ssl.retrieveLeafCert设置为true,并在 Retrieving from Port 时获取叶证书。

fumotvh3

fumotvh36#

下面是将证书导入到JVM进行HTTPS WS调用的步骤:

A)取得进口证书

1.每个浏览器以不同的方式显示证书,但它们通常非常相似。在浏览器的URL栏上,通常有一个区域,您可以单击该区域以显示SSL证书信息。例如,您可能会在状态栏中看到一个挂锁,单击该挂锁将打开证书信息。打开证书信息后,单击“Certification Path”信息。通常会有一种方法来导出每个签名证书(受信任的根)。以**“Base-64 encoded X.509(.CER)"**格式导出证书。以这种格式导出的文件将是一个ASCII文本文件,在顶部和底部有“开始CERTIFICATE”和“END CERTIFICATE”行。导出签署远程服务器SSL证书的证书后,就可以将它们导入JVM。

B)导入证书

1.启动ikeyman实用程序。实用程序(ikeyman.bat或ikeyman.sh)位于WAS_HOME\bin中。
1.从“密钥数据库文件”菜单中,选择“打开”。
1.在键数据库类型中,选择JKS。
1.在“文件名”字段中,键入cacliterature。
1.在Location字段中,键入WAS_HOME\java\jre\lib\security。
1.在“密码提示”窗口中,在“密码和确认密码”窗口中键入密钥库的密码。默认密码是changeit。单击“确定”。
1.将您为LDAP服务器创建的证书添加到此证书存储中。
1.在主窗口的“密钥数据库内容”区域中,从列表中选择“签名者证书”。点击〖增加
1.在Certificatefilename字段中,浏览并找到为LDAP服务器创建的服务器证书文件,该文件在BinaryDer数据中。验证“位置”字段中是否显示了相应的目录。单击“确定”。
1.在提示符中,键入此证书的标签。例如,键入LDAPCA。单击“确定”。

相关问题