Spring security Spring SAML配置正在中断其他http连接

Spring security Spring SAML配置正在中断其他http连接,spring-security,saml-2.0,spring-saml,Spring Security,Saml 2.0,Spring Saml,我正在使用SpringSAML在我的应用程序中实现单点登录。从SSO的角度来看,Evreything是集成的,可以正常工作。 我的应用程序的另一个服务也通过Axis使用HTTP客户机post,该服务开始失败,出现以下错误 {}stackTrace:javax.net.ssl.SSLPeerUnverifiedException:ssl对等主机名验证失败,名称为null 我已经研究了提供链接的答案 照样做,但没有用 以下是TLSProtocolSocketFactory的配置 <be

我正在使用SpringSAML在我的应用程序中实现单点登录。从SSO的角度来看,Evreything是集成的,可以正常工作。 我的应用程序的另一个服务也通过Axis使用HTTP客户机post,该服务开始失败,出现以下错误

{}stackTrace:javax.net.ssl.SSLPeerUnverifiedException:ssl对等主机名验证失败,名称为null

我已经研究了提供链接的答案 照样做,但没有用

以下是TLSProtocolSocketFactory的配置

    <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
    <property name="targetClass" value="org.apache.commons.httpclient.protocol.Protocol"/>
    <property name="targetMethod" value="registerProtocol"/>
    <property name="arguments">
        <list>
            <value>https</value>
            <bean class="org.apache.commons.httpclient.protocol.Protocol">
                <constructor-arg value="https"/>
                <constructor-arg>
                    <bean class="org.springframework.security.saml.trust.httpclient.TLSProtocolSocketFactory">
                        <constructor-arg ref="keyManager"/>
                        <constructor-arg><null/></constructor-arg>
                        <constructor-arg value="allowAll"/>
                    </bean>
                </constructor-arg>
                <constructor-arg value="443"/>
            </bean>
        </list>
    </property>
</bean>

https
我也在samlKeystore.jks中导入了其他服务的证书


在这个问题上的任何帮助都将受到感谢

我想这可能是您正在寻找的:

您正在使用bean
TLSProtocolConfigurer
,它更改HTTP客户端中HTTPS协议的受信任证书和主机名验证。通过删除此bean,可以将HTTP客户端的行为恢复为默认值。然后,您需要确保加载元数据()的实体使用的证书在您的cacerts中受信任,或者使用不带https()的端点

或者,您可以通过在bean
TLSProtocolConfigurer
上将属性
sslHostnameVerification
设置为
allowAll
来禁用主机名验证。您还需要确保的HTTPS证书(或其CA)包含在samlKeystore.jks中(请参阅)


您可以在中找到有关
TLSProtocolConfigurer
bean的更多详细信息。

问题在于
PKIXX509CredentialTrustEngine
checkNames()
函数中,我们正在检查
trustedNames
集合是否仅为
null
,而不是
“null或Empty”


即使我们在
TLSProtocolSocketFactory
getPKIXResolver()
方法中将trustedNames的值传递为null,以创建
静态PKIxValidationFormatonResolver
,此类的构造函数将
trustedNames
集合重新初始化为空集合。
将行从
if(trustedNames==null)
更改为


if(trustedNames==null | | trustedNames.isEmpty())

为我解决了这个问题。

谢谢@blur0224。我已经在上面的问题中发布了相同的链接,并按照说明进行了操作。即使删除了上面提到的bean,我仍然会得到异常
code
faultDetail:{}stackTrace:javax.net.ssl.SSLException:org.opensaml.ws.soap.client.http.TLSProtocolSocketFactory.verifyHostname(TLSProtocolSocketFactory.java:153)上的主机名验证错误在org.opensaml.ws.soap.client.http.TLSProtocolSocketFactory.createSocket(TLSProtocolSocketFactory.java:118)上,如果您试图使用具有自签名证书的java连接到Web服务,也会出现此错误。Java需要通过将证书添加到JKS来显式信任证书。您是否可能在同一时间切换到另一个JDK或更新到新的JDK,但可能没有加载该CA?我在samkeystore.jks和jre cacerts中都加载了站点CA。我看到的一个观察结果是,当我使用Spring TLSSocketProtocolFCative时,Opensaml TLSProtocolFactory主机的verifyHostname函数中的值总是为null,当从sslssion.getPeerHost()检索时……有人找到了解决方案吗?请帮忙。