using (RSA rsa = RSA.Create())
{
rsa.ImportFromPem(privateKeyString);
byte[] dataToSign = Encoding.UTF8.GetBytes(signData);
byte[] signedData = rsa.SignData(dataToSign, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
signatureBase64 = Convert.ToBase64String(signedData);
}
This code works fine as a Windows Forms application in .NET 6.0. However, it throws a strange error:
The system cannot find the file specified
in an ASP.NET Core 6.0 Web API.
privateKeyString is of the form
-----BEGIN PRIVATE KEY-----
.....
-----END PRIVATE KEY-----
Where is my mistake?
.csprojfile, so we see which packages you have installed.