LetsEncrypt DNS challenge in production

LetsEncrypt DNS challenge in production

Before you begin please make sure github environment was created using yarn environment:init script, check https://github.com/opencrvs/documentation/blob/master/v2.0.0/setup/3.-installation/3.3-set-up-a-server-hosted-environment/4.3.1-create-a-github-environment

If you are provisioning a qa, staging or production environment behind a VPN and wish to use LetsEncrypt there are 2 options depending on your DNS server provider.

  1. Using Traefik supported DNS challenge APIs

  2. Manually creating static LetsEncrypt certs and TXT records

If your DNS is cloud managed using a supported provider, Traefik can use an access token to automatically generate the TXT records required for LetsEncrypt to validate your domain.

Traefik supported DNS Challenge APIs

Traefik supports APIs for the following cloud DNS providers and the secrets required can be passed to the Traefik service as environment variables:

Example configuration Traefik with Cloudflare as DNS provider

In this example, Cloudflare is the configured DNS provider. The environment secret CLOUDFLARE_API_KEY is stored as Kubernetes secret in traefik namespace.

  1. Make sure you are connected to correct kubernetes cluster, you need to check your kubernetes context:

Example output: In this output bob is your user name, tmp-k8s-server is master node name:

  1. Create a kubernetes secret in traefik namespace:

  • generic: is special kubernetes secret type

  • cloudflare-api-token-secret: : is kubernetes secret name

  • traefik: is namespace

  1. Verify the secret was created:

Example output:

  1. Update traefik helm chart values by adding following code snippet to environments/<env name>/traefik/values.yaml

See full example at examples/dev/traefik/values-dns-challenge.yaml

  1. Commit and push changes

  2. Run "Provision" workflow or deploy traefik manually

Manually creating static LetsEncrypt certs and TXT records

If you are not using one of Traefik's supported DNS providers, for example if you are hosting your own DNS server, then you can manually create the LetsEncrypt static files .crt and .key by using the certbot tool.

  1. Install certbot on your laptop

  2. Run this command to generate a wildcard LetsEncrypt cert for each of your environment domains:

The process after that is guided by the CLI. Running the command will give you the following prompt:

At this point you need to go to control panel of your DNS server and create the TXT record for the domains as instructed.

Once the process succeeds, it should write 2 certificate files fullchain.pem and privkey.pem to your local machine. The content of these files must be provided to the traefik service at runtime. The process required to implement this is equivalent to the next step: Static TLS certificates.

Last updated