Using custom Registration Authority (RA) certificate templates for the Network Device Enrollment Service (NDES)

The Network Device Enrollment Service (NDES) uses two certificate templates for its internal function to make it act as a Registration Authority (RA). These are published during role configuration of the NDES service on the configured certification authority and certificates are requested:

  • CEP Encryption
  • Exchange Enrollment Agent (Offline Request)

These certificate templates are standard templates from the Windows 2000 world (version 1 templates), i.e. they cannot be edited. In addition, the Exchange Enrollment Agent (Offline Request) template is marked as a user template, i.e. during NDES role configuration the certificate is requested in the context of the installing user and then imported into the machine store. At the latest when the certificates are to be renewed after two years, things get complicated here.

It is therefore a good idea to use your own certificate templates for NDES. These can be adapted in terms of their key length, for example. The use of hardware security modules (HSM) is also possible in this way. Even automatic renewal can be configured.

The Network Device Enrollment Service (NDES) provides a way for devices that do not have an identifier in Active Directory (for example, network devices such as routers, switches, printers, thin clients, or smartphones and tablets) to request certificates from a certification authority. For a more detailed description, see the article "Basics: Network Device Enrollment Service (NDES) ".

NDES also uses a certificate template for the connected devices. The setup is described in the article "Configure Device Template for Network Device Enrollment Service (NDES) ". In addition, the service is optionally offered via HTTPS. The setup is described in the article "Enabling Secure Sockets Layer (SSL) for the Network Device Enrollment Service (NDES) ".

Configure your own certificate template for CEP Encryption

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 Encryption template is used to encrypt the certificate request during transfer to the certification authority. The SCEP protocol was originally designed to be used without HTTPS (HTTP over Secure Socket Layer, SSL), so the encryption here is at the protocol level.

The core properties of the template that the NDES process will look for at startup are:

  • Key Usage: Key Encipherment (0x20)
  • Extended Key Usage: Certificate Request Agent (1.3.6.1.4.1.311.20.2.1)

The standard template "CEP Encryption" ("CEP-Verschlüsselung" in German) is used as the starting template, and a copy is created.

Certificate Templates console: context menu of the "CEP Encryption" template with "Duplicate Template"

"Compatibility" tab

If a domain account is used for the NDES service, the permissions on the private keys can be configured directly in the certificate template. For this purpose, the compatibility of the template must be set to Windows Server 2012 R2 in the "Compatibility" tab.

"Properties of New Template", "Compatibility" tab: Certification Authority "Windows Server 2012 R2", Certificate recipient "Windows 8.1 / Windows Server 2012 R2"

"General" tab

A meaningful name is assigned in the "General" tab.

"Properties of New Template", "General" tab: template display name "ADCS Labor CEP Encryption", validity period 2 years

"Request Handling" tab

This is where the permissions on the private key of the issued certificate are set for the service account used by NDES.

If permissions on the private key can be (and should be) set via the template (when NDES is running as a Group Managed Service Account or as a domain account), they can be assigned in the "Request Handling" tab.

"Request Handling" tab: "Authorize additional service accounts to access the private key", key permissions: Service_NDES with Read set to Allow

"Cryptography" tab

In the "Cryptography" tab, a higher key length and optionally a Hardware Security Module (HSM) Cryptographic Service Provider (CSP) can be configured.

Only the "old" Cryptographic Service Providers (CSP) are supported. Key Storage Providers, as available since Windows Server 2008, are not supported by NDES .

The CSP for an HSM must have been previously installed and set up on the NDES system so that it can be used. The system on which the certificate template is configured must also have the CSP installed so that it can be selected when configuring the certificate template.

The CSP for the HSM is only displayed if it is also installed on the system on which the certificate template is configured.

"Cryptography" tab: Legacy Cryptographic Service Provider, minimum key size 4096, provider "Utimaco CryptoServer CSP"

In the NDES installation routine, the Microsoft RSA SChannel Cryptographic Provider is preselected.

"Subject Name" tab

In the "Subject Name" tab, the identity can be created from the Active Directory. It is recommended to fill both Subject (Common Name) and Subject Alternative Name (DNS name).

"Subject Name" tab: "Build from this Active Directory information", subject name format "Common name", "DNS name" selected

"Security" tab

In the "Security" tab, the computer account of the NDES server is given permissions to enroll.

Autoenrollment is also possible, but this is not recommended, as follow-up tasks are required (setting key permissions and restarting the NDES service, if necessary).

"Security" tab: NDES01 (INTRA\NDES01$) with "Enroll" and "Autoenroll" set to Allow

Dialog "Select Users, Computers, Service Accounts, or Groups": object type Computers, name NDES01 entered

In order for computer accounts to be included in the search, the corresponding object type must be selected in the search dialog.

Dialog "Object Types": only "Computers" selected

Configure your own certificate template for Exchange Enrollment Agent (Offline Request)

