CLI and python library to export Traefik SSL certificates
MIT License
CLI and python library to export Traefik SSL certificates.
This project is intended to provide tools to automate the process of extracting the certificates generated by Traefik's automatic certificate generation
Project based on the excelent work on Traefik SSL Certificate Exporter
You can use the python library on your own automation scripts
pip install traefik-cert-exporter
from traefik_cert_exporter import export_certificates
acme_file = "./acme.json"
output_dir = "./certs"
export_certificates(acme_file, output_dir)
You can use the included CLI directly from the terminal
pip install traefik-cert-exporter
export-certs ./acme.json ./certs
There is also a Docker image that create a cron job that runs the certificate export process on a schedule.
The container needs to have access to the store file generated by Traefik, so it needs to be configured with the correct variables to run successfully.
You can use the docker compose example to create your own environment.
image: https://hub.docker.com/r/ahuahuachi/traefik-cert-exporter
Variable | Default value | Description |
---|---|---|
CRON_SCHEDULE | 0 0 1 * * |
Cron schedule to run the extraction script |
STORAGE_FILE | traefik/acme.json |
Path to the acme storage file |
OUTPUT_PATH | certs/ |
Path where the certs are going to be extracted to |
ON_START |
1 (true) |
Run export scripts once when container starts |
Traefik's static configuration file
# static.yaml
certificatesResolvers:
myresolver:
acme:
storage: "/config/acme.json"
...
# docker-compose.yaml
version: "3"
services:
cert-exporter:
image: ahuahuachi/traefik-cert-exporter:latest
environment:
- STORAGE_FILE="/config/acme.json"
- OUTPUT_PATH="/certs"
volumes:
- traefik-config:/config/
- ./certs:/certs
traefik:
image: traefik:latest
volumes:
- traefik-config:/config/
...
volumes:
traefik-config: