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:
- CSR created on server A, certificate imported on server B.
- The CA’s .cer file imported instead of a PFX with key.
- CSR created in the user context, certificate imported into the computer store (or vice versa).
- The pending request was deleted or the server reinstalled.
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
- On another Windows server: complete the certificate there and export it as a PFX with private key, then import it here. This only works if the key was marked exportable.
- As a .key file, for example from a Linux server: combine certificate, key and intermediates into a PFX in the certificate converter and import it. CSR & key match shows whether key and certificate belong together.
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.