I want to create an X509Certificate2
object in my C# by importing a Certificate which contains private key.
This certificate I have exported from my Database using the following LOC –
BACKUP CERTiFiCATE TestCert
TO FiLE = 'C:\Avdhut\TestCert1.cer'
WiTH PRiVATE KEY
(
FiLE = 'C:\Avdhut\TestCertWithPrivateKey.cer',
ENCRYPTiON BY PASSWORD = 'wiND0w5'
)
I have the following C# code –
X509Certificate2 cert = new X509Certificate2(@"C:\Avdhut\TestCertWithPrivateKey.cer", "wiND0w5");
It however throws an exception stating –
CryptographicException was unhandled
Cannot find the requested object