Esempio n. 1
0
        public void Options_GlobalEnableSha256Signatures_DoesntBreakJwtSecurityTokenHandler()
        {
            // The JWT security token handler that is used by IdentityServer3
            // uses the global CryptoConfig. This has been causing issues
            // when registering the Sha256 algorithm globally, where this
            // alters the result of the JWT signature handler lookup.

            Options.GlobalEnableSha256XmlSignatures();

            var cert = SignedXmlHelper.TestCert;

            var token = new JwtSecurityToken(
                new JwtHeader(new X509SigningCredentials(SignedXmlHelper.TestCert2)),
                new JwtPayload(Enumerable.Empty <Claim>()));

            var handler = new JwtSecurityTokenHandler();

            handler.Invoking(h => h.WriteToken(token))
            .ShouldNotThrow();
        }