Dump ACME data from Traefik to certificates
Go to file
dependabot[bot] 6367da653e
chore: bump golang.org/x/crypto from 0.14.0 to 0.17.0
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.14.0 to 0.17.0.
- [Commits](https://github.com/golang/crypto/compare/v0.14.0...v0.17.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-18 23:30:10 +00:00
.github chore: fix CI 2023-12-05 23:05:16 +01:00
cmd feat: update traefik and valkeyrie 2023-01-29 16:42:14 +01:00
contrib doc: note about contrib directory 2022-07-27 21:57:03 +02:00
docs chore: update whoami 2022-07-28 03:52:54 +02:00
dumper chore: update Go, CI, and linter 2023-02-22 10:06:39 +01:00
hook chore: update Go, linter, and dependencies 2022-08-29 08:57:30 +02:00
integrationtest feat: update traefik and valkeyrie 2023-01-29 16:42:14 +01:00
.dockerignore chore: migrate to seihon. 2019-04-30 23:05:08 +02:00
.gitignore chore: migrate to seihon. 2019-04-30 23:05:08 +02:00
.golangci.yml chore: update Go, and linter 2023-07-23 23:16:21 +02:00
.goreleaser.yml chore: update goreleaser config. 2019-08-01 08:11:06 +02:00
go.mod chore: bump golang.org/x/crypto from 0.14.0 to 0.17.0 2023-12-18 23:30:10 +00:00
go.sum chore: bump golang.org/x/crypto from 0.14.0 to 0.17.0 2023-12-18 23:30:10 +00:00
godownloader.sh chore: adds download script. 2019-04-04 21:29:26 +02:00
LICENSE chore: update Go, and linter 2023-07-23 23:16:21 +02:00
main.go chore: prepare release v2.0.0 2019-04-20 22:24:57 +02:00
Makefile feat: support Traefik v2. 2019-09-01 19:20:29 +02:00
readme.md doc: update versions 2022-07-27 21:54:50 +02:00
tmpl.Dockerfile chore: migrate to seihon. 2019-04-30 23:05:08 +02:00

traefik-certs-dumper

GitHub release Build Status Docker Image Version (latest semver) Go Report Card

If you appreciate this project:

Sponsor

Features

  • Supported sources:
    • file ("acme.json")
    • KV stores (Consul, Etcd, Zookeeper, Boltdb)
  • Watch changes:
    • from file ("acme.json")
    • from KV stores (Consul, Etcd, Zookeeper)
  • Output formats:
    • use domain as sub-directory (allow custom names and extensions)
    • flat (domain as filename)
  • Hook (only with watch mode and if the data source changes)

Installation

Download / CI Integration

curl -sfL https://raw.githubusercontent.com/ldez/traefik-certs-dumper/master/godownloader.sh | bash -s -- -b $(go env GOPATH)/bin v2.8.1

From Binaries

You can use pre-compiled binaries:

  • To get the binary just download the latest release for your OS/Arch from the releases page
  • Unzip the archive.
  • Add traefik-certs-dumper in your PATH.

From Docker

docker run ldez/traefik-certs-dumper:<tag_name>

Examples:

Usage

Examples

Note: to dump data from Traefik v2, the CLI flag --version v2 must be added.

Simple Dump

$ traefik-certs-dumper file
dump
├──certs
│  └──my.domain.com.key
└──private
   ├──my.domain.com.crt
   └──letsencrypt.key

Change source and destination

$ traefik-certs-dumper file --source ./acme.json --dest ./dump/test
test
├──certs
│  └──my.domain.com.key
└──private
   ├──my.domain.com.crt
   └──letsencrypt.key

Use domain as sub-directory

$ traefik-certs-dumper file --domain-subdir=true
dump
├──my.domain.com
│  ├──certificate.crt
│  └──privatekey.key
└──private
   └──letsencrypt.key

Change file extension

$ traefik-certs-dumper file --domain-subdir --crt-ext=.pem --key-ext=.pem
dump
├──my.domain.com
│  ├──certificate.pem
│  └──privatekey.pem
└──private
   └──letsencrypt.key

Change file name

$ traefik-certs-dumper file --domain-subdir --crt-name=fullchain --key-name=privkey
dump
├──my.domain.com
│  ├──fullchain.crt
│  └──privkey.key
└──private
   └──letsencrypt.key

Hook

Hook can be a one liner passed as a string, or a file for more complex post-hook scenarios. For the former, create a file (ex: hook.sh) and mount it, then pass sh hooksh as a parameter to --post-hook.

Here is a docker-compose example:

version: '3.9'

services:
# ...

  traefik-certs-dumper:
    image: ldez/traefik-certs-dumper:v2.8.1
    container_name: traefik-certs-dumper
    entrypoint: sh -c '
      apk add jq
      ; while ! [ -e /data/acme.json ]
      || ! [ `jq ".[] | .Certificates | length" /data/acme.json` != 0 ]; do
      sleep 1
      ; done
      && traefik-certs-dumper file --version v2 --watch
        --source /data/acme.json --dest /data/certs
        --post-hook "sh /hook.sh"'
    labels:
      traefik.enable: false
    volumes:
      - ./letsencrypt:/data
      - ./hook.sh:/hook.sh

# ...

KV store

Consul

$ traefik-certs-dumper kv consul --endpoints localhost:8500

Etcd

$ traefik-certs-dumper kv etcd --endpoints localhost:2379

Boltdb

$ traefik-certs-dumper kv boltdb --endpoints /the/path/to/mydb.db

Zookeeper

$ traefik-certs-dumper kv zookeeper --endpoints localhost:2181