SecurityTokenSignatureKeyNotFoundException when validating JWT signature

前端 未结 1 1565

I\'m trying to implement the OpenID Connect specification for my organisation. I\'m using Microsoft\'s OWIN implementation of OpenID Connect in a test relying party applicat

相关标签:
1条回答
  • 2021-01-11 18:07

    The problem is nestled in the exception message here:

    Clause[0] = X509ThumbprintKeyIdentifierClause(Hash = 0xF8A59280B3D13777CC7541B3218480984F421450)

    The token is signed with the default key identifier clause for an X.509 certificate: its thumbprint. The metadata is exposing just the RSA parameters and a name identifier. When the client retrieves the metadata, it sets up an RSA key using this information, not an X.509 thumbprint.

    To correct this error, the signing credentials have to be changed to include the correct name identifier:

    var credentials = new X509CertificateCredentials(
        cert,
        new SecurityKeyIdentifier(
            new NamedKeySecurityKeyIdentifierClause(
                "kid",
                "F8A59280B3D13777CC7541B3218480984F421450")));
    

    This includes the expected identifier in the signature, and the signature is validated successfully.

    0 讨论(0)
提交回复
热议问题