0
votes

I'm facing this exception in my authenticated applications with identityserver4:

SecurityTokenInvalidSignatureException: IDX10503: Signature validation failed. Keys tried: 'Microsoft.IdentityModel.Tokens.RsaSecurityKey , KeyId: '. Exceptions caught: ''. token: '{"alg":"RS256","typ":"JWT"}.{"nbf":1501510053,"exp":1501510353,"iss":"http://localhost:5000","aud":"clientId","nonce":"636371068531446271.Nzc2YzRjZGMtN2M0Ny00MGZiLWI3NTQtN2Q2NWIxZGM5MWUyODY2MGE5NTgtYWMzNS00YWJmLWEyMDktNjcwMmJhYTlkYWJk","iat":1501510053,"c_hash":"teGUAAIvU0EY9L1WzjfI2Q","sid":"c870b6184744290472b157ce5992f8e0","sub":"a3915666-8586-476b-9166-b5b183af609e","auth_time":1501508734,"idp":"local","amr":["pwd"]}'.

At this time, I don't have a certificate to use in my Sign in credentials in identity server. So I try this code, sometimes works, but I have sure this is wrong. Someone have a step by step how to use SignInCredentials without a .pfx certificate?

var signinkey = new RsaSecurityKey(RSA.Create());

        var signingCredentials = new SigningCredentials(signinkey,
            SecurityAlgorithms.RsaSha256);

        // Adds IdentityServer
        services.AddIdentityServer()
            .AddSigningCredential(signingCredentials)
...
1

1 Answers

2
votes

Use

services.AddIdentityServer().AddDeveloperSigningCredential()

This will create you a random RSA key pair at first launch and cache it on disk.