Issue
When binding a certificate to an SSL port as detailed in this article, you may run into one of these 2 common errors:
The parameter is incorrect.

SSL Certificate Add Failed, Error: 1312
A specified logon session does not exist. It may have already been terminated.

Environment
Cause
If you are getting the message that "The parameter is incorrect," the certhash likely contains hidden characters that were inadvertently copied from the certificate's thumbprint. In the above screenshot, note the '?' at the beginning of the certhash which is causing the issue.
If you are getting Error Code 1312, the certificate you are attempting to bind likely does not contain the private key.
Diagnosis
If you are getting Error Code 1312, you can determine if the certificate you imported contains the private key by looking at its icon in MMC.
Icon only shows a certificate. The private key needs to be added.

Icon includes a key. While your icon may be slightly different, the presence of a key means the private key is attached.
Solution A (Incorrect Parameter)
- Copy the command into notepad
- Save As ANSI
- Re-open the file
- Remove hidden characters
- Re-try the command
Solution B (Error 1312)
- Create a .pfx file with your certificate and key file using the following command (replace pfx, key, and crt filenames as appropriate):
openssl.exe pkcs12 -export -out ServerName.pfx -inkey ServerName.key -in ServerName.crt
- Remove the previously imported certificate from MMC
- Follow the instructions in this article beginning with the "Installing the Certificate" section
Additional Resources