2017-06-15 85 views
3

我正在尝试设置IdentityServer以使用ADFS进行身份验证。流程将是:IdentityServer和ADFS

用户 - >自定义应用程序 - > IS - > ADFS

我设置几乎所有的东西,但我被困在IS和ADFS之间的通信。用户似乎在ADFS成功登录,但我得到一个错误:

ID4037:验证签名所需的密钥无法从下面的安全密钥标识符来解决“SecurityKeyIdentifier

当我回来到IS。

很明显,令牌签署证书在一方或另一方存在问题。我试过找不到解释不同证书之间关系的文档。

现在我在签署令牌(使用IdentityServerOptions的SigningCertificate属性进行设置)中有一个自签名证书,并且我在ADFS中配置了AD证书来签署令牌。

有没有关于如何正确地做到这一点的指导或建议?两者应该是相同的还是应该配置别的东西才能使其工作?

编辑 使用Fiddler我可以看到里面的一切ADFS运行良好并在结果公布于IdentityServer误差。张贴在wresult PARAM的XML是:

<t:RequestSecurityTokenResponse xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust"> 
    <t:Lifetime> 
    <wsu:Created xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2017-06-20T12:25:31.148Z</wsu:Created> 
    <wsu:Expires xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2017-06-20T13:25:31.148Z</wsu:Expires> 
    </t:Lifetime> 
    <wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"> 
    <wsa:EndpointReference xmlns:wsa="http://www.w3.org/2005/08/addressing"> 
     <wsa:Address>urn:identityServer</wsa:Address> 
    </wsa:EndpointReference> 
    </wsp:AppliesTo> 
    <t:RequestedSecurityToken> 
    <saml:Assertion MajorVersion="1" MinorVersion="1" AssertionID="_fd1a14cd-4d18-407b-97d4-9f9dfcacd29a" Issuer="http://ssosrv.mydomain.com/adfs/services/trust" IssueInstant="2017-06-20T12:25:31.148Z" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"> 
     <saml:Conditions NotBefore="2017-06-20T12:25:31.148Z" NotOnOrAfter="2017-06-20T13:25:31.148Z"> 
     <saml:AudienceRestrictionCondition> 
      <saml:Audience>urn:identityServer</saml:Audience> 
     </saml:AudienceRestrictionCondition> 
     </saml:Conditions> 
     <saml:AttributeStatement> 
     <saml:Subject> 
      <saml:NameIdentifier>[email protected]</saml:NameIdentifier> 
      <saml:SubjectConfirmation> 
      <saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:bearer</saml:ConfirmationMethod> 
      </saml:SubjectConfirmation> 
     </saml:Subject> 
     <saml:Attribute AttributeName="emailaddress" AttributeNamespace="http://schemas.xmlsoap.org/ws/2005/05/identity/claims"> 
      <saml:AttributeValue>[email protected]</saml:AttributeValue> 
     </saml:Attribute> 
     <saml:Attribute AttributeName="name" AttributeNamespace="http://schemas.xmlsoap.org/ws/2005/05/identity/claims"> 
      <saml:AttributeValue>Name Surname</saml:AttributeValue> 
     </saml:Attribute> 
     <saml:Attribute AttributeName="upn" AttributeNamespace="http://schemas.xmlsoap.org/ws/2005/05/identity/claims"> 
      <saml:AttributeValue>[email protected]</saml:AttributeValue> 
     </saml:Attribute> 
     </saml:AttributeStatement> 
     <saml:AuthenticationStatement AuthenticationMethod="urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport" AuthenticationInstant="2017-06-20T12:25:31.039Z"> 
     <saml:Subject> 
      <saml:NameIdentifier>[email protected]</saml:NameIdentifier> 
      <saml:SubjectConfirmation> 
      <saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:bearer</saml:ConfirmationMethod> 
      </saml:SubjectConfirmation> 
     </saml:Subject> 
     </saml:AuthenticationStatement> 
     <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="#_fd1a14cd-4d18-407b-97d4-9f9dfcacd29a"> 
      <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>6CeXXXXXXXXXXXXXXXXXXXX=</ds:DigestValue> 
      </ds:Reference> 
     </ds:SignedInfo> 
     <ds:SignatureValue>q9hJBFFFFFFFFFFFFFFFFFFFF==</ds:SignatureValue> 
     <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#"> 
      <X509Data> 
      <X509Certificate>MIIFnzXXXXXXXXXXXXXXXXXXXX</X509Certificate> 
      </X509Data> 
     </KeyInfo> 
     </ds:Signature> 
    </saml:Assertion> 
    </t:RequestedSecurityToken> 
    <t:TokenType>urn:oasis:names:tc:SAML:1.0:assertion</t:TokenType> 
    <t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType> 
    <t:KeyType>http://schemas.xmlsoap.org/ws/2005/05/identity/NoProofKey</t:KeyType> 
</t:RequestSecurityTokenResponse> 

谢谢 阿尔伯特

回答

5

解决了它。它与ADFS集成无关,但我如何在Identity Server中设置联合身份验证。我使用了两个联合身份验证身份提供程序:这一个使用ADFS,另一个使用WinAuth。没有回调,来自ADFS的响应由WinAuth处理,所以我为它们中的每一个配置了不同的回调,并且它正在工作。

2

从内存:

  • 您需要将IS证书.CER格式转换。
  • 在mmc中,右键单击证书和“所有任务”/“导出”。
  • 点击导出向导选择: “不,不要导出私钥”。 “DER编码二进制X.509(.CER)”。
  • 选择要导出到的文件名和“保存”。
  • 查看选项和“完成”。
  • 在ADFS向导中,将.cer文件导入到“证书”选项卡中。
+0

我确实改变了它在ADFS和IS中使用相同的证书,我仍然收到错误。无论如何,我正在寻找更多的文档/指南,而不是针对可能有效的特定解决方案,但我不知道为什么。 – Albert

+0

请参阅本文的底部:https://social.technet.microsoft.com/wiki/contents/articles/1420。ad-fs-2-0-id4037-the-key-needed-verify-the-signature-could-be-resolved-the-following-security-key-identifier.aspx - 您可能需要禁用撤销检查 – stombeur

+0

@stombeur我曾尝试过,但仍然得到相同的错误... – Albert