Skip to content

Autoenrollment and Renewal

With autoenrollment, Windows requests the certificates of templates that allow it and renews them before they expire, with no one at the computer. The template must have Allow autoenrollment checked in its Windows settings (Request Handling tab).

Computers

Off-domain computers

  1. Add the policy as SYSTEM. Autoenrollment runs as SYSTEM and uses the username and password kept for SYSTEM, while -Credential keeps them only for the account that runs the command. In a PowerShell window running as SYSTEM, add the policy with a credential from the policy’s Credentials tab:

    Terminal window
    Add-CertificateEnrollmentPolicyServer -Url <CEP_URL> -context Machine -Credential (Get-Credential) -AutoEnrollmentEnabled

    If the policy was added before, by an administrator or as SYSTEM, remove it first, as SYSTEM too, with Remove-CertificateEnrollmentPolicyServer and the same address: adding it again while it is still there keeps no credential for SYSTEM. One way to run commands as SYSTEM is a scheduled task whose user is NT AUTHORITY\SYSTEM.

  2. Turn on autoenrollment (enroll, renew and update) in the computer’s local Group Policy, and apply it now, as administrator:

    Terminal window
    Set-CertificateAutoEnrollmentPolicy -EnableAll -context Machine; gpupdate /target:computer /force

    The setting takes effect at the next Group Policy refresh; gpupdate applies it at once. A domain Group Policy setting overrides it. To turn it off again: Set-CertificateAutoEnrollmentPolicy -PolicyState NotConfigured -context Machine, then gpupdate /target:computer /force.

  3. Enroll now instead of waiting, as SYSTEM:

    certutil -pulse

The policy’s Connection tab shows these steps with its own address filled in.

Off-domain computers steps on the Connection tab

Domain-joined computers

In a Group Policy object, under Computer Configuration › Policies › Windows Settings › Security Settings › Public Key Policies:

  1. Certificate Services Client - Certificate Enrollment Policy: set Configuration Model to Enabled and add the CEP address.
  2. Certificate Services Client - Auto-Enrollment: set Configuration Model to Enabled, and check both renewal and update boxes.

With username and password logins, each computer also needs the credential added as SYSTEM, as in step 1 above.

Users

A user can add the policy and request user certificates with a username and password (see Request Certificates). On a computer that isn’t joined to a domain, however, user autoenrollment and silent renewal with a username and password don’t work: Windows keeps no password for the user that autoenrollment can use, so it fails with NTE_SILENT_CONTEXT 0x80090022 and nothing reaches PKIaaS.io. Request and renew user certificates by hand, or use machine certificates for devices that must renew on their own.

How renewal works

Windows renews a certificate when it enters its Renewal period, the number of days before expiry set in the template’s Windows settings (General tab). It renews in one of two ways:

  • Key-based renewal - Windows signs the renewal request with the key of the certificate it renews, with no username or password. It is allowed when the template has Allow key based renewal checked (which needs Valid existing certificate and Windows Server 2012 compatibility, schema 4) and the policy allows Key-based renewal logins. A key-based renewal before the renewal period starts is refused.
  • Client certificate login - when key-based renewal isn’t allowed, Windows retries about a second later, logging in with the certificate it renews to the policy’s client certificate address, on port 4433. The policy must allow Client certificate logins, and clients must be able to reach port 4433.

Either way, check Revoke on renewal for the template on the policy’s Templates tab to have the old certificate revoked when the new one is issued.

Renew by hand

To renew a machine certificate now, as administrator:

certreq -machine -enroll -q -policyserver <CEP_URL> -cert <thumbprint> renew

Add reusekeys at the end to renew with the same key. A same-key renewal is a key-based renewal: when the template doesn’t allow it, it is refused and Windows renews with a client certificate login instead.