After publish my site to iis, i get a error as:
Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException: The system cannot find the file specified
My code to read X509Certificate2 from embedded file is:
X509Certificate2 certificate = null;
using (var certStream = typeof(T).Assembly.GetManifestResourceStream(resourceName))
{
using (var memory = new MemoryStream((int)certStream.Length))
{
certStream.CopyTo(memory);
certificate = new X509Certificate2(memory.ToArray(), password);
}
}
this error only occurred in windows server IIS, but if run Kestrel directly and in IIS Express no problem find.
It seams the file is read as unmanaged memory.