I have an application, and I must use a certificate that requires output from the prompt window.
I have the following code.
SecureString password = GetPassword(); X509Certificate2 certificate = GetCertificate(); var cspParameters = new CspParameters(1, "ProviderName", "KeyContainerName", null, password); certificate.PrivateKey = new RSACryptoServiceProvider(cspParameters);
Everything works fine in a console application, but when I run this code in a Windows service or a console application launched from the task scheduler, then the application freezes on this line.
certificate.PrivateKey = new RSACryptoServiceProvider(cspParameters);
No exceptions, no progress.
I am running the Windows service with the same credentials as the application.
Windows 10 / Windows Server 2012
Do you have any ideas what is wrong?
c # windows-services x509certificate2 private-key
Degusto
source share