CSharp-easy-RSA-PEM
CSharp-easy-RSA-PEM copied to clipboard
Getting System.NullReferenceException
I'm getting below exception while trying to decrypt the string. "System.NullReferenceException: Object reference not set to an instance of an object.\r\n at CoreEntities.Classes.Utility.RSADecrypt(String input)\r\n at WebAPI.Attributes.ApiAuthorizeAttribute.Authorize(HttpActionContext actionContext)"
Code:-
public static string RSADecrypt(string input)
{
try
{
string priv = File.ReadAllText(HostingEnvironment.MapPath("~/Certificates/consumer.pem"));
RSACryptoServiceProvider privc = Crypto.DecodeRsaPrivateKey(priv);
return Crypto.DecryptString(input, privc);
}
catch (Exception ex)
{
throw ex;
}
}
It is only coming when i deploy my application on windows server 2012 although it's working fine on local machine on iis and via visual studio 2015.
How to fix this?
I am also facing the same issue . @jhakasjk , did you find solution to this?
Found a solution : https://stackoverflow.com/questions/45503830/getting-exception-on-server-when-using-rsa-via-csharp-easy-rsa-pem