出站连接的SSL配置不';t在WebSphereLiberty 17.0.0.2中工作

出站连接的SSL配置不';t在WebSphereLiberty 17.0.0.2中工作,ssl,websphere-liberty,sslhandshakeexception,open-liberty,Ssl,Websphere Liberty,Sslhandshakeexception,Open Liberty,我正在尝试将WebSphereLiberty服务器配置为对所有出站连接(实际上是REST调用)使用默认密钥库和信任库,对入站连接使用自定义密钥和信任库。但当尝试调用外部REST服务时,它会失败,并出现SSLHandshakeException。在日志中,我可以看到它使用我的自定义信任库而不是默认信任库。 下面是我的server.xml <?xml version="1.0" encoding="UTF-8"?> <server description="Default serv

我正在尝试将WebSphereLiberty服务器配置为对所有出站连接(实际上是REST调用)使用默认密钥库和信任库,对入站连接使用自定义密钥和信任库。但当尝试调用外部REST服务时,它会失败,并出现SSLHandshakeException。在日志中,我可以看到它使用我的自定义信任库而不是默认信任库。
下面是我的server.xml

<?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>
错误:

[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.

在您的配置中,我没有看到defaultKeyStore和defaultTrustStore的keyStore元素。如果缺少,则会导致outboundSSLConfig为无效的SSL配置。你能不能把它们加起来,看看效果如何

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指向的内容。

我希望在SSL设置中没有定义密钥库和信任库的情况下,liberty服务器会定义defaultKeyStore和defaultTrustStore。defaultTruststore正在使用java的cacerts。不是这样吗?如何将liberty服务器配置为对所有出站连接使用默认java cacerts truststore?liberty不会加载cacerts文件,除非您将其添加到配置中。如果您有使用cacerts文件的场景,那么这是因为连接使用JSSE的默认SSLContext并以某种方式绕过了Liberty SSL。上面是向配置中添加cacerts的示例,我启用了跟踪日志,发现在这两种情况下都使用com.ibm.ssl.contextProvider=IBMJSSE2(com.ibm.ws.ssl.provider.IBMJSSEProvider)。因此,配置的区别在于这两行:[失败];[成功]您将始终在属性中看到com.ibm.ssl.contextProvider=IBMJSSE2。问题是,您是否看到Liberty创建SSLContext?我希望创建一个SSLContext,如果在跟踪中看到它。无效,因为信任库不存在,因此未创建SSLContext。在这种情况下,JAXR将传递给JDK/JSSE。它是这样工作的,但我不明白如果删除出站SSL设置并对“saasSSLConfig”使用“trustStoreRef=”defaultTrustStore“,为什么它也能工作?我可能会遇到一些错误(比如“defaultTrustStore”未定义),或者回过头来使用“saasKeyStore”作为信任库,但它成功了(因此使用了java的defaul cacerts文件)。可能会出现某种错误消息,说您的配置无效,所以它只是被忽略了。但是在您解释的场景中发生的情况是,“defaultTrustStore”是有效配置中的一个,不存在,因此“saasSSLConfig”也是无效配置。因此,如果您的Liberty服务器没有Liberty SSL配置,那么您的服务器入站端口https端口可能没有启动。在这种情况下,JAXR将只传递给JSSE默认SSLContext。
<ssl id="outboundSSLConfig" keyStoreRef="cacertKeyStore" />
<keyStore id="cacertKeyStore" location=<fill in path to your jdk cacerts file> password="changeit" />