Search code examples
c++windowscertificateprivate-keycryptoapi

Certmgr - Self-signed certificate without private key is not updated


I am working with self-signed certificates and certificate manager of Windows OS.

First of all, I have created a self-signed certificate "RootCA" which has a private/public key pair assigned, nevertheless I have destroyed private key of this certificate with the next certutil.exe command succesfully:

certutil -user -delkey "RootCA"

Also, I have check refreshing and exporting private key and it is not possible, because it has been destroyed.

The problem is when I visualize "RootCA" in Certificate Manager after destroying private key, "General" tab indicates that "You have a private key that corresponds to this certificate.":

enter image description here

My question is:

Are there any way to update/remove previous certificate information? And if yes, is it possible to do it programmatically?


Solution

  • With Microsoft CryptoAPI setting pvData parameter of CertSetCertificateContextProperty function to NULL solves the problem.