Migrating your Microsoft PKI infrastructure to Windows Server 2016 (Part 1)
Migrating your Microsoft PKI infrastructure to Windows Server 2016 (Part 2)
In the second part of this guide I will be migrating my online issuing CA to Windows Server 2016. As before this guide is written as a guide to upgrade from a Windows Server 2012 R2 CA to a Windows Server 2016 CA, however it is equally valid for moving a CA from any older version of Windows server to Windows Server 2016.
The majority of the steps in this guide are identical to the steps for the offline root CA, however there are a few differences as this is a domain joined system and at the end of the guide you will need to re-register any certificate templates you have.
Start by building your new Windows Server 2016 server. I recommend again that you give it the same name as your current issuing CA, although it is possible to change it if you are willing to modify some registry keys later on in the process. If you do give this server the same name do not join it to the domain yet. This will be done later in the guide once the existing issuing CA has been removed from the domain. You should also patch the new server with the latest Microsoft patches at this time.
Migration – Backing up your existing issuing CA server
The first step is to back up the CA using the command
certutil -backup C:\SubCABackup KeepLog. If you do not care about keeping the logs then you can omit the
KeepLog part and instead the logs will be truncated.
You will need to enter a password, remember it and make it complex as this backup contains your issuing CA private key.
The next thing to backup is the CA configuration, which is stored in the registry in the following location:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\CertSvc. Back it up by typing
reg export "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\CertSvc" C:\SubCABackup\CertSvcRegBackup.reg
You now also need to make a record of what certificate templates you have created as these will need to be re-registered on the new CA. The easiest way to do this is to run the command
Certutil -catemplates > "C:\SubCABackup\Catemplates.txt". This pipes the output to a file called Catemplates.txt which you can open later to see the names of the templates.
It is also worth backing up your CAPolicy.inf file which you can do easily enough by copying it into the backup folder by typing
copy C:\Windows\CAPolicy.inf C:\SubCABackup.
Once you have done the work to backup your existing issuing CA it is time to uninstall the CA role. Before doing this run
Get-WindowsFeature in Powershell and have a look at what additional CA features you currently have installed (for example you may have the Web Enrolment service and/or Online Responder roles installed). Make a note of these so that you know what features to install on the new issuing CA server.
To uninstall the certificate authority role use the Powershell command
Remove-WindowsFeature Adcs-Cert-Authority and press enter. If you did have any additional CA roles installed you may need to remove those first; in my case I had to remove the Web Enrollment service (this was done by running
You will need to restart the server to complete the role uninstall.
It is now important that you copy the SubCABackup folder to your new issuing CA as the next step is to remove the existing issuing CA from the domain and power it down.
To remove the old issuing CA from the domain using Powershell type
Remove-Computer HOSTNAME replacing HOSTNAME with the name of your issuing CA. Restart the server to complete the domain removal and then power down the old issuing CA.
Load Active Directory Users and Computer from a management workstation and delete the computer account for the old issuing CA.
Migration – Configuring your new issuing CA and restoring from the backup
Power on your new issuing CA and join it to the domain. You can do this from Powershell by typing in
Add-Computer –DomainName yourdomain.com -Credential YOURDOMAIN\Administrator replacing the domain with your domain and the admin account with your admin account. Restart the server to complete the domain join.
Once the reboot has completed you must install the CA role. Do this using Powershell by typing in
Add-WindowsFeature ADCS-Cert-Authority and pressing enter. As with the root CA this now needs to be configured using the backup from the old issuing CA, which you do with the following Powershell command:
Install-AdcsCertificationAuthority -CAType EnterpriseSubordinateCA -CertFile "C:\SubCABackup\LaptopPoc Sub CA.p12" -CertFilePassword (Read-Host "Enter password" -AsSecureString)
Replace the value after
-CertFile with the path and name of the .p12 file from your issuing CA backup. When you press enter you will be prompted for the password you used to back up your original issuing CA.
If this step is successful you will receive ErrorID 0 as your return code.
Next you need to restore the database and logs. Before you do this the CA service must be stopped. Do that by typing in
net stop certsvc and pressing enter. Once it has stopped restore the database and logs using the command
certutil -f -restore C:\SubCABackup. The -f forces an overwrite of the data that was configured in the barebones CA setup. Once again you must enter the password you used to backup your original issuing CA.
Before starting the CA service you must import the registry configuration. If you opted to change the name of your issuing CA server you need to go through the C:\SubCABackup\CertSvcRegBackup.reg file and replace and reference to the old server name with your new server name. Once this is done you can import the configuration by typing
reg import "C:\SubCABackup\CertSvcRegBackup.reg".
Finish up the restoration process by copying the CAPolicy.inf file back into the Windows directory by using the command
copy C:\SubCABackup\CAPolicy.inf C:\Windows
One final thing
There may be one other thing you need to consider before you can start your new issuing CA and that is the location of the web CRL. This is a website that is likely hosted inside your network that contains an up to date certificate revocation list which your issuing CA needs to have access to before it will start. This may not be a problem for you at all if your web CRL is hosted on an separate web server that you did not touch during this migration. However, if like me your web CRL is hosted on your issuing CA, this will have been lost when you decommissioned your previous issuing CA.
To resolve this you will need to install IIS on your new issuing CA and configure a new site to host your CRL. The URL to the CRL must match the previously configured CRL location, so if it used to be accessible via http://PKI.yourdomain.com then it must still be accessible there now. You can find the URL for your CRL by looking at any certificate issued by your CA, going to the Details pane and looking at the CRL Distribution Points field.
Restoring your certificate templates
With everything else done you can now start your new issuing CA by typing in
net start certsrv. Now you will need to re-register each of the certificate templates you had on your previous issuing CA. Open the Catemplates.txt file you saved by typing
notepad Catemplates.txt and use it as a reference for the names for each of your templates. You will need to run the following command for each one:
certutil -setcatemplates +TEMPLATENAME
Replace TEMPLATENAME with the name of your certificate template. Note that + before the template name.
Do this for each of your templates. Once completed all of your templates will be available again and all issuing permissions will be retained.
That completes the process of migrating your issuing CA to a new server. If you have multiple issuing CA servers you will need to repeat this process for each of them. You may also need to reinstall any additional certificate service roles such as Web Enrollment1, which you can do either in Powershell or by using a management workstation with Server Manager. You should make sure you delete the C:\SubCABackup folder so that you don’t leave your issuing CA private key laying around.
1You may encounter error 0x80070057 when reinstalling the Web Enrollment role. If you do, take a look at this blog post: AD: Certification Authority Web Enrollment Configuration Failed 0x80070057 (WIN32: 87)