When attempting to install a certificate in IIS7, an alert appears with the following error:
There was an error while performing this operation.
CertEnroll::CX509Enrollment::p_InstallResponse: ASN1 bad tag value met. 0x8009310b
This error is caused by a mismatched private key. If the private key is still on the server, it may be possible to install the certificate and restore the private key. The following resolution may correct the error; if it doesn't work, the certificate must be replaced.
Import certificate in to the Computer certificate store
- Create a Certificate snap-in in a MMC console.
- In the left-hand pane, expand the Certificates folder, expand and select the Personal folder.
- Right-click the Certificates folder inside the Personal folder, select All Tasks, select Import.
- The Certificate Import Wizard opens. Click Next.
- Click Browse and then navigate to the file that contains the SSL certificate. Click Open, then click Next.
- Ensure Place all certificates in the following store is selected, ensure that Personal is listed for Certificate store
- Click Next, then click Finish.
Restore Private Key
- With the MMC console still open, select the Certificates folder inside the Personal folder in the left-hand pane.
- Double-click the newly imported SSL certificate in the right-hand pane, then select the Details tab.
- Scroll down and select the Thumbprint field, then select and copy the entire thumbprint (in the bottom box) to the clipboard.
- Open a command prompt, then enter the following command:
certutil -repairstore my "[certificate thumbprint]"
certutil -repairstore my "00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f"
If successful, the response will be "CertUtil: -repairstore command completed successfully". At this point the certificate can be assigned to the site.
If the certutil command fails, a new CSR will need to be generated and the certificate replaced.
Assign SSL certificate in IIS
- Open the IIS Manager application.
- From the Connections pane on the left, expand the local server, expand the Sites folder and select the web site to be secured with SSL.
- From the Actions pane on the right, select the Bindings option (under Edit Site).
- In the Site Bindings window, select an existing https binding and click Edit. If there are no existing https bindings, click Add.
- Ensure the type is set to https, then select the new SSL certificate from the drop down menu. Click the View button to confirm details of the certificate, if necessary. Click OK, then click Close