Extract certificate from traefik acme.js file for usage in cockpit.

Aymen Furter
1 min readJul 1, 2020

--

I do run a containerized traefik instance which makes sure that my wildcard certificate stays valid as shown in my previous article.

Additionally, I use the same certificate on my local cockpit application.

This script will extract the certificate and key & then put it onto the location which is expected by cockpit (Prerequisite is that you mount your acme.json file):

#!/bin/sh

less /path/to/your/traefik/acme/acme.json | grep certificate | cut -c 25- | rev | cut -c 3- | rev | base64 --decode > /tmp/certificate.crt
less /opt/appdata/traefik/acme/acme.json | grep key | cut -c 17- | rev | cut -c 3- | rev | base64 --decode > /tmp/key.crt
cat /tmp/key.crt /tmp/certificate.crt > /etc/cockpit/ws-certs.d/10-cert.cert
rm /tmp/key.crt
rm /tmp/certificate.crt

I do run it every 12 hours via crontab to ensure my certificate is always up-to-date.

--

--

Aymen Furter
Aymen Furter

Written by Aymen Furter

I am a Cloud Solution Architect working for Microsoft. The views expressed on this site are mine alone and do not necessarily reflect the views of my employer.

No responses yet