PKI Certificate Revocation (CN / Serial)
Go to Automation :materialformkdocs: Go to Automation Hub Docs
Description
This automation playbook revokes certificates from one or more Microsoft Active Directory Certificate Services (AD CS) Certification Authorities.
Revocation can be performed based on Common Name (CN), explicit Serial Number, or both.
The playbook supports bulk revocation, input normalization, and safe execution through a dedicated PKI service account. It leverages native certutil commands and provides detailed execution feedback for audit and incident response purposes.
Credentials
-
sys_srvaapwin_pki
PKI service account credentials retrieved securely from Passwordstate.
This account must have sufficient rights to revoke certificates on the target CA(s). -
sys_ansible_windows Credential passed on via AAP
-
sys_ps_pki Credential passed on via AAP. Used to retrieve the correct credential to execute the revocation
Target Hosts
- srvaapwinpr01.gentgrp.gent.be
Execution host with network and security access to the AD CS infrastructure.
Input Variables
| Variable | Description | Required | Default |
|---|---|---|---|
CommonName |
One or more certificate Common Names (CSV supported) | No* | |
SerialNumber |
One or more certificate serial numbers (CSV supported) | No* | |
CAlocationsRaw |
CA configuration string(s) (server\CA-name, CSV supported) |
Yes | SRVCAISSUE02.gentgrp.gent.be\D09-Issuing-CA2 |
Reason |
Revocation reason code (RFC 5280: 0–6) | No | 5 (Key Compromise) |
* At least one of CommonName or SerialNumber must be provided.
Common Name Normalization Logic
To reduce operator error and improve usability, the playbook automatically normalizes Common Names:
- If a CN does not end with
.gentgrp.gent.be
→ an additional FQDN variant is automatically added.
Example
Input: server01
Processed CN list: server01 server01.gentgrp.gent.be
- Existing FQDNs are not modified
- Duplicate CNs are automatically removed
- Only the approved suffix is appended (hard-coded)
Output (Ansible facts)
| Variable | Description |
|---|---|
pki_creds |
PKI service account credentials from Passwordstate |
pwsh_output |
PowerShell execution output including revocation results and summary |
Process Flow
-
Retrieve PKI Credentials
Securely fetches the PKI service account credentials from Passwordstate. -
Input Normalization
- Parses CSV input for CNs and serial numbers
- Automatically adds FQDN variants for non-qualified CNs
-
Deduplicates normalized CN list
-
Input Validation
Ensures that at least one revocation source (CN or Serial Number) is supplied. -
CA Processing Loop
Iterates over one or more configured Certification Authorities. -
CN-Based Revocation
- Queries the CA database for issued certificates matching the CN
- Extracts all matching serial numbers
-
Revokes each matching certificate
-
Serial-Based Revocation
- Directly revokes explicitly supplied serial numbers
-
No database lookup required
-
Result Collection
- Tracks per-certificate success or failure
-
Includes CA, CN, serial number, reason, and message
-
Final Reporting
Outputs a revocation summary and sets the playbook exit code: 0→ all revocations successful1→ one or more revocations failed
Revocation Reasons (RFC 5280)
| Code | Meaning |
|---|---|
| 0 | Unspecified |
| 1 | Key Compromise |
| 2 | CA Compromise |
| 3 | Affiliation Changed |
| 4 | Superseded |
| 5 | Cessation of Operation |
| 6 | Certificate Hold |
Security Features
-
Credential Protection
Secrets retrieved dynamically from Passwordstate; no hard-coded credentials. -
Input Guardrails
Controlled CN normalization prevents arbitrary domain injection. -
Auditable Output
Detailed per-certificate revocation results for incident response and compliance.
Monitoring & Troubleshooting
The playbook provides clear execution feedback including:
- CA(s) being processed
- Normalized CN list
- Certificates found per CN
- Revocation success or failure per serial number
- Final revocation summary
Failures on individual certificates do not stop processing of remaining items.
Operational Use Cases
- Incident response (key compromise, malware, lateral movement)
- Decommissioning servers or services
- Bulk revocation during PKI security events
Dependencies
- Windows PowerShell
- CertUtil (AD CS tools installed)
- Network connectivity to CA
- Passwordstate integration
- Ansible Automation Platform (AAP)