【问题标题】:InvalidSignatureException: Signature is invalidInvalidSignatureException:签名无效
【发布时间】:2020-02-24 11:15:36
【问题描述】:

我正在尝试将 ITFoxtec-saml 与 Auth0 一起用作 IdP。但在 ACS 上,我收到以下错误:

ITfoxtec.Identity.Saml2.Cryptography.InvalidSignatureException: Signature is invalid.
   at ITfoxtec.Identity.Saml2.Saml2Request.ValidateXmlSignature(SignatureValidation documentValidationResult) in C:\Documents\Repos\ITfoxtec.Identity.Saml2-master\ITfoxtec.Identity.Saml2-master\src\ITfoxtec.Identity.Saml2\Request\Saml2Request.cs:line 237
   at ITfoxtec.Identity.Saml2.Saml2Request.Read(String xml, Boolean validateXmlSignature) in C:\Documents\Repos\ITfoxtec.Identity.Saml2-master\ITfoxtec.Identity.Saml2-master\src\ITfoxtec.Identity.Saml2\Request\Saml2Request.cs:line 204
   at ITfoxtec.Identity.Saml2.Saml2Response.Read(String xml, Boolean validateXmlSignature) in C:\Documents\Repos\ITfoxtec.Identity.Saml2-master\ITfoxtec.Identity.Saml2-master\src\ITfoxtec.Identity.Saml2\Request\Saml2Response.cs:line 66
   at ITfoxtec.Identity.Saml2.Saml2AuthnResponse.Read(String xml, Boolean validateXmlSignature) in C:\Documents\Repos\ITfoxtec.Identity.Saml2-master\ITfoxtec.Identity.Saml2-master\src\ITfoxtec.Identity.Saml2\Request\Saml2AuthnResponse.cs:line 214
   at ITfoxtec.Identity.Saml2.Saml2PostBinding.Read(HttpRequest request, Saml2Request saml2RequestResponse, String messageName, Boolean validateXmlSignature) in C:\Documents\Repos\ITfoxtec.Identity.Saml2-master\ITfoxtec.Identity.Saml2-master\src\ITfoxtec.Identity.Saml2\Bindings\Saml2PostBinding.cs:line 106
   at ITfoxtec.Identity.Saml2.Saml2PostBinding.UnbindInternal(HttpRequest request, Saml2Request saml2RequestResponse, String messageName) in C:\Documents\Repos\ITfoxtec.Identity.Saml2-master\ITfoxtec.Identity.Saml2-master\src\ITfoxtec.Identity.Saml2\Bindings\Saml2PostBinding.cs:line 96
   at ITfoxtec.Identity.Saml2.Saml2Binding`1.Unbind(HttpRequest request, Saml2Response saml2Response) in C:\Documents\Repos\ITfoxtec.Identity.Saml2-master\ITfoxtec.Identity.Saml2-master\src\ITfoxtec.Identity.Saml2\Bindings\Saml2Binding.cs:line 70
   at TestWebAppCore.Controllers.AuthController.AssertionConsumerService() in C:\Documents\Repos\ITfoxtec.Identity.Saml2-master\ITfoxtec.Identity.Saml2-master\test\TestWebAppCore\Controllers\AuthController.cs:line 58

【问题讨论】:

    标签: saml-2.0 auth0 itfoxtec-identity-saml2


    【解决方案1】:

    如果签名有效,ITFoxtec Identity SAML 2.0 组件应该接受签名。我不知道验证 Auth0 令牌的问题。

    要调试,您可以检查签名算法和证书是否正确。也许还可以尝试将证书验证模式设置为无,将吊销模式设置为不检查。

    配置示例:

      "Saml2": {
        ...
        "SignatureAlgorithm": "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256",
        "CertificateValidationMode": "None",
        "RevocationMode": "NoCheck"
        ...
      }
    

    【讨论】:

    • 谢谢,原来Auth0的默认签名算法是SHA1,改成rsa,问题解决了。
    • 我在 1) 签名文件更改时遇到了这种类型的错误(我们不知道更改) 2) 如果您错误地在签名文件的开头出现了一个空行 (这将是无效的 xml)
    • 我在 Auth0 中遇到了同样的问题。我在 Auth0 令牌中注意到它有<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/> - 如果它存在而不是配置中指定的算法,是否有办法让这个库使用令牌中的算法?不必像参考代码中那样提前对签名进行硬编码会很好。
    • 您可以配置为使用 SHA1,例如在配置文件中。但出于安全原因,该库将只接受配置的算法。
    • @AndersRevsgaard 感谢您的回复。我在任何地方都看不到 SAML 元数据 XML 中的签名算法。是否有标准方法来确认正在使用的算法,还是我只需要询问 IdP 让我知道他们使用什么算法?
    猜你喜欢
    • 2017-10-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-08
    • 2016-12-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多