ACME: Difference between revisions

From NixOS Wiki
imported>Onny
mNo edit summary
imported>Onny
mNo edit summary
Line 11: Line 11:
   certs."mx1.example.org" = {
   certs."mx1.example.org" = {
     dnsProvider = "inwx";
     dnsProvider = "inwx";
    credentialsFile = config.sops.secrets.lego-inwx-credentials.path;
     # Suplying password files like this will make your credentials world-readable
     # Suplying password files like this will make your credentials world-readable
     # in the Nix store. This is for demonstration purpose only, do not use this in production.
     # in the Nix store. This is for demonstration purpose only, do not use this in production.

Revision as of 11:39, 22 April 2023

NixOS supports automatic domain validation & certificate retrieval and renewal using the ACME protocol. Any provider can be used, but by default NixOS uses Let's Encrypt. The alternative ACME client lego is used under the hood.

Setup

Following example setup generates certificates using DNS validation. Let's Encrypt ToS has to be accepted. Further the contact mail admin+acme@example.com is defined.

security.acme = {
  acceptTerms = true;
  defaults.email = "admin+acme@example.com";
  certs."mx1.example.org" = {
    dnsProvider = "inwx";
    # Suplying password files like this will make your credentials world-readable
    # in the Nix store. This is for demonstration purpose only, do not use this in production.
    credentialsFile = "${pkgs.writeText "inwx-creds" ''
      INWX_USERNAME=xxxxxxxxxx
      INWX_PASSWORD=yyyyyyyyyy
    ''}";
  };
};

Certificates are getting generated for the domain mx1.example.org using the DNS provider inwx. See upstream documentation on available providers and their specific configuration for the credentialsFile option.

See also