Certificate without private key after import

The certificate is imported, but the little key icon is missing in the certificate store, IIS does not offer it for the binding, and services report “key does not exist”. Almost always the link to the private key is missing. Whether it can be repaired depends on where the key is.

How it happens

A certificate alone (.cer, .crt) only contains the public key. The private key is created with the CSR and stays where the CSR was created. Typical cases:

Check

Get-ChildItem Cert:\LocalMachine\My | Format-Table Subject, Thumbprint, HasPrivateKey
certutil -store my "<serial number or thumbprint>"

HasPrivateKey = False confirms the problem. With a key, certutil shows the line “Encryption test passed”; without a key it is missing. In IIS this often shows up as the error “A specified logon session does not exist” when creating the binding.

Case 1: the key is still on this server

If the CSR was created on this server, the key is still there, just not linked. certutil looks for the matching key and restores the link:

certutil -repairstore my "<serial number>"
:: CSR created in the user context:
certutil -user -repairstore my "<serial number>"

The serial number is in the certificate details; spaces are fine. Afterwards the key icon appears and the IIS binding works.

Case 2: the key is somewhere else

openssl pkcs12 -export -in server.crt -inkey server.key -certfile chain.pem -out server.pfx \
  -keypbe PBE-SHA1-3DES -certpbe PBE-SHA1-3DES -macalg sha1

The switches at the end make sure older Windows versions can import the file too, see PFX import: password incorrect.

Case 3: the key is lost

Without the private key the certificate is worthless. Create a new CSR and have the CA reissue the certificate. With most CAs this is free during the term and is called “rekey” or “reissue”.

Afterwards: permissions for the service

Once the certificate has its key, the service still needs read access to it: certlm.msc → certificate → All Tasks → Manage Private Keys. Otherwise Schannel event 36870 follows. Examples for SQL Server and Remote Desktop are in the articles SQL Server with TLS and replace the RDP certificate.

FAQ

Can I get the private key from the .cer file?

No. The .cer file only contains the public part. The private key only exists where the CSR was created.

The key is marked as not exportable. What now?

That cannot be changed afterwards. Either use the certificate on the server where it lives, or create a new CSR and have it reissued.

certutil -repairstore reports an error. Why?

Usually the key is not on this server or is in the other context (user instead of computer). Try -user; otherwise look for the key where the CSR was created.

Sources and documentation