Windows Certificate Manager – Restore Private Key

certificatepkiprivate-keysmartcardwindows 7

This is may sounds very strange but let me explain a situation:
I was using my PKI Private Key installed at Windows Certificate Storage I get token, so I decided to load them to token and delete them from windows' storage. So far, so good.

But now, when I use token key re-appear in Windows Certificate Storage (that is normal as you can see also certificates from smartcards here). But I can export private key! And this is definitely wrong.

I tried to use token only on different machine (where private key was never really stored in storage) and private key is not exportable.

Have you any idea how this could happened? And how to really delete private key from storage? Or why they re-stored, somehow?

Best Answer

I am just "WOW" - I would not call this secure at any way - according to http://seclists.org/fulldisclosure/2006/Apr/164 private keys are not deleted and stay in system WITHOUT any information about this, I used tried to used app in attached link, but it does not work, however I was able to identify private keys with hexa editor in path C:\Users\[USERNAME]\AppData\Roaming\Microsoft\Crypto\RSA\[UID] and delete them permanently from system. I am still kind of shocked this is not a bug but feature.

If you have a certificate installed on HD (i.e. using the MS Enhaced CSP), then, following Microsoft, you can remove it using IExplorer, on the Tools menu, you click Internet Options, then you click the* Content* tab, and then click Remove. This is a well known action described in http://www.microsoft.com/technet/prodtechnol/ie/reskit/6/part2/c06ie6rk.mspx?mfr=true

Doing this, you effectively remove the certificate, but THE PRIVATE KEY REMAINS IN THE HD. You can find a lot of scenarios where this can be a problem. Suppose you go to a friend's home, you install a pkcs12 file containing your certificate and private key with "Medium" security level (the default), then you use it, and when you finishes your work, you remove the certificate (but NO the private key). Then your friend takes your certificate (is a public document) and installs it, having your private key working for him.

The program cleancapi deletes the private keys that are not used by any certificate. Source code: http://dwnl.nisu.org/dwnl?fic=cleancapi_0_2_src.zip Precompiled version: http://dwnl.nisu.org/dwnl?fic=cleancapi_0_2_bin.zip

Related Question