The Exchange Enrollment Agent template is used to sign the certificate request before it is submitted to the certification authority, ensuring that it actually originates from the NDES service, which is acting as the Registration Authority here.

The core properties of the template that the NDES process will look for at startup are:

  • Key Usage: Digital Signature (0x80)
  • Extended Key Usage: Certificate Request Agent (1.3.6.1.4.1.311.20.2.1)

By default, the certificate request signature is not verified by the certification authority, but this is quite useful and should be configured. How this is done is described in the article "Configure Device Template for Network Device Enrollment Service (NDES) ".

The standard template "Exchange Enrollment Agent (Offline Request)" is not used as the starting template, since it is a user template, whereas the customized template is to be configured for a computer. Instead, the otherwise identical template "Enrollment Agent (Computer)" ("Registrierungs-Agent (Computer)" in German) is used, and a copy is created.

Certificate Templates console: context menu of the "Enrollment Agent (Computer)" template with "Duplicate Template"

"Compatibility" tab

If a domain account is used for the NDES service, the permissions on the private keys can be configured directly in the certificate template. For this purpose, the compatibility of the template must be set to Windows Server 2012 R2 in the "Compatibility" tab.

"Properties of New Template", "Compatibility" tab: Certification Authority "Windows Server 2012 R2", Certificate recipient "Windows 8.1 / Windows Server 2012 R2"

"General" tab

A meaningful name is assigned in the "General" tab.

"Properties of New Template", "General" tab: template display name "ADCS Labor Enrollment Agent (Computer)", validity period 2 years

"Request Handling" tab

This is where the permissions on the private key of the issued certificate are set for the service account used by NDES.

If permissions on the private key can be (and should be) set via the template (when NDES is running as a Group Managed Service Account or as a domain account), they can be assigned in the "Request Handling" tab.

"Request Handling" tab: "Authorize additional service accounts to access the private key", key permissions: Service_NDES with Read set to Allow

"Cryptography" tab

In the "Cryptography" tab, a higher key length and optionally a Hardware Security Module (HSM) Cryptographic Service Provider (CSP) can be configured.

Only the "old" Cryptographic Service Providers (CSP) are supported. Key Storage Providers as they are available since Windows Server 2008, are not supported by NDES .

The CSP for an HSM must have been previously installed and set up on the NDES system so that it can be used. The system on which the certificate template is configured must also have the CSP installed so that it can be selected when configuring the certificate template.

The CSP for the HSM is only displayed if it is also installed on the system on which the certificate template is configured.

"Cryptography" tab: Legacy Cryptographic Service Provider, minimum key size 4096, provider "Utimaco CryptoServer CSP"

In the NDES installation routine, the Microsoft Enhanced Cryptographic Provider v1.0 is preselected.

"Subject Name" tab

In the "Subject Name" tab, the identity can be created from the Active Directory. It is recommended to fill both Subject (Common Name) and Subject Alternative Name (DNS name).

"Subject Name" tab: "Build from this Active Directory information", subject name format "Common name", "DNS name" selected

"Security" tab

In the "Security" tab, the computer account of the NDES server is given permissions to enroll. Autoenrollment is also possible.

"Security" tab: NDES01 (INTRA\NDES01$) with "Enroll" and "Autoenroll" set to Allow

Publish the certificate templates

The two templates can now be published on the certification authority.

Certification Authority console: context menu "Certificate Templates", "New", "Certificate Template to Issue"

Dialog "Enable Certificate Templates": ADCS Labor CEP Encryption and ADCS Labor Enrollment Agent (Computer) selected

Requesting the Registration Authority certificates

Afterwards, the certificates can be requested on the NDES server via the certificate management console for the computer account (certlm.msc).

"Requesting certificates. Please wait...": ADCS Labor CEP Encryption with STATUS: Enrolling..., ADCS Labor Enrollment Agent (Computer) with STATUS: Available

If multiple certification authorities offer the certificate templates described here, a certification authority will be randomly selected during the request process, which may result in certificates being issued by the wrong certification authority. NDES will refuse service in this case. Therefore, the certificate templates described here should only ever be temporarily published on the certification authority for whose NDES server new certificates are currently to be requested.

Set permissions on private keys

If the permissions on the private keys have not been configured in the certificate templates in the "Request Handling" tab, or NDES is running with the identity of the IIS application pool, the permissions on the private keys of both certificates must be set manually. This is done through the computer certificate management console (certlm.msc).

certlm: context menu of an NDES01.intra.adcslabor.de certificate, "All Tasks", "Manage Private Keys..."

The NDES service account requires read permissions to the private keys of both certificates.

Dialog "Permissions for NDES01.intra.adcslabor.de private keys": user SCEP with Read set to Allow

Unfortunately, you cannot configure the SCEP IIS application pool identity from the Certificate Management Console. However, one can find here a PowerShell script with which this can be done.

PowerShell: .\NDESAppPoolKeyPermissions.ps1 lists two certificates with the subject CN=NDES01

External sources