#!/bin/sh # certbot manual DNS-01 hook for MOKLAV DNS # certbot certonly --manual --preferred-challenges dns \ # --manual-auth-hook "/path/certbot-moklav-hook.sh auth" \ # --manual-cleanup-hook "/path/certbot-moklav-hook.sh cleanup" -d example.com -d '*.example.com' # Requires: export MOKLAV_API_KEY="mk_..." API="${MOKLAV_API:-https://dns.moklav.com/api/v1}" BODY="{\"fqdn\":\"_acme-challenge.${CERTBOT_DOMAIN}\",\"value\":\"${CERTBOT_VALIDATION}\"}" case "$1" in auth) curl -fsS -X POST "$API/acme/present" -H "Authorization: Bearer $MOKLAV_API_KEY" -H "Content-Type: application/json" -d "$BODY" >/dev/null && sleep 20 ;; cleanup) curl -fsS -X POST "$API/acme/cleanup" -H "Authorization: Bearer $MOKLAV_API_KEY" -H "Content-Type: application/json" -d "$BODY" >/dev/null ;; *) echo "usage: $0 auth|cleanup"; exit 1 ;; esac