1 { config, lib, pkgs, ... }:
7 cfg = config.security.pki;
9 cacertPackage = pkgs.cacert.override {
10 blacklist = cfg.caCertificateBlacklist;
11 extraCertificateFiles = cfg.certificateFiles;
12 extraCertificateStrings = cfg.certificates;
14 caBundle = "${cacertPackage}/etc/ssl/certs/ca-bundle.crt";
22 security.pki.certificateFiles = mkOption {
23 type = types.listOf types.path;
25 example = literalExpression ''[ "''${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" ]'';
26 description = lib.mdDoc ''
27 A list of files containing trusted root certificates in PEM
28 format. These are concatenated to form
29 {file}`/etc/ssl/certs/ca-certificates.crt`, which is
30 used by many programs that use OpenSSL, such as
31 {command}`curl` and {command}`git`.
35 security.pki.certificates = mkOption {
36 type = types.listOf types.str;
38 example = literalExpression ''
42 -----BEGIN CERTIFICATE-----
43 MIIGUDCCBTigAwIBAgIDD8KWMA0GCSqGSIb3DQEBBQUAMIGMMQswCQYDVQQGEwJJ
44 TDEWMBQGA1UEChMNU3RhcnRDb20gTHRkLjErMCkGA1UECxMiU2VjdXJlIERpZ2l0
46 -----END CERTIFICATE-----
50 description = lib.mdDoc ''
51 A list of trusted root certificates in PEM format.
55 security.pki.caCertificateBlacklist = mkOption {
56 type = types.listOf types.str;
59 "WoSign" "WoSign China"
61 "Certification Authority of WoSign G2"
63 description = lib.mdDoc ''
64 A list of blacklisted CA certificate names that won't be imported from
65 the Mozilla Trust Store into
66 {file}`/etc/ssl/certs/ca-certificates.crt`. Use the
75 # NixOS canonical location + Debian/Ubuntu/Arch/Gentoo compatibility.
76 environment.etc."ssl/certs/ca-certificates.crt".source = caBundle;
78 # Old NixOS compatibility.
79 environment.etc."ssl/certs/ca-bundle.crt".source = caBundle;
81 # CentOS/Fedora compatibility.
82 environment.etc."pki/tls/certs/ca-bundle.crt".source = caBundle;
84 # P11-Kit trust source.
85 environment.etc."ssl/trust-source".source = "${cacertPackage.p11kit}/etc/ssl/trust-source";