当前位置: 首页 > 知识库问答 >
问题:

解密加密数据(SAML2)失败

费承载
2023-03-14

我有一个问题与ADFS身份验证,因为我升级了Spring启动版本从2.2.5。释放到2.5. x

在新版本中,我收到以下错误消息:未能解密EncryptedData

依赖性:

<dependency>
  <groupId>org.springframework.security</groupId>
  <artifactId>spring-security-saml2-service-provider</artifactId>
</dependency>
spring:
  security:
    allowed-groups: "xxx,yyy"
    saml2:
      relyingparty:
        registration:
          ospa:
            signing:
              credentials:
                - private-key-location: file:/applications/tls/file.key
                  certificate-location: file:/applications/tls/file.cer
            identityprovider:
              entity-id: http://ospa.corp.com/adfs/services/trust
              sso-url: https://ospa.corp.com/adfs/ls
              verification:
                credentials:
                  - certificate-location: file:/applications/tls/adfs-certificate.crt

spring:
  security:
    allowed-groups: "xxx,yyy"
    saml2:
      relyingparty:
        registration:
          ospa:
            signing.credentials:
              - private-key-location: file:/applications/tls/file.key
                certificate-location: file:/applications/tls/file.cer
            identityprovider:
              entity-id: http://ospa.corp.com/adfs/services/trust
              verification.credentials:
                - certificate-location: file:/applications/tls/adfs-certificate.crt
              singlesignon.url: https://ospa.corp.com/adfs/ls
              singlesignon.sign-request: true
  • SAML请求
<?xml version="1.0" encoding="UTF-8"?>
<saml2p:AuthnRequest xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol"
                    AssertionConsumerServiceURL="https://intranet.corp.com/login/saml2/sso/ospa"
                    Destination="https://ospa.corp.com/adfs/ls"
                    ForceAuthn="false"
                    ID="XXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
                    IsPassive="false"
                    IssueInstant="2021-10-25T11:40:01.954Z"
                    ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
                    Version="2.0">
    <saml2:Issuer xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">https://intranet.corp.com/saml2/service-provider-metadata/ospa
    </saml2:Issuer>
    <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
        <ds:SignedInfo>
            <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
            <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
            <ds:Reference URI="#ARQeg3e48e-6b33-236d-b000-b5000000d000d">
                <ds:Transforms>
                    <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
                    <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
                </ds:Transforms>
                <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
                <ds:DigestValue>xxxejYgwFdH+jEjBnAZpDgrOh5epA0puLYmthxhYxa=</ds:DigestValue>
            </ds:Reference>
        </ds:SignedInfo>
        <ds:SignatureValue>
            gZfewwevtIxxxxxwefvQ6xxx3/wJePlwPqIPOdCfI0sefffJ2Krqjwkuzkzukzuefw/YbaptteFT&#13;
            TbpX+Lhtrhrthrthhjmbbttt7hVxvNzukzukxxxxuzuOfKitXG4qewZspJj74ucqOOzukzukzuJy&#13;
            lAttYztjztjztxxxxliztbrthrthhhMwFjWgmp7jxJAl3z+Ub2cANjw77rLATvRnh+oh6DaujF0w&#13;
            mqT+Pxrthxxx834jh1238387f1238fh37437f12f7812fh8offeeddT2PJgoePuVk+Dw3r/Bz2rs&#13;
            BrtfqijP9bs1kfKOtRXLdKfofof/xb2AgKtrxw==
        </ds:SignatureValue>
    </ds:Signature>
</saml2p:AuthnRequest>
  • 重新分析:/
  • SAML请求:
<?xml version="1.0" encoding="UTF-8"?>
<saml2p:AuthnRequest xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol"
                    AssertionConsumerServiceURL="https://intranet.corp.com/login/saml2/sso/ospa"
                    Destination="https://ospa.corp.com/adfs/ls"
                    ID="XXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
                    IssueInstant="2021-10-22T11:21:47.075Z"
                    ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
                    Version="2.0">
    <saml2:Issuer xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">https://intranet.corp.com/saml2/service-provider-metadata/ospa</saml2:Issuer>
</saml2p:AuthnRequest>
  • 西格尔:http://www.w3.org/2001/04/xmldsig-more#rsa-sha256
  • 2.vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvSPMXXXX==
  • Saml回应:
