Spring SAML:SAML消息预期目标终结点与收件人终结点不匹配

Spring SAML:SAML消息预期目标终结点与收件人终结点不匹配,spring,spring-security,saml,saml-2.0,spring-saml,Spring,Spring Security,Saml,Saml 2.0,Spring Saml,我收到由以下原因引起的:org.opensaml.xml.security.SecurityException:SAML消息目标端点与收件人端点不匹配“在我的应用程序SP和客户端IdP之间执行SSO时出现异常 服务器日志显示架构中的差异,请参见以下内容: Checking SAML message intended destination endpoint against receiver endpoint 2019-03-05 15:02:44.599 DEBUG [204 default t

我收到由以下原因引起的
:org.opensaml.xml.security.SecurityException:SAML消息目标端点与收件人端点不匹配“
在我的应用程序SP和客户端IdP之间执行SSO时出现异常

服务器日志显示架构中的差异,请参见以下内容:

Checking SAML message intended destination endpoint against receiver endpoint
2019-03-05 15:02:44.599 DEBUG [204 default task-41][BaseSAMLMessageDecoder] Intended message destination endpoint: https://my.app.com/app-gateway/saml/SSO
2019-03-05 15:02:44.599 DEBUG [204 default task-41][BaseSAMLMessageDecoder] Actual message receiver endpoint: http://my.app.com/app-gateway/saml/SSO
2019-03-05 15:02:44.600 ERROR [204 default task-41][BaseSAMLMessageDecoder] SAML message intended destination endpoint 'https://my.app.com/app-gateway/saml/SSO' did not match the recipient endpoint 'http://my.app.com/app-gateway/saml/SSO'
我的应用程序在STG上的两个实例上运行,前面有LB,因此我使用
SAMLContextProviderLB
上下文提供程序,而不是
SAMLContextProviderImpl

<bean id="contextProvider" class="org.springframework.security.saml.context.SAMLContextProviderLB">
        <property name="scheme" value="https"/>
        <property name="serverName" value="my.app.com"/>
        <property name="serverPort" value="443"/>
        <property name="includeServerPortInRequestURL" value="false"/>
        <property name="contextPath" value="/app-gateway"/>
    </bean>

<bean id="metadataGeneratorFilter" class="org.springframework.security.saml.metadata.MetadataGeneratorFilter">
        <constructor-arg>
            <bean class="org.springframework.security.saml.metadata.MetadataGenerator">
                <property name="entityBaseURL" value="https://my.app.com/app-gateway1"/>
                <property name="entityId" value="${cas.sso.entityId}"/>
                <property name="includeDiscoveryExtension" value="false"/>
                <property name="extendedMetadata" ref="extendedMetadata"/>
                <property name="keyManager" ref="keyManager"/>
            </bean>
        </constructor-arg>
    </bean>

您可能希望查看以下页面:

我有一个类似的问题,即使在LB上正确设置了X-Forwarded-Proto,请求仍然只在http中解释。 后端必须知道标头

在http侦听器和两个筛选器引用上添加代理地址转发=“true”

<http-listener name="default" socket-binding="http" proxy-address-forwarding="true"/>  
            <filter-ref name="server-header"/>  
            <filter-ref name="x-powered-by-header"/>  


希望此帮助,

对于运行在AWS应用程序负载平衡器后面的Apache Tomcat服务器,需要启用,以便基于x-forwarded-proto头,Tomcat将相应地覆盖方案(https)和端口(443)

server.xml中

<Valve className="org.apache.catalina.valves.RemoteIpValve" protocolHeader="X-Forwarded-Proto" internalProxies="10\.\d+\.\d+\.\d+|192\.168\.\d+\.\d+|169\.254\.\d+\.\d+|127\.\d+\.\d+\.\d+|172\.(1[6-9]|2[0-9]|3[0-1])\.\d+\.\d+" />


应用服务器和LB之间的通信是如何完成的?Http,https,ajp,还有其他的吗?@SébastienPRAT,谢谢你的评论。LB(梭鱼)通过http与应用程序通信。问题是TLS/SSL卸载。SAML库使用'request.getScheme()'并返回'http'而不是'https',因此收件人检查失败。使用了哪个部署容器?@BernhardThalmayr。谢谢你的回答。WildFly 10.1.0最终版本用作应用程序服务器。你知道吗,我如何改变它并强制它使用https?
<Valve className="org.apache.catalina.valves.RemoteIpValve" protocolHeader="X-Forwarded-Proto" internalProxies="10\.\d+\.\d+\.\d+|192\.168\.\d+\.\d+|169\.254\.\d+\.\d+|127\.\d+\.\d+\.\d+|172\.(1[6-9]|2[0-9]|3[0-1])\.\d+\.\d+" />