Obtains certificates from Let's Encrypt, using Lexicon to answer DNS-based challenges
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

hook.sh 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/usr/bin/env bash
  2. #
  3. # Example how to deploy a DNS challange using lexicon
  4. set -e
  5. set -u
  6. set -o pipefail
  7. export PROVIDER=${PROVIDER:-"cloudflare"}
  8. function deploy_challenge {
  9. local DOMAIN="${1}" TOKEN_FILENAME="${2}" TOKEN_VALUE="${3}"
  10. echo "deploy_challenge called: ${DOMAIN}, ${TOKEN_FILENAME}, ${TOKEN_VALUE}"
  11. lexicon $PROVIDER create ${DOMAIN} TXT --name="_acme-challenge.${DOMAIN}." --content="${TOKEN_VALUE}"
  12. sleep 30
  13. # This hook is called once for every domain that needs to be
  14. # validated, including any alternative names you may have listed.
  15. #
  16. # Parameters:
  17. # - DOMAIN
  18. # The domain name (CN or subject alternative name) being
  19. # validated.
  20. # - TOKEN_FILENAME
  21. # The name of the file containing the token to be served for HTTP
  22. # validation. Should be served by your web server as
  23. # /.well-known/acme-challenge/${TOKEN_FILENAME}.
  24. # - TOKEN_VALUE
  25. # The token value that needs to be served for validation. For DNS
  26. # validation, this is what you want to put in the _acme-challenge
  27. # TXT record. For HTTP validation it is the value that is expected
  28. # be found in the $TOKEN_FILENAME file.
  29. }
  30. function clean_challenge {
  31. local DOMAIN="${1}" TOKEN_FILENAME="${2}" TOKEN_VALUE="${3}"
  32. echo "clean_challenge called: ${DOMAIN}, ${TOKEN_FILENAME}, ${TOKEN_VALUE}"
  33. lexicon $PROVIDER delete ${DOMAIN} TXT --name="_acme-challenge.${DOMAIN}." --content="${TOKEN_VALUE}"
  34. # This hook is called after attempting to validate each domain,
  35. # whether or not validation was successful. Here you can delete
  36. # files or DNS records that are no longer needed.
  37. #
  38. # The parameters are the same as for deploy_challenge.
  39. }
  40. HANDLER="$1"; shift
  41. if [[ "${HANDLER}" =~ ^(deploy_challenge|clean_challenge)$ ]]; then
  42. "$HANDLER" "$@"
  43. fi