I generated a Jwt token but when i tried to verify the token, I could only see my header and payload and for my signature it says that its invalid, even though, I used my public key in the verification process. Below is the code i used to generate the token.
public static string GetToken(string jsonPayload, string path)
{
string pemString = File.ReadAllText(path);
string jwt = string.Empty;
AsymmetricCipherKeyPair keyPair;
using (StreamReader sr = new StreamReader(path))
{
PemReader pr = new PemReader(sr);
keyPair = (AsymmetricCipherKeyPair)pr.ReadObject();
}
RSAParameters rsaParams = DotNetUtilities.ToRSAParameters((RsaPrivateCrtKeyParameters)keyPair.Private);
using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider())
{
rsa.ImportParameters(rsaParams);
jwt = Jose.JWT.Encode(jsonPayload, rsa, Jose.JwsAlgorithm.RS256);
}
return jwt;
}