Skip to content

Commit

Permalink
ISSUE-9: Moved initialization of rsa out of else, so it's not dispose…
Browse files Browse the repository at this point in the history
…d too early
  • Loading branch information
Svenskapojkarna committed Dec 4, 2023
1 parent 4a6bda6 commit d2be690
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public static TokenResult CreateJWTToken(Input input)
{
SigningCredentials signingCredentials;
bool isSymmetric = input.SigningAlgorithm.ToString().StartsWith("HS");
using var rsa = RSA.Create();

// If signing algorithm is symmetric, key is not in PEM format and no stream is used to read it.
if (isSymmetric)
Expand All @@ -33,8 +34,7 @@ public static TokenResult CreateJWTToken(Input input)
}
else
// Default is to use stream and assume PEM format.
{
using var rsa = RSA.Create();
{
rsa.ImportFromPem(input.PrivateKey);

signingCredentials = new SigningCredentials(key: new RsaSecurityKey(rsa), algorithm: input.SigningAlgorithm.ToString())
Expand Down

0 comments on commit d2be690

Please sign in to comment.