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



我正在使用Spring SAML在我的应用程序中实现单点登录。从SSO的角度来看,Everreything是集成的并且可以正常工作。我的应用程序的另一项服务也通过Axis使用HTTP客户端发布,开始失败,出现以下错误

{http://xml.apache.org/axis/}stackTrace:javax.net.ssl.SSLPeerUnverifiedException:ssl对等端未通过名称的主机名验证:null

我已经研究了提供链接的答案Spring Security SAML+HTTPS到另一个页面,并遵循相同的操作,但没有效果。

以下是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>

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

问题中的任何帮助都将被视为

我想这可能就是你想要的:源

您使用的是bean TLSProtocolConfigurer,它更改HTTP客户端中HTTPS协议的可信证书和主机名验证。您可以通过删除这个bean将HTTP客户端的行为恢复到默认值。然后,您需要确保从中加载元数据的实体使用的证书(https://idp.ssocircle.com/idp-meta.xml)在您的cacerts中受信任,或者使用没有https的端点(http://idp.ssocircle.com/idp-meta.xml)。

或者,您可以通过在bean TLSProtocolConfigurer上将属性sslHostnameVerification设置为allowAll来禁用主机名验证。您还需要确保https://www.somepage.com(或其CA)包含在samlKeystore.jks中(请参阅Spring SAML手册)。

您可以在SpringSAML手册的基于HTTP的带SSL的元数据提供程序一章中找到有关TLSProtocolConfigurerbean的更多详细信息。

问题出现在PKIXX509CredentialTrustEnginecheckNames()函数中,我们只检查trustedNames集合中的null,而不是"null or Empty"

尽管我们在TLSProtocolSocketFactorygetPKIXResolver()方法中将trustedNames的值传递为null以创建StaticPKIXValidationInformatonResolver,但该类的构造函数将trustedNames集合重新初始化为空集合
将行从
if(trustedNames == null)更改为

if(trustedNames == null || trustedNames.isEmpty())
为我解决了问题。

相关内容

最新更新