Adding certificate using X509Store



Hi,

I'm having an odd problem using X509Store.

This code is called from a test winForms app.

public static void Install()
{
X509Certificate2 certificate = new X509Certificate(Resources.certificate, "password");

X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
store.Open(OpenFlags.ReadWrite);

try
{
store.Add(certificate);
}
finally
{
store.Close();
}
}

Resource.certificate is a byte[] containing the public/private certificate.

When I press the corresponding "Install" button in my app I see the private key created in "C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys".
However as soon as I close the test app the private key is deleted - what is going on?
This behaviour occurs on Vista64 + Win2k3_SP2.

Note that if I install using the mmc in Vista or winhttpcertcfg on Win2k3 the private key is installed and stays installed.

Re

.


Loading