Three ways to automatic renewal
Internal servers often get their certificates from the company CA on Windows. Renewal is then usually manual, and sooner or later one expires. There are three ways to automate it:
- ACME gateway in front of AD CS (recommended): acme2certifier is an open-source ACME server (RFC 8555) that passes requests on to the Windows CA. The Linux servers run plain certbot or acme.sh. No domain join needed, and you can switch CAs later without touching the clients.
- certmonger with cepces: the certmonger daemon watches certificates and renews them via Microsoft's CEP and CES web services. This needs those roles on the Windows side and usually Kerberos on the Linux servers.
- Scripts with certreq or web enrollment: works, but it is home-made and nothing checks who may request which name.
This guide covers the first way.
How an issuance works
Until the very end the Linux server only talks to acme2certifier. The Windows CA only sees the finished CSR, submitted via a service account.
- Fetch the directory: the client loads
https://acme.corp.example.com/directoryand gets the endpoints. - Create an account: the client creates its own key pair and registers, with key ID and HMAC key if External Account Binding (EAB) is enabled.
- Create an order: the client names the desired host names. acme2certifier checks them against
allowed_domainlist. - Solve the challenge: with http-01 the client places a token under
/.well-known/acme-challenge/, with dns-01 a TXT record. acme2certifier fetches it itself. - Finalize: the client sends the CSR. acme2certifier checks that the names match the order exactly and hands it to the CA handler.
- Issuance: the handler submits the CSR to AD CS with the configured template and fetches certificate and chain.
- Download: the client stores certificate and chain and runs its deploy hook, e.g. a reload of nginx.
- Renewal: not a special case; the client simply goes through a new order. certbot renews 30 days before expiry; acme2certifier can recommend a time via ACME Renewal Information (ARI).
The Microsoft handlers cannot revoke. That is still done in the Certification Authority console (certsrv.msc).
The two handlers for AD CS
| mscertsrv | msicpr (formerly mswcce) | |
|---|---|---|
| Route to the CA | HTTPS to /certsrv/ | RPC (MS-ICPR) over SMB |
| Ports | TCP 443 | TCP 445, if needed 135 and dynamic RPC ports |
| Windows role | Certification Authority Web Enrollment (IIS) | none extra |
| Authentication | Kerberos (gssapi), NTLM, Basic | Kerberos or NTLM |
| Typical pitfall | Extended Protection in IIS set to “Required” | firewall between gateway and CA |
Rule of thumb: mscertsrv if web enrollment already runs or only HTTPS may pass the firewall. msicpr if no IIS should run on the CA. For both, Kerberos is the better choice; NTLM is considered deprecated.
Preparing the Windows CA
- Template: duplicate “Web Server”, e.g. as
WebServer-Linux. Under Subject Name choose “Supply in the request”, otherwise the SANs are missing. Under Issuance Requirements set no CA certificate manager approval, because no handler can complete pending requests. - Publish the template: in
certsrv.mscunder Certificate Templates → New → Certificate Template to Issue. - Service account: e.g.
svc-a2c-enrollwith “Read” and “Enroll” on the template. The account is powerful: it may request any name acme2certifier lets through. - Keytab for Kerberos: create it with
ktpasson a DC. Agree with the AD admins first, asktpasscan change the account's password. - mscertsrv only: role “Certification Authority Web Enrollment” and Windows authentication in IIS. Test from the gateway after
kinit:
curl -I --negotiate -u : https://ca01.corp.example.com/certsrv/
acme2certifier with Docker
The gateway is easiest to run as a container. Everything persistent lives in the volume: configuration, database, keytab and CA chain. If the configuration is missing, the container creates a template on first start.
services:
acme2certifier:
image: grindsa/acme2certifier:apache2-wsgi
container_name: acme2certifier
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- ./data:/var/www/acme2certifier/volume
The configuration data/acme_srv.cfg for AD CS with Kerberos via web enrollment:
[DEFAULT] debug: False [Account] contact_check_disable: True [Order] allowed_domainlist: ["corp.example.com", "*.corp.example.com"] wildcard_certificate_disable: True [Challenge] http_01_support: True dns_01_support: True [CAhandler] handler_module: acme2certifier.cahandlers.mscertsrv_ca_handler host: ca01.corp.example.com auth_method: gssapi template: WebServer-Linux allowed_templates: ["WebServer-Linux"] allowed_domainlist: ["corp.example.com", "*.corp.example.com"] krb5_principal: svc-a2c-enroll@CORP.EXAMPLE.COM krb5_keytab: /var/www/acme2certifier/volume/svc-a2c-enroll.keytab krb5_config: /var/www/acme2certifier/volume/krb5.conf ca_bundle: /var/www/acme2certifier/volume/ca-chain.pem
For msicpr only the [CAhandler] section changes: module acme2certifier.cahandlers.msicpr_ca_handler, plus ca_name, target_domain, domain_controller and use_kerberos: True. HTTPS is enabled as soon as the gateway's own server certificate is in the volume, for the Apache image as acme2certifier.pem with key and chain. Restart the container after every configuration change.
docker compose up -d docker compose logs -f acme2certifier curl https://acme.corp.example.com/directory
Connecting the Linux servers
Compared with Let's Encrypt, only the address of the ACME server changes on the servers. First the server must trust the company CA, otherwise even the connection to the gateway fails:
# Debian/Ubuntu cp corp-root-ca.crt /usr/local/share/ca-certificates/ update-ca-certificates # RHEL/Rocky/Alma cp corp-root-ca.crt /etc/pki/ca-trust/source/anchors/ update-ca-trust
certbot with http-01 via the existing webroot; renewal is handled by the bundled systemd timer:
certbot certonly --server https://acme.corp.example.com/directory \ --webroot -w /var/www/html -d app01.corp.example.com \ --register-unsafely-without-email --agree-tos \ --deploy-hook "systemctl reload nginx" systemctl list-timers | grep certbot certbot renew --dry-run
acme.sh as an alternative without Python:
acme.sh --issue --server https://acme.corp.example.com/directory \ -d app01.corp.example.com -w /var/www/html acme.sh --install-cert -d app01.corp.example.com \ --key-file /etc/ssl/private/app01.key \ --fullchain-file /etc/ssl/certs/app01-fullchain.pem \ --reloadcmd "systemctl reload apache2"
In nginx and Apache, fullchain.pem and privkey.pem are configured as for Let's Encrypt with nginx and with Apache. Tomcat 8.5 and later reads PEM directly, see Tomcat with Let's Encrypt. If you need a keystore, rebuild it in the deploy hook:
#!/bin/sh # /etc/letsencrypt/renewal-hooks/deploy/tomcat.sh set -e D=/etc/letsencrypt/live/app01.corp.example.com openssl pkcs12 -export -in "$D/fullchain.pem" -inkey "$D/privkey.pem" \ -out /opt/tomcat/conf/app01.p12 -name tomcat -passout pass:changeit \ -keypbe PBE-SHA1-3DES -certpbe PBE-SHA1-3DES -macalg sha1 chown tomcat: /opt/tomcat/conf/app01.p12 systemctl restart tomcat
The ACME helper generates the matching commands for your server; just replace the server address. Windows servers can join in too: win-acme accepts a custom ACME server with --baseuri.
Hardening: the gateway is powerful
Anyone who reaches the gateway and passes a challenge gets a certificate signed by the company CA. These restrictions are therefore mandatory:
- Limit names:
allowed_domainlistin[Order]and[CAhandler]; block wildcards withwildcard_certificate_disable: True. - Limit templates: set
allowed_templates; empty allows every template the service account may enroll. - Enable EAB: only clients with key ID and HMAC key may create an account; with certbot via
--eab-kidand--eab-hmac-key. - Limit the network: make the gateway reachable only from the server networks and run it over HTTPS itself.
- Verify TLS: with
mscertsrvalways useca_bundleinstead of disabling verification. - Don't disable challenges: use
challenge_validation_disableandprevalidated_domainlistonly deliberately and narrowly. - Monitor: check expiry dates on the target servers in your monitoring, e.g. with the certificate expiry overview, plus the reachability of
/directory.
Typical errors
| Symptom | Cause | Fix |
|---|---|---|
SSL error fetching /directory | company root missing from the client's trust store | distribute the root, update-ca-certificates |
| Challenge fails (http-01) | gateway cannot reach port 80 of the server, or DNS resolves differently | check the firewall, set dns_server_list, or use dns-01 |
| Order stays “processing” | template requires CA certificate manager approval | turn off approval in the template |
| Certificate without SAN or with the wrong name | template builds the subject from AD | “Supply in the request” |
mscertsrv: HTTP 401 despite correct login | Extended Protection in IIS set to “Required” | set it to “Accept” or use a current requests-gssapi |
mscertsrv with NTLM: MD4 error | OpenSSL 3 without legacy provider | enable the legacy provider or use Kerberos |
msicpr: timeout | TCP 445 or RPC ports blocked | open the firewall between gateway and CA |
| Kerberos: “Clock skew too great” | gateway and DC clocks differ | set up NTP on the Docker host |
CA errors only appear in the gateway log (docker logs acme2certifier, more detail with debug: True); the client only sees a short message. Whether the issued certificate and chain are right is shown by the SSL check for publicly reachable servers or the certificate converter for the file.
FAQ
Do the Linux servers have to be domain members?
No. Only the gateway logs on to the CA with a service account. The Linux servers only speak ACME with the gateway and just need the company CA's root certificate.
Can acme2certifier revoke certificates?
Not with the two AD CS handlers. Revocation is still done in the Certification Authority console, and the CA's revocation list applies as usual.
Does it work for internal names like server01?
Yes, as long as the name is allowed in allowed_domainlist and the gateway can validate the challenge, i.e. resolve the name and reach port 80. For servers without a web server, dns-01 is the alternative.
How long are the certificates valid?
The template on the Windows CA decides, not acme2certifier. Shorter lifetimes such as 90 days are no longer a problem with automatic renewal and limit the damage if a key is lost.