我想配置WebSphere的自由服务器使用的所有出站连接(实际上REST调用)和入站使用自定义的默认密钥库和trustore关键和信任商店。但尝试调用外部REST服务时,SSLHandshakeException会失败。在日志中,我可以看到它使用我的自定义信任库而不是默认信任库。
下面是我的server.xml出站连接的SSL配置不WebSphere的自由工作17.0.0.2
<?xml version="1.0" encoding="UTF-8"?>
<server description="Default server">
<featureManager>
<feature>appSecurity-2.0</feature>
<feature>transportSecurity-1.0</feature>
<feature>jaxrs-2.0</feature>
<feature>json-1.0</feature>
<feature>javaMail-1.5</feature>
<!--<feature>ssl-1.0</feature>-->
</featureManager>
<sslDefault sslRef="saasSSLConfig" outboundSSLRef="outboundSSLConfig" />
<ssl id="saasSSLConfig" keyStoreRef="saasKeyStore" trustStoreRef="saasTrustStore" clientAuthentication="true" sslProtocol="TLSv1" />
<keyStore id="saasKeyStore" location="/opt/ibm/wlp/output/defaultServer/resources/security/sbs_endpoint_keystore.jks" password="pwd" />
<keyStore id="saasTrustStore" location="/opt/ibm/wlp/output/defaultServer/resources/security/serverTruststore.jks" password="pwd" />
<ssl id="outboundSSLConfig" keyStoreRef="defaultKeyStore" trustStoreRef="defaultTrustStore" />
<basicRegistry id="basic" realm="BasicRealm">
<!-- <user name="yourUserName" password="" /> -->
</basicRegistry>
<httpEndpoint id="defaultHttpEndpoint" host="*" httpPort="9080" httpsPort="9443" />
<applicationManager autoExpand="true"/>
</server>
BTW,如果改变saasSSLConfig使用defaultTrustStore而不是saasTrustStore然后一切工作正常。
Server版本:
WebSphere Application Server 17.0.0.2 (1.0.17.cl170220170523-1818) on IBM J9 VM, version pxa6480sr4fp7-20170627_02 (SR4 FP7) (en_US)
错误:
[ERROR] CWPKI0022E: SSL HANDSHAKE FAILURE: A signer with SubjectDN CN=*.api.ibm.com, O=International Business Machines, L=Armonk, ST=New York, C=US was sent from the target host. The signer might need to be added to local trust store /opt/ibm/wlp/output/defaultServer/resources/security/serverTruststore.jks, located in SSL configuration alias saasSSLConfig. The extended error message from the SSL handshake exception is: PKIX path building failed: java.security.cert.CertPathBuilderException: PKIXCertPathBuilderImpl could not build a valid CertPath.;
SSLHandshakeException invoking https://dev.api.ibm.com/scx/test/sbs/customer/222222222: java.security.cert.CertificateException: PKIXCertPathBuilderImpl could not build a valid CertPath.
它的工作原理是这样的,但我不明白为什么它也可以工作,如果删除出站SSL设置并使用'trustStoreRef ='defaultTrustStore''为'saasSSLConfig'?我会期待一些错误(比如'defaultTrustStore'未定义)或者回退以使用'saasKeyStore'作为一个trustStore,但它取得了成功(用java的defaul cacerts文件)。 –
也许应该有某种错误信息说你的配置是无效的,所以它只是被忽略。但是在你解释的场景中会发生什么:“defaultTrustStore”是一个有效的配置,不存在,所以“saasSSLConfig”也是一个无效的配置。因此,如果您的Liberty服务器没有使用Liberty SSL配置,那么您的服务器入站端口https端口可能不会启动。在这种情况下,jaxrs只会传递给JSSE的默认SSLContext。 – Alaine