I am trying to sign a stream using the method below but I always get a Cryptographic Exception saying that it is not a valid hash algorithm even though it is listed in the documentation:
byte[] SignData(RSACryptoServiceProvider rsa, Stream stream, string hashName)
{
HashAlgorithm hash = HashAlgorithm.Create(hashName);
byte[] signature = rsa.SignData(stream, hash);
return signature;
}
I am calling it with "SHA256" as the hashName parameter. and the exception is thrown at the line where rsa.SignData() is called.
This is NOT using X509 certificates, it is not a duplicate. BTW see answer below.