Synchronising Certificates from AD CS

From version: 1.18.0

Certdog can keep itself in step with a Microsoft CA. Certificates the CA has issued, including those that were not requested through certdog (e.g. via auto-enrolment or requested at the CA directly), are imported into certdog automatically and on a schedule

This allows certdog to be used as the inventory for all of the certificates issued by your Microsoft CAs, with its search, expiry monitoring and alerting

This is carried out by the ADCS Agent. It replaces the need to run scripts to import certificates (see Importing Certificates from AD CS and Import the ADCS Database into Certdog) although those options remain available

How it Works

  • Synchronisation is switched on for a Certificate Issuer. Certdog then asks one of the issuer’s agents for the certificates in the CA’s database, a small number at a time, and imports those it does not already have
  • The first synchronisation starts at the beginning of the CA’s database and works through it in the background. For a large CA this can take some time (around 100,000 certificates an hour) but the issuing of certificates is not affected while it runs
  • Once up to date, certdog checks for new certificates on the schedule you choose (e.g. every hour)
  • Each check also picks up certificates that have been revoked at the CA, and marks them as revoked in certdog
  • Certificates that are already in certdog (such as those issued through certdog) are not imported again
  • The agent only reads from the CA’s database. Nothing at the CA is changed
  • Certdog only imports a certificate that was issued by the CA certificates held for the Certificate Issuer

Requirements

  • A Certificate Issuer for the Microsoft CA that uses the ADCS Agent. See Create an ADCS Certificate Issuer
  • The account used to access the CA (the issuer’s Credential, or the account the agent runs under) must be able to read the CA’s database. The Issue and Manage Certificates permission on the CA provides this
  • A Team and a User in certdog that the imported certificates will be assigned to. The user must be a member of the team. See Teams and Users

Switching on Synchronisation

Select Certificate Issuers from the menu, click the Microsoft CA issuer and click Edit

At the bottom of the form, switch on Sync Certificates

Sync Certificates

Configure the following:

Setting Description
Sync Every How often certdog checks for new certificates once it is up to date: 5 minutes, 15 minutes, 1 hour (the default), 6 hours or 1 day
Team The team the imported certificates are added to. Required
Owner The user who will own the imported certificates. Must be a member of the team. Required
Templates Leave empty to import certificates from all templates. Or select one or more templates to only import certificates issued from those. Click Get Available Templates further up the form to list the CA’s templates
Include Issued certificates are always imported. Tick Revoked to also import certificates that have already been revoked, and Expired to also import certificates that have already expired
Issued After Optional. Only certificates issued after this date are imported. Use this to leave old certificates out
Extra Info Optional. Text that is added to each imported certificate’s extra information. The following tokens can be included and are replaced for each certificate: {template}, {requestId} (the request ID at the CA), {requester} (the account that requested the certificate at the CA) and {caName}
Extra Emails Optional. Email addresses, separated by commas, that will also be sent notifications (such as expiry reminders) for the imported certificates
Track Expiry When on, certdog sends its expiry reminders for the imported certificates
Import CSRs When on, the original certificate request is stored with each certificate, which allows the certificate to be renewed from certdog

Click Update

The first synchronisation starts within a few seconds

A different set of certificates can be sent to a different team by creating a second Certificate Issuer for the same CA, with its own templates and team selected

Changing the settings later

Synchronisation only reads forward from the point it has reached. This means that if you change Templates, Include or Issued After after certificates have been synchronised, the change applies to certificates issued from then on. Certificates that the previous settings left out are not picked up automatically

To also bring in those earlier certificates use Re-sync From on the sync status page (see below). The sync status page displays a reminder when these settings have been changed

Switching Sync Certificates off pauses the synchronisation. Its position is kept, so that switching it on again continues from where it stopped

Sync Status

To see how the synchronisation is progressing, click View Sync Status from the Sync Certificates section of the issuer, or from the issuer’s details on the Certificate Issuers page

Sync status

The status, shown at the top right, will be one of:

Status Meaning
Up to date All certificates have been read. Certdog will check again at the Next Sync time
Catching up Certdog is working through the CA’s database. This is displayed during the first synchronisation and after a re-sync
Syncing A check for new certificates is in progress
Waiting for an agent None of the issuer’s agents that allow synchronisation is connected. It will run when one connects
Error The last attempt failed. The reason is displayed. Certdog will try again in a few minutes
Off Synchronisation is switched off for this issuer

