No description
  • Python 91.4%
  • Shell 6.7%
  • Dockerfile 1.9%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-08-03 16:15:06 +02:00
.forgejo/workflows Update .forgejo/workflows/build-dev.yaml 2026-08-03 16:15:06 +02:00
app Apparently '4096' is a valid keytype too, have to map it to an enum key 2026-06-24 10:35:07 +02:00
example-hooks Rework into main branch (#2) 2025-05-22 17:10:25 +02:00
.gitignore Rework into main branch (#2) 2025-05-22 17:10:25 +02:00
Dockerfile Downgrade python to 3.12 2025-05-23 10:43:12 +02:00
example-hook.sh Update 2025-09-29 10:33:30 +02:00
LICENSE.md updated packages and base image 2023-07-17 18:04:10 +03:00
README.md Change file paths 2025-06-25 17:42:06 +02:00
requirements.txt Rework into main branch (#2) 2025-05-22 17:10:25 +02:00

Traefik Certificate Extractor

Tool to extract ACME certificates from Traefik.

Originaly developed by Daniel Huisman and improved by Marc Brückner and Estivador, inspired by parts of their code but mostly rewritten.

Usage

All development and testing was done in Docker, so that's the recommended way to use it: edekeijzer/traefik-certificate-extractor. Example run:

docker run --name extractor -d \
  -v /opt/traefik:/app/input \
  -v ./certs:/app/output \
  -v /run/docker.sock:/run/docker.sock \
  edekeijzer/traefik-certificate-extractor:latest

Mount the whole folder containing the traefik certificate file (acme.json) as /app/input. The extracted certificates are going to be written to /app/output. The filenames are equal to those produced by certbot (and other ACME clients), as well as a combined.pem containing both private key and the public certificate chain.

The Docker socket is used to find any containers with this label: traefik-certificate-extractor.domains and will take action if any of the (comma separated) domains matches any domain on the certificate. If the label traefik-certificate-extractor.command is set, executing this command within the container will be attempted instead of just restarting it. The special commands SIGHUP and SIGINT will trigger a docker kill --signal <signal>>.

Configuration

Everything is (currently) configured by environment variables. All variables are optional, with sensible defaults.

Name Type Default Description
INPUT_FILE file path (string) /input/acme.json The input file to read certificates from
OUTPUT_DIR dir path (string) /output The output directory to write the extracted certificates into
OUTPUT_PATH_RESOLVER bool or none none If true, the resolver name will be part of the directory path. If unset, will be true if there are multiple resolvers, false otherwise.
HOOK_DIR dir path (string) /hooks The path where hook scripts can be placed
CHECK_HASH bool true Should we do a hash compare on the data from Traefik and the target file before writing (and triggering hooks)
ONESHOT bool false Don't keep running, just do a single process and exit
STARTUP_EXTRACT bool true Should we process immediately at startup or only act at changes while already running?
DOCKER_COMMAND bool false Should we scan Docker labels for domain names and commands?
DOCKER_DOMAIN_LABEL string traefik-certificate-extractor.domains The Docker container label to check for domain names
DOCKER_COMMAND_LABEL string traefik-certificate-extractor.command The Docker container label to check for the command to execute on the container

Hooks

The container will fire hooks whenever the input file has been changed:

Event Description Parameters
pre Triggered as soon as a file change is detected, before any processing none
pre-cert Triggered for each certificate, before any check or action resolver (string), domains (list)
update Triggered for each certificate, after certificate files have been written resolver (string), domains (list), cert_dir (string), file_names (dict)
post Triggered after all certificates in all resolvers have been processed none