Configure the Certificate Enrollment Policy Web Service (CEP) to work with a group managed service account (gMSA)

For security reasons, it may make sense to operate the CEP with a group managed service account (gMSA) instead of a normal domain account. This option offers the charming advantage that the password of the account is changed automatically, and thus this step does not have to be done manually, which is unfortunately forgotten far too often.

The Certificate Enrollment Web Services (Certificate Enrollment Policy Web Service, CEP, and Certificate Enrollment Web Service, CES) enable the automatic request and renewal of certificates from a certification authority via a web-based interface. This eliminates the need to contact the certification authority directly via Remote Procedure Call (RPC). For a more detailed description, see the article "Certificate request basics via Certificate Enrollment Web Services (CEP, CES) ".

If CEP was installed according to the instructions described in the article "Installing a Certificate Enrollment Policy Web Service (CEP) ", the service runs with the identity of the application pool after installation.

IIS Manager, "Application Pools": the WSEnrollmentP... application pool uses the identity ApplicationPoolIdentity

If CEP and CES are installed on the same server and a service account with delegation is used, the CEP and CES application pools must be run under the same account.

Requirements for the CEP service account

Do you know TameMyCerts? TameMyCerts is an add-on for the Microsoft certification authority (Active Directory Certificate Services). It extends the function of the certification authority and enables the application of rule sets to realize the secure automation of certificate issuance. TameMyCerts is unique in the Microsoft ecosystem, has already proven itself in countless companies around the world and is available under a free license. It can be downloaded via GitHub and used free of charge. Professional maintenance is also offered.

The CEP service account...

  • must be a member of the IIS_IUSRS local group.
  • requires a Service Principal Name (SPN), which must correspond to the fully qualified server name or the alias to be used, depending on the configuration.

Creating the gMSA for the Certificate Enrollment Policy Web Service

The gMSA for CEP can be created with the following PowerShell command, provided that a KDS root key has been created in the Active Directory forest :

New-ADServiceAccount `
    -Name gMSA_CEP `
    -PrincipalsAllowedToRetrieveManagedPassword CEP01$ `
    -DNSHostName gMSA_CEP.intra.adcslabor.de

The arguments given here mean the following:

  • The Name argument specifies the name of the gMSA.
  • The PrincipalsAllowedToRetrieveManagedPassword argument specifies the server which is allowed to retrieve the service account password.
  • The DNSHostName argument specifies the contents of the account's dNSHostName attribute, since a gMSA technically functions like a computer account.

PowerShell: New-ADServiceAccount -Name gMSA_CEP with -PrincipalsAllowedToRetrieveManagedPassword CEP01$ and -DNSHostName gMSA_CEP.intra.adcslabor.de

Configure the Service Principal Name (SPN) for the gMSA

The following command creates the service principal name (SPN) for the gMSA.

setspn -S HTTP/cep01.intra.adcslabor.de INTRA\gMSA_CEP$

Command prompt: setspn -S HTTP/cep01.intra.adcslabor.de INTRA\gMSA_CEP$ reports "Updated object"

Installing the gMSA on the CEP server

First, the Active Directory management tools for PowerShell must be installed on the CEP server.

Add-WindowsFeature RSAT-AD-PowerShell 

PowerShell: Add-WindowsFeature RSAT-AD-PowerShell reports Success True, Restart Needed No

After that, the service account can be installed on the server with the following PowerShell command.

Install-ADServiceAccount gMSA_CEP

PowerShell: Install-ADServiceAccount gMSA_CEP

The command returns nothing if it was successful.

You can check if this is really the case with the following command line command.

Test-ADServiceAccount gMSA_CEP

PowerShell: Test-ADServiceAccount gMSA_CEP returns True

This command returns True when the gMSA has been successfully installed.

Include gMSA in the IIS_IUSRS group on the CEP server

The configured gMSA must now be added to the local security group IIS_IUSRS so that it can be used by the CEP. This can be done via the management console for local users (lusrmgr.msc).

Properties of the IIS_IUSRS group: member INTRA\gMSA_CEP

Configuring the gMSA in the CEP application pool

For the CEP service to work with the installed gMSA, it must be configured in the WSEnrollmentPolicyServer application pool in the Internet Information Server (IIS) management console. To do this, right-click on the WSEnrollmentPolicyServer application pool and select the "Advanced Settings..." option.

IIS Manager: context menu of the WSEnrollmentP... application pool with the "Advanced Settings..." item highlighted

In the "Identity" option, click on the "..." button on the right side.

Dialog "Advanced Settings": entry "Identity" set to ApplicationPoolIdentity, the button to change it highlighted

In the following dialog, select "Custom account" and click on "Set...".

Dialog "Application Pool Identity": "Custom account" selected, "Set..." button highlighted

When specifying the identity in the following dialog, some special features have to be considered:

  • It is mandatory to specify the domain name.
  • Since a gMSA works similarly to a computer account, a dollar sign must be specified at the end of the account name.
  • With a gMSA, no password is specified, so the two fields must remain empty.

Dialog "Set Credentials": user name INTRA\gMSA_CEP$ with empty password fields

Restarting the Web Server service

The Web Server service is then restarted with the iisreset command.

Command prompt: iisreset stops and restarts Internet Information Services ("Internet services successfully restarted")