Position shows the request ID at the CA that has been reached, and the highest request ID at the CA

The totals are:

Total Meaning
Imported Certificates that were added to certdog
Already In Certdog Certificates that certdog already had, such as those issued through certdog. These are not imported again
Revocations Applied Certificates in certdog that were marked as revoked because they were found to be revoked at the CA
Rejected (Not From This CA) Certificates that were not issued by the CA certificates held for this issuer. These are not imported. If the CA’s certificate has been renewed, edit the issuer and click Get Available Templates to update the CA certificates held
Failed Certificates Certificates that could not be imported. Each is listed, with the reason, under Recent Failures
Failed Syncs In A Row How many times in a row the synchronisation has failed to run. The owner is sent a notification after three failures and again when it is working once more

Note that Imported only counts new certificates. If you expected more certificates to be imported, check Already In Certdog and the settings that decide what is included (Templates, Include and Issued After)

Recent Syncs lists the most recent runs, with which agent was used and what was read and imported

Recent Failures lists certificates that could not be imported and why. A certificate that can not be imported does not stop the others

While catching up, a progress bar is displayed:

Sync catching up

The page updates itself

Sync Now

Click Sync Now to check for new certificates straight away rather than waiting for the Next Sync time

This only looks for certificates issued since the last check. To read earlier certificates again use Re-sync From

Re-sync From

Click Re-sync From… to read the CA’s database again from a chosen request ID

Re-sync

Enter 0 to read everything again from the start, or a request ID to start from that point, and confirm

Certificates already in certdog are skipped, so this can be run at any time and will not create duplicates

Use this:

  • After changing Templates, Include or Issued After, to bring in certificates that the previous settings left out
  • After resolving the cause of any Failed Certificates

Note that on a large CA, reading everything again takes some time and certificates that are newly issued will not be picked up until it has finished

Monitoring and Troubleshooting

Notifications

The Owner receives a notification in certdog if the synchronisation fails three times in a row, and another when it is working again

Fewer certificates than expected

  1. Check the totals on the sync status page. Certificates certdog already had are counted under Already In Certdog, not Imported
  2. Check the issuer’s Templates, Include and Issued After settings. If these were changed after the first synchronisation, use Re-sync From… with 0
  3. Check the agent’s log file on the agent’s server (see Log Files). For each batch read from the CA the agent records how many certificates it read and how many it sent to certdog, and for each one that was not sent, the reason. E.g.
Certificate sync: read 35 row(s) of the CA database after request 0 and sent 33 to certdog
Certificate sync: CA request 12 was not sent to certdog: it expired on 2025-03-01 and the sync does not include expired certificates
Certificate sync: CA request 20 was not sent to certdog: its template (CAExchange) is not one of the templates the sync is set to: WebServer, User

Waiting for an agent

Select Agents from the menu and check that an agent selected for the issuer is Approved and Connected. See Troubleshooting

If the agents are connected, check that the agent allows synchronisation. Click the agent and check that its Operations include Sync. An agent installed with the -DisableSync option will not allow it. To allow it, run the following on the agent’s server:

.\configure-certdog-adcs-agent.ps1 -DisableSync:$false

Error

The reason is displayed on the sync status page. Common causes are that the CA could not be reached, the account does not have permission to read the CA’s database, or the team or owner selected no longer exist

Certificates without a CSR

The original request is only stored where it is a standard (PKCS#10) certificate request. Certificates requested by Windows auto-enrolment use a different format and are imported without a CSR. These certificates can be tracked and revoked, but can not be renewed from the stored CSR

PowerShell

The status can be obtained, and a synchronisation started, using the PowerShell module:

# Display the status
Get-AdcsSyncStatus -issuerId 617a6c684eaeb271fa97d556

# Display the certificates that failed to import
(Get-AdcsSyncStatus -issuerId 617a6c684eaeb271fa97d556).recentFailures | Format-Table

# Sync now
Start-AdcsSync -issuerId 617a6c684eaeb271fa97d556

# Re-sync from the start
Start-AdcsSync -issuerId 617a6c684eaeb271fa97d556 -fromRequestId 0

The issuerId is displayed in the issuer’s details and when editing the issuer

Permissions

The synchronisation settings are part of the Certificate Issuer. A user who can edit Certificate Issuers (the Global Admin or CA Manager role) can change the settings, view the status and use Sync Now and Re-sync From