Metadata-Version: 2.3
Name: traefik-cert-exporter
Version: 1.0.1
Summary: CLI and python library to export Traefik SSL certificates
Project-URL: Documentation, https://github.com/ahuahuachi/traefik-cert-exporter#readme
Project-URL: Issues, https://github.com/ahuahuachi/traefik-cert-exporter/issues
Project-URL: Source, https://github.com/ahuahuachi/traefik-cert-exporter
Author-email: Alfredo Altamirano <pypi.sprinkled287@passmail.net>
License-Expression: MIT
License-File: LICENSE
Keywords: certificate,cli,export,ssl,traefik
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Security
Classifier: Topic :: System :: Monitoring
Classifier: Topic :: Utilities
Requires-Python: >=3.10
Requires-Dist: click<9,>=8.1.7
Provides-Extra: dev
Requires-Dist: black; extra == 'dev'
Requires-Dist: isort; extra == 'dev'
Provides-Extra: tests
Requires-Dist: pytest; extra == 'tests'
Description-Content-Type: text/markdown

![license](https://badgen.net/github/license/ahuahuachi/traefik-cert-exporter/)
![releases](https://badgen.net/github/releases/ahuahuachi/traefik-cert-exporter/?icon=github)
![stars](https://badgen.net/github/stars/ahuahuachi/traefik-cert-exporter/?icon=github)
![docker stars](https://badgen.net/docker/stars/ahuahuachi/traefik-cert-exporter/?icon=docker)
![docker pulls](https://badgen.net/docker/pulls/ahuahuachi/traefik-cert-exporter/?icon=docker)
![docker size](https://badgen.net/docker/size/ahuahuachi/traefik-cert-exporter/?icon=docker)
![pypi version](https://badgen.net/pypi/v/traefik-cert-exporter/?icon=pypi)
![python versions](https://badgen.net/pypi/python/traefik-cert-exporter/?icon=pypi)
![python downloads](https://badgen.net/pypi/dm/traefik-cert-exporter/?icon=pypi)

# Traefik Cert Exporter

CLI and python library to export [Traefik](https://traefik.io/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](https://doc.traefik.io/traefik/https/acme)

<sub>Project based on the excelent work on [Traefik SSL Certificate Exporter](https://github.com/rafi0101/traefik-ssl-certificate-exporter)</sub>

## Python library

You can use the python library on your own automation scripts

### Installation

```bash
pip install traefik-cert-exporter
```

### Usage

```python
from traefik_cert_exporter import export_certificates

acme_file = "./acme.json"
output_dir = "./certs"

export_certificates(acme_file, output_dir)
```

## CLI

You can use the included CLI directly from the terminal

### Installation

```bash
pip install traefik-cert-exporter
```

### Usage

```bash
export-certs ./acme.json ./certs
```

## Docker

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

### Environment Variables

| 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     |

### Docker compose example

Traefik's static configuration file

```yaml
# static.yaml
certificatesResolvers:
  myresolver:
    acme:
      storage: "/config/acme.json"
      ...
```

```yaml
# 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:
```
