@@ -1,25 +1,49 @@
1−{ stdenv, nss, curl, perl }:
1+{ stdenv, fetchurl, writeText, nss, python
2+, blacklist ? []
3+, includeEmail ? false
4+}:
5+
6+with stdenv.lib;
7+
8+let
9+
10+ certdata2pem = fetchurl {
11+ name = "certdata2pem.py";
12+ url = "https://anonscm.debian.org/cgit/collab-maint/ca-certificates.git/plain/mozilla/certdata2pem.py?h=debian/20160104";
13+ sha256 = "0bw11mgfrf19qziyvdnq22kirp0nn54lfsanrg5h6djs6ig1c2im";
14+ };
15+
16+in
217
318stdenv.mkDerivation rec {
419 name = "nss-cacert-${nss.version}";
520
621 src = nss.src;
722
8− postPatch = ''
9− unpackFile ${curl.src};
23+ nativeBuildInputs = [ python ];
1024
11− # Remove dependency on LWP, curl is enough. Also, since curl here
12− # is working on a local file it will not actually get a 200 OK, so
13− # remove that expectation.
14− substituteInPlace curl-*/lib/mk-ca-bundle.pl \
15− --replace 'use LWP::UserAgent;' "" \
16− --replace ' && $out[0] == 200' ""
17− '';
25+ configurePhase = ''
26+ ln -s nss/lib/ckfw/builtins/certdata.txt
27+
28+ cat << EOF > blacklist.txt
29+ ${concatStringsSep "\n" (map (c: ''"${c}"'') blacklist)}
30+ EOF
1831
19− nativeBuildInputs = [ curl perl ];
32+ cp ${certdata2pem} certdata2pem.py
33+ ${optionalString includeEmail ''
34+ # Disable CAs used for mail signing
35+ substituteInPlace certdata2pem.py --replace \[\'CKA_TRUST_EMAIL_PROTECTION\'\] '''
36+ ''}
37+ '';
2038
2139 buildPhase = ''
22− perl curl-*/lib/mk-ca-bundle.pl -d "file://$(pwd)/nss/lib/ckfw/builtins/certdata.txt" ca-bundle.crt
40+ python certdata2pem.py | grep -vE '^(!|UNTRUSTED)'
41+
42+ for cert in *.crt; do
43+ echo $cert | cut -d. -f1 | sed -e 's,_, ,g' >> ca-bundle.crt
44+ cat $cert >> ca-bundle.crt
45+ echo >> ca-bundle.crt
46+ done
2347 '';
2448
2549 installPhase = ''
@@ -27,10 +51,10 @@ stdenv.mkDerivation rec {
2751 cp -v ca-bundle.crt $out/etc/ssl/certs
2852 '';
2953
30− meta = with stdenv.lib; {
54+ meta = {
3155 homepage = http://curl.haxx.se/docs/caextract.html;
3256 description = "A bundle of X.509 certificates of public Certificate Authorities (CA)";
3357 platforms = platforms.all;
34− maintainers = with maintainers; [ wkennington ];
58+ maintainers = with maintainers; [ wkennington fpletz ];
3559 };
3660}