<samlp:Response ID="_XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
                Version="2.0"
                IssueInstant="2021-10-21T12:28:24.104Z"
                Destination="https://intranet.corp.com/login/saml2/sso/ospa"
                Consent="urn:oasis:names:tc:SAML:2.0:consent:unspecified"
                InResponseTo="ARQxxxb0fd-xxxx-xxxx-xxxx-9da0cxxx0a37"
                xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
    <Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion">http://ospa.intranet.com/adfs/services/trust</Issuer>
    <samlp:Status>
        <samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success" />
    </samlp:Status>
    <Assertion ID="_dea92497-1dcb-4ecf-a856-42c90ad39541"
                IssueInstant="2021-10-21T12:28:24.104Z"
                Version="2.0"
                xmlns="urn:oasis:names:tc:SAML:2.0:assertion">
        <Issuer>http://ospa.intranet.com/adfs/services/trust</Issuer>
        <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
            <ds:SignedInfo>
                <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
                <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" />
                <ds:Reference URI="#_dea9xxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx">
                    <ds:Transforms>
                        <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
                        <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
                    </ds:Transforms>
                    <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
                    <ds:DigestValue>xxxxHGxxx/LbGx+QddCxxxxGbfYxxxxhn0v0Ldrxxxx=</ds:DigestValue>
                </ds:Reference>
            </ds:SignedInfo>
            <ds:SignatureValue>xxxxJimmzRM+xyQNddwOSeJdddvda851gTVgnheMDxA52ZbYWcVO2DYqdQo7Px40p/K3xmsi03GiibeqZXsI0vHUBZdde0CZEddsB0SjW00bNsqhPD0zYEt0r0g1Zq5PFA6IaZdd+ddUi+lVq3sGZqCmiMjiVIHmr7dhOR4FvIGP8X/tggXDDO/JxA1b000MYbWr5XPddR0y00JrBE5FjN/IfJcAvA1uvpF0iirPUriShqqQAhvXgCo0JIxAODDIyCgNCHdY22tOktQtSgqZAgYHy0inz0kOWqFsXDsKEOm0r0Owz0/0RfwBgr/wR00t0FePaI0L0YnfAI00hcxxxx==</ds:SignatureValue>
            <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
                <ds:X509Data>
                    <ds:X509Certificate>...</ds:X509Certificate>
                </ds:X509Data>
            </KeyInfo>
        </ds:Signature>
        <Subject>
            <NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">GROUP\Account</NameID>
            <SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
                <SubjectConfirmationData InResponseTo="ARQ12bc7bv-xxxx-xxxx-xxxx-0ra0c00000a01"
                                        NotOnOrAfter="2021-10-21T12:33:24.104Z"
                                        Recipient="https://intranet.corp.com/login/saml2/sso/ospa" />
            </SubjectConfirmation>
        </Subject>
        <Conditions NotBefore="2021-10-21T12:28:24.104Z"
                    NotOnOrAfter="2021-10-21T13:28:24.104Z">
            <AudienceRestriction>
                <Audience>https://intranet.corp.com/saml2/service-provider-metadata/ospa</Audience>
            </AudienceRestriction>
        </Conditions>
        <AttributeStatement>
            <Attribute Name="http://corp.com/ad/memberOf">
                <AttributeValue>CN=xxx,OU=xxx,OU=xxx,DC=CENTER,DC=CORP</AttributeValue>
                <AttributeValue>CN=xxx-users,OU=xxx,OU=xxx,DC=CENTER,DC=CORP</AttributeValue>
            </Attribute>
        </AttributeStatement>
        <AuthnStatement AuthnInstant="2021-10-21T12:28:24.042Z"
                        SessionIndex="_dea92497-xxxx-xxxx-xxxx-42c90ad3xxxx">
            <AuthnContext>
                <AuthnContextClassRef>urn:federation:authentication:windows</AuthnContextClassRef>
            </AuthnContext>
        </AuthnStatement>
    </Assertion>
</samlp:Response>
  • 重新分析:/
<samlp:Response ID="_853bf633-xxxx-xxxx-xxxx-xxxx9962c9ba"
                Version="2.0"
                IssueInstant="2021-10-21T14:31:45.743Z"
                Destination="https://intranet.corp.com/login/saml2/sso/ospa"
                Consent="urn:oasis:names:tc:SAML:2.0:consent:unspecified"
                InResponseTo="ARQ0b0f598-xxxf-xxxx-xxxx-xxxxf3b9b1xx"
                xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
    <Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion">http://ospa.intranet.com/adfs/services/trust</Issuer>
    <samlp:Status>
        <samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success" />
    </samlp:Status>
    <EncryptedAssertion xmlns="urn:oasis:names:tc:SAML:2.0:assertion">
        <xenc:EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element"
                            xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
            <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc" />
            <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
                <e:EncryptedKey xmlns:e="http://www.w3.org/2001/04/xmlenc#">
                    <e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p">
                        <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
                    </e:EncryptionMethod>
                    <KeyInfo>
                        <ds:X509Data xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
                            <ds:X509IssuerSerial>
                                <ds:X509IssuerName>CN=CORP CERT, OU=KIR, O=CORP, DC=CORP, C=COM</ds:X509IssuerName>
                                <ds:X509SerialNumber>1000104020028032808734893034101106804152633690</ds:X509SerialNumber>
                            </ds:X509IssuerSerial>
                        </ds:X509Data>
                    </KeyInfo>
                    <e:CipherData>
                        <e:CipherValue>xxxxvgWtSD0rPTkT+XzClVWRLGlRgWNbumeoXJqHsYWluXe1qqDmzRjn3WX2xxxxxXs6E7AhbC5hUMFuCZ2FUM9QR9h6jSpHDZRaYOnomAvReog58EclxxxxMox+Wvfxi/Tg9mm/Xnfvvh4nxxxxDki+lXSSJhQ2hMHphUhKhd4ZiV/XCQyhUdOXzJ3QOJDD94HI2OkquW+7GHrGH0prCHFYfMQxxxOTYYBDSez8VxxxxmR6li/PWBVxvuAKZgRO0JaMjnmwHBCxxxxZcOBsRPmVzjMk5Z6HaF2xB8DNwW7lpPcAQAIYQ0SUR8uIGk4angoi00ppIBzqn1WJMuExxxx==</e:CipherValue>
                    </e:CipherData>
                </e:EncryptedKey>
            </KeyInfo>
            <xenc:CipherData>
                <xenc:CipherValue>qyw+ccS8PD4xxxxZPMTrFabX6OFrdxxxxKds4PgIngwduLKf+82L4k3NNlhvwTMHccxRxxxxr69cFXg6E2OSK2pWXhTMwcNdydoA1cFxxxxsoDEmoKUy3ZhZnOgkSUzePtBikxxxx0V8PTl9iakjJxxxxbXlr0m2MXMTZPDNzcK4KxxxxDuvLUBWmo4p2XE2e85wunBWYgHW4YSDnUuy0MP3+z6PxxxxM5vEEkADxD5IDQxjVDxxxxr0hgjpchLAysHr+yL4N4VSFCtxd1CQbJpu18rxTZPZsY0qaGUQwm8cSq/3+3LCQctKTqyxFvZCdC6Ni8S6Ldh1wHdu6sX0C2F7kmxrjcWPi2h8g8t6XYj9SnqeAfMZcZ/r//whbrBQzGR76x2OolZr15JQw53yYCd...</xenc:CipherValue>
            </xenc:CipherData>
        </xenc:EncryptedData>
    </EncryptedAssertion>
