1

我有一个用 c# 和 Microsoft 的 EncryptedXml 例程加密的 xml 文件。来源是 SamlTool.com 示例响应。下面列出了加密版本,以及公钥和私钥。SamlTool 响应验证器(此处)只是说“解密数据失败”。我可以手动提取加密 xml 的各个部分并使用 c# 库正确解密它(但不是 EncryptedXml,因为它需要证书位于存储而不是文件中)。

我究竟做错了什么?我假设这是一个语法问题,但 SamlTool 模式验证器说没问题。我的下一个想法是在 xml 数据中没有设置一些默认值,这在 SamlTool 和 microsoft 之间是不同的,但我不知道它是什么。

加密的 XML

<?xml version="1.0" encoding="utf-8"?> 
<samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="_8e8dc5f69a98cc4c1ff3427e5ce34606fd672f91e6" Version="2.0" IssueInstant="2014-07-17T01:01:48Z" Destination="http://sp.example.com/demo1/index.php?acs" InResponseTo="ONELOGIN_4fee3b046395c4e751011e97f8900b5273d56685">
  <saml:Issuer>http://idp.example.com/metadata.php</saml:Issuer>
  <samlp:Status>
    <samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success" />
  </samlp:Status>
  <saml:EncryptedAssertion><EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns="http://www.w3.org/2001/04/xmlenc#"><EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc" /><KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#"><EncryptedKey xmlns="http://www.w3.org/2001/04/xmlenc#"><EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5" /><KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#"><X509Data><X509Certificate>MIIDizCCAnOgAwIBAgIJAJd0hkzFSivDMA0GCSqGSIb3DQEBCwUAMFwxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxFTATBgNVBAM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509Data></KeyInfo><CipherData><CipherValue>msGiar1oSAV8ucR7bRr0LxQXoURpYD10M/NW4Uo0WHqXaSCCwqgnnifUXPzB17VW8UtaCCSsUQss9TZVEIor+U1PLEEqfV7/b2TBvcsumyXk/W888KxB6U8LVxfJ2S31oal2ErJgmzbBNm9fBfAgzkZRUS2OHq0ak/fPkcdkV75+hmzizmpkYByZo15AF+wMFNMxXBHH5EspvX8CMFCbw9MgEreqFl3BsvzFzPQeaMQYjl63HceZTIjueYjkaJBHfTaYO63Bjgql1q8wSMnoH8ls/cr+o0U3EYVI3ErabhMjVmDMOIuF5Gq/uBezEXhJyzWFU2Hr948ucrhCTwn0YQ==</CipherValue></CipherData></EncryptedKey></KeyInfo><CipherData><CipherValue>jW2lTGMOYys/maTp7+XNNKmaCLd7vLY+L1UlhdayaerIHbsN+WgfR1yMikRVu8zUuqmP65c1y/sQfm3Xj/Nep3KG246W4bC2WwM4MwTOTZHr09cCHyxGg7rhGmi7nDmP5XSMt3RDH9fB9qlc7wIzagUUzOkefBWZsqT0nEZgxLj5SfLIUgzuk4yzrtIIo3C2353KKT0wOvQXwOzZLqc909ahBhk6aluHg4DQ7kbxJUvrw3WHsPfgayknzc5JbNFHi1iUeyG4WviwrM1/k9DFMOYIAbfbh/QKei8impQBku025m3PUxmIsgv2ahslqnKAaGz57hsqxck2wfUX56/lI/8HzwcDb7MnB+eXQhrwY1RRNmcsd5EQUpI8ACu+YD3PkV+dHHsRoW8pLEHYpqE3jZsgqIfHiNWlE9AtQhNhzxUOCVrm7gCPLbcqI3CRSaiXfwyMQcvArsQKl2keMNltIbHjJi3efpeQqCyto8drQCFDQl9dID08qtoJVeh3eT/+JSINk11lv3fOFd1a7zZaljGwmSAnvIqdk/ep7dE8mCZOcfsfKZAxCBO5abfrarV5IUgHxdRaD6DrkonCwRPpJOj8OMZcOtVIs15DXNhXapEME34oYOvZSEIVlZbPblcvK84DsYd0XZVTW49Ek6gRSaJp2jNTZ2MKgioNuYnOPCfyJVqr/T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