2017-08-11 87 views
0

我想配置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. 

回答

0

Liberty不自动加载cacerts。如果需要,您可以创建一个keyStore元素来指向它。所以在上面的例子中,你可以创建一个像这样的配置。

<ssl id="outboundSSLConfig" keyStoreRef="cacertKeyStore" /> 
<keyStore id="cacertKeyStore" location=<fill in path to your jdk cacerts file> password="changeit" /> 

我假设您不需要此配置的密钥,因此我简化为outboundSSLConfig上的keyStoreRef。它将使用keyStoreRef为key和trust所指向的内容。

+0

它的工作原理是这样的,但我不明白为什么它也可以工作,如果删除出站SSL设置并使用'trustStoreRef ='defaultTrustStore''为'saasSSLConfig'?我会期待一些错误(比如'defaultTrustStore'未定义)或者回退以使用'saasKeyStore'作为一个trustStore,但它取得了成功(用java的defaul cacerts文件)。 –

+0

也许应该有某种错误信息说你的配置是无效的,所以它只是被忽略。但是在你解释的场景中会发生什么:“defaultTrustStore”是一个有效的配置,不存在,所以“saasSSLConfig”也是一个无效的配置。因此,如果您的Liberty服务器没有使用Liberty SSL配置,那么您的服务器入站端口https端口可能不会启动。在这种情况下,jaxrs只会传递给JSSE的默认SSLContext。 – Alaine

0

在你的配置我没有看到defaultKeyStore和defaultTrustStore的keyStore元素。如果它们丢失会导致outboundSSLConfig成为无效的SSL配置。你可以请添加他们,看看事情的工作。

+0

嗯,我预计defaultKeyStore和defaultTrustStore通过对案件的自由服务器时,有没有密钥库和信任的SSL设置中定义的定义。而defaultTruststore使用java的cacerts。不是那样吗?如何配置liberty服务器以使用默认java cacerts信任库来保存所有出站连接? –

+0

Liberty不加载cacerts文件,除非将其添加到配置中。如果你有使用cacerts文件的场景,那是因为连接使用了JSSE的默认SSLContext,并绕过了Liberty SSL。将cacerts添加到配置的示例高于 – Alaine

+0

我已启用跟踪日志,并发现在这两种情况下都使用com.ibm.ssl.contextProvider = IBMJSSE2(com.ibm.ws.ssl.provider.IBMJSSEProvider)。所以配置的区别在于以下两行:[FAILS] ; [SUCCESS]

相关问题