Source: Certificate Autoenrollment in Windows Server 2016 (part 3) – PKI Extensions (sysadmins.lv)
Thanks to Vadims Podans for his detailed write up.
Source 2: Basic: How to set up automatic certificate enrollment in Active Directory – Druva Documentation
Source 3 (Official): Configure server certificate auto-enrollment | Microsoft Docs
Autoenrollment configuration in general consist of three steps: configure autoenrollment policy, prepare certificate templates and prepare certificate issuers. Each configuration step is described in next sections.
- Working AD
- Enterprise CA
- Proper Permissions (This post assumed domain admin rights)
Configure Autoenrollment Policy
- Start Group Policy editor. In Active Directory environment, use Group Policy Management Console (gpmc.msc). In workgroup environment, use Local Group Policy Editor (gpedit.msc);
- Expand to
Computer Configuration\Policies\Windows Settings\Security Settings\Public Key Policies
- Double-click on Certificate Services Client – Auto-enrollment;
- Set Configuration Model to Enabled;
- Configure the policy save settings:
- Repeat steps 2-5 for User Configuration node.
*Note 1* You technically don’t *NEED* a policy, the minimum you do need is the registry settings the policy defined. The reason for the policy is obliviously for scalability purposes. The key it defines is:
Key: SOFTWARE\Policies\Microsoft\Cryptography\AutoEnrollment Value: AEPolicy Type: DWORD
Of course HKLM and HKCU will be used depending on which one was defined in the policy, so if you want user auto enrollment ensure the registry is defined in the HKCU. If you want machine auto enrollment ensure it is defined in HKLM.
*Note 2* Vadims doesn’t cover what each value represents, or what possible values are available. I was only able to find this source on it which made the following statements:
The two checkboxes (point 7) control the value of AEPolicy
0 = non
1 = second
6 = first
7= both selected”
Configuring Certificate Templates
This section covers how to configure certificate templates.
The following are the default settings:
- Both domain administrators from the root domain, and enterprise administrators for fresh installations of Windows Server 2003 (and newer) domains may configure templates.
- Certificate template ACLs are viewed in the Certificate Templates MMC snap-in.
- Certificate templates can be cloned or edited using the Certificate Templates MMC snap-in.
- Certificate Template need to be published before they can be used.
- Authenticated Users have Read permission on the Template. (Leave it be)
Creating a new template for the autoenrollment of Web Server Cert
In this exercise we will create certificate template that will be intended for Server Authentication usually for a web server (IIS). As the additional requirement, the certificate will be stored on the server. To create a new template for autoenrollment for a web server:
- Log on to a computer where ADCS Remote Server Administration Tools (RSAT) are installed with Enterprise Admins permissions;
- Press Win+R key combination on the keyboard.
- In the Run dialog box, type certtmpl.msc, and then click Ok.
The Certificate Templates MMC snap-in may also be invoked using the Certification Authority MMC snap-in by selecting the Certificate Templates folder, right-clicking, and then selecting Manage.
- In the console tree, click Certificate Templates.
- In the details pane, right-click the Web Server template, and then click Duplicate Template.
- The Compatibility tab of the new template properties dialog box appears. Configure compatibility settings to minimum OS version that will consume this template and minimum OS version of CA server that will issue certificates based on this template. (In my Lab Server 2016, and client Windows 10)
- On the General Tab, Give it a name, Do not publish in AD. If you want more info on these 2 checkboxes read Vadims guide on creating a smart card cert.
- Click the Request Handling tab. This tab is used to define how the certificate request should be processed. Use default settings in this tab.
- Switch to Cryptography tab:
I use Key Storage Provider, RSA, 2048, Requests can use any provider.
- Switch to Subject Name tab. This tab is used to define how the subject name and certificate properties will be built.
*IMPORTANT* Check off “Use subject information from existing certificates for autoenrollment renewal requests.
- Switch to Security tab. This tab is used to define which users or groups may enroll or autoenroll for a certificate template. A user or group must have the Read, Enroll, and Autoenroll permissions to automatically be enrolled for a certificate template.
In our case any web server computers joined to the domain will be granted Read, Enroll, Autoenroll permissions.
Publishing the Certificate Template
When certificate template is prepared for autoenrollment, it must be added to Enterprise CA server for issuance. This section will describe how to add certificate template to CA for issuance by using Certification Authority MMC snap-in. For examples using certutil, and Powershell see Vadims post.
*Note* Standalone CA does not support certificate templates
Configuring CA using MMC
The most convenient way to add certificate template to CA is to use Certification Authority MMC snap in:
- Log on to CA server or computer with Remote Server Administration Tools installed with CA Administrator permissions;
- Press Win+R key combination on the keyboard;
- In the Run… dialog, type “certsrv.msc”;
- If necessary, click on root node, then press Action menu and select Retarget Certification Authority to connect to desired CA server;
- When connected, expand CA node and select Certificate Templates folder. You will see certificate templates supported for issuance by this CA.
- In Action menu, select New and Certificate Template to Issue menu. In the opened dialog, select target template and press Ok to finish. Ensure that certificate template is listed in Certification Authority MMC console.
Request and Issue Initial Certificate
Now with all the pre-reqs in place. All one has to do is log into the domain joined machine and request a certificate. In our example since we picked Serve 2016 and recipient as Windows 10, the template is saved as a version 4 template.
*Note* Version 3 and 4 templates do not show up under the CA’s web enrollment option.
If everything was done correctly on the client side Certificate snap in for the machine you should be able to see the template listed:
Fill in a common name, and a couple DNS names fields to make browsers SAN requirements happy. Once filled the Enroll option should be available.
Testing and Validating
Well now that we got that, not sure how to test it getting renewed outside of the time going by…
I did discover this command by searching for an answer:
Well that’s doesn’t tell me much… wonder what the office MS source has to say…
Real mature Microsoft… This isn’t new either here’s a bit more deatiled answer from good ol TechNet (RIP).
“Certutil -pulse will initiate autoenrollment requests.
It is equivalent to doing the following in the CertMgr.msc console (in Vista and Windows 7)
Right-click Certificates , point to All Tasks , click Automatically Enroll and Retrieve Certificates .
The command does require that
– any autoenrollment GPO settings have already been applied to the target user or computer
– a certificate template enables Read, Enroll and Autoenroll permissions for the user or a global or universal group containing the user
– The group membership is recognized in the users Token (they have logged on after the membership was added”
This action is available only when you right click the very top “Certificates” node, not the sub folders node under the Personal folder.
So again I wasn’t sure how to validate it will work when time comes, as running the above action in certmgr simply only gave me the option to enroll in the computer certificate template all the other templates were marked as “unavailable” even though I manually enrolled the cert above without issue. Which made me wonder if there’s a difference between auto renewal of a certificate and auto enrollment.
I found this post from a “field Engineer” which seemed to conclude that they are tied together in some form.
“The Autoenrollment Group Policy has to be enabled for this feature to work. This feature will also work on certificates issued prior to enabling it.”
However no other details. From what I can tell.. The command certutil -pulse triggers the following Scheduled Task:
Which AFAIK will only trigger certificate issuance on certs destined to expire, how close to expiry? I’m not sure, there was the option in the template to log @ 10% remaining. I’m not sure that’s the threshold it uses to trigger a certificate renewal.
I’m not sure if there’s a specific parameter you can set to tell it to renew a certificate before this expiry time.
If you know please leave a comment.
Final Note… Ensure you enable the auto rebind feature introduced in IIS 8.5 and later. I’ve had this bite me.