</samlp:Response>

我错过什么了吗?我不明白为什么请求和响应发生了变化,设置几乎相同。我还需要显式配置吗?

共有1个答案

宰父才
2023-03-14

您确定您没有更改ADFS配置吗?在您对ADFS的第一次响应中,断言没有加密,但在第二次响应中是加密的。这不应该因为Spring中SP sode的更新而改变。

查看ADFS方面,看看是否有人启用了加密断言。

可能是ADFS使用不同的密钥进行签名和加密。如果您没有在Spring中配置来自ADFS的加密凭据,则会收到此错误。

 类似资料:
  • 前面小节介绍了如何存储密码,但是有的时候,我们想把一些敏感数据加密后存储起来,在将来的某个时候,随需将它们解密出来,此时我们应该在选用对称加密算法来满足我们的需求。 base64加解密 如果Web应用足够简单,数据的安全性没有那么严格的要求,那么可以采用一种比较简单的加解密方法是base64,这种方式实现起来比较简单,Go语言的base64包已经很好的支持了这个,请看下面的例子: package

  • 我尝试在服务器上进行gpg加密/解密,对于加密,我使用以下命令行: 我想要找到原因:同一个用户有2个不同的密钥和1个秘密密钥。但现在又出现了一个问题:我删除了错误的键,并再次进行相同的测试。 解密后的答案是: 您需要一个密码短语来解锁用户的密钥:“Droli Mail_Adress”2048位RSA密钥,ID 6D2F1BE9,创建2017-07-19(主密钥ID 09C41BAC) 没有关于gp

  • 因此,这种特殊的异常非常常见,但我的问题与通常被问到的略有不同。 我有一个AES解密和加密函数,定义如下: 现在,如果我像这样执行单个解密: 字节数组输出很好。而如果我执行双重加密/解密: 我得到了著名的<code>javax.crypto。BadPaddingException:给定的最终块未正确填充异常。请注意,和只是整数(假设它们都是0)。目前,IVBytes只是一个大小为16的空字节数组,

  • 我正在尝试使用KMS和AWS加密SDK加密数据。查看AWS文档中提供的示例,似乎没有地方可以显式设置数据键。 使用由KMS生成的数据密钥使用AWS加密SDK加密数据的推荐方法是什么?

  • 我正在尝试用python中的pycrypto加密/解密。在大多数情况下,事情进展顺利,但在解密数据时,我遇到了一个奇怪的问题。我尝试对一些JPG进行加密/解密以进行测试,尽管它们加密/解密没有问题,但解密的文件无法打开/已损坏。为了找到问题,我保存了一个文本文件,其中有一个类似于“测试这个文件的完整性”之类的随机句子,它只有在“…完整性”之类的内容之后才能正确解密,完整性之前的所有内容仍然是乱码。

  • 问题内容: 我们正在使用bcrypt来存储不需要解密的密码和数据。 应该采取什么措施来保护其他这样做的用户信息。对于此示例,假设我们不希望用户的真实姓名采用纯文本格式,以防有人获取数据库。 这是一些敏感数据,但还需要不时调用并以纯文本显示。有没有简单的方法可以做到这一点? 问题答案: 您可以使用crypto模块: 编辑 现在 createCipher 和 createDecipher 已被弃用,而