1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015 Andreas Enge <andreas@enge.fr>
3 ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2016, 2017 Ludovic Courtès <ludo@gnu.org>
5 ;;; Copyright © 2017 Leo Famulari <leo@famulari.name>
7 ;;; This file is part of GNU Guix.
9 ;;; GNU Guix is free software; you can redistribute it and/or modify it
10 ;;; under the terms of the GNU General Public License as published by
11 ;;; the Free Software Foundation; either version 3 of the License, or (at
12 ;;; your option) any later version.
14 ;;; GNU Guix is distributed in the hope that it will be useful, but
15 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;;; GNU General Public License for more details.
19 ;;; You should have received a copy of the GNU General Public License
20 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
22 (define-module (gnu packages certs)
23 #:use-module ((guix licenses) #:prefix license:)
24 #:use-module (guix packages)
25 #:use-module (guix download)
26 #:use-module (guix build-system gnu)
27 #:use-module (guix build-system trivial)
28 #:use-module (gnu packages)
29 #:use-module (gnu packages python)
30 #:use-module (gnu packages perl)
31 #:use-module (gnu packages tls))
41 "http://pkgs.fedoraproject.org/cgit/ca-certificates.git/plain/certdata2pem.py?id=053dde8a2f5901e97028a58bf54e7d0ef8095a54")
42 (file-name "certdata2pem.py")
45 "0zscrm41gnsf14zvlkxhy00h3dmgidyz645ldpda3y3vabnwv8dx"))))
46 (build-system trivial-build-system)
48 `(("python" ,python-2)))
50 `(#:modules ((guix build utils))
53 (use-modules (guix build utils))
54 (let ((bin (string-append %output "/bin")))
55 (copy-file (assoc-ref %build-inputs "source") "certdata2pem.py")
56 (chmod "certdata2pem.py" #o555)
57 (substitute* "certdata2pem.py"
59 (string-append (assoc-ref %build-inputs "python")
61 ;; Use the file extension .pem instead of .crt.
64 (copy-file "certdata2pem.py"
65 (string-append bin "/certdata2pem.py"))))))
66 (synopsis "Python script to extract .pem data from certificate collection")
68 "certdata2pem.py is a Python script to transform X.509 certificate
69 \"source code\" as contained, for example, in the Mozilla sources, into
70 .pem formatted certificates.")
71 (license license:gpl2+)
72 (home-page "http://pkgs.fedoraproject.org/cgit/ca-certificates.git/")))
74 (define-public nss-certs
80 (uri (let ((version-with-underscores
81 (string-join (string-split version #\.) "_")))
83 "https://ftp.mozilla.org/pub/mozilla.org/security/nss/"
84 "releases/NSS_" version-with-underscores "_RTM/src/"
85 "nss-" version ".tar.gz")))
88 "1r44qa4j7sri50mxxbnrpm6fxprwrhv76whi7bfq73j06syxmw4q"))))
89 (build-system gnu-build-system)
92 `(("certdata2pem" ,certdata2pem)
94 ("perl" ,perl))) ;for OpenSSL's 'c_rehash'
96 (propagated-inputs '())
98 `(#:modules ((guix build gnu-build-system)
107 (let ((certsdir (string-append %output "/etc/ssl/certs/"))
108 (trusted-rx (make-regexp "^# openssl-trust=[a-zA-Z]"
111 (define (maybe-install-cert file)
112 (let ((cert (call-with-input-file file get-string-all)))
113 (when (regexp-exec trusted-rx cert)
114 (call-with-output-file
115 (string-append certsdir file)
116 (cut display cert <>)))))
119 (with-directory-excursion "nss/lib/ckfw/builtins/"
120 ;; extract single certificates from blob
121 (system* "certdata2pem.py" "certdata.txt")
122 ;; copy selected .pem files into the output
123 (for-each maybe-install-cert
124 (find-files "." ".*\\.pem")))
126 (with-directory-excursion certsdir
127 ;; create symbolic links for and by openssl
128 ;; Strangely, the call (system* "c_rehash" certsdir)
129 ;; from inside the build dir fails with
130 ;; "Usage error; try -help."
131 ;; This looks like a bug in openssl-1.0.2, but we can also
132 ;; switch into the target directory.
133 (system* "c_rehash" "."))))
135 (map (cut assq <> %standard-phases)
136 '(set-paths install-locale unpack)))))
137 (synopsis "CA certificates from Mozilla")
139 "This package provides certificates for Certification Authorities (CA)
140 taken from the NSS package and thus ultimately from the Mozilla project.")
141 (home-page "https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS")
142 (license license:mpl2.0)))
144 (define-public le-certs
149 (build-system trivial-build-system)
151 '(#:modules ((guix build utils))
154 (use-modules (guix build utils))
155 (let ((root (assoc-ref %build-inputs "isrgrootx1.pem"))
156 (intermediate (assoc-ref %build-inputs "letsencryptauthorityx3.pem"))
157 (backup (assoc-ref %build-inputs "letsencryptauthorityx4.pem"))
158 (out (string-append (assoc-ref %outputs "out") "/etc/ssl/certs"))
159 (openssl (assoc-ref %build-inputs "openssl"))
160 (perl (assoc-ref %build-inputs "perl")))
164 (copy-file cert (string-append out "/"
165 (strip-store-file-name cert))))
166 (list root intermediate backup))
168 ;; Create hash symlinks suitable for OpenSSL ('SSL_CERT_DIR' and
170 (chdir (string-append %output "/etc/ssl/certs"))
171 (unless (zero? (system* (string-append perl "/bin/perl")
172 (string-append openssl "/bin/c_rehash")
174 (error "'c_rehash' failed" openssl))))))
176 `(("openssl" ,openssl)
177 ("perl" ,perl))) ;for 'c_rehash'
179 `(; The Let's Encrypt root certificate, "ISRG Root X1".
183 (uri "https://letsencrypt.org/certs/isrgrootx1.pem")
186 "0zhd1ps7sz4w1x52xk3v7ng6d0rcyi7y7rcrplwkmilnq5hzjv1y"))))
187 ;; "Let’s Encrypt Authority X3", the active Let's Encrypt intermediate
189 ("letsencryptauthorityx3.pem"
192 (uri "https://letsencrypt.org/certs/letsencryptauthorityx3.pem")
195 "0zbamj6c7zqw1j9mbqygc8k1ykgj6xiisp9svmlif5lkbnyjhnkk"))))
196 ;; "Let’s Encrypt Authority X4", the backup Let's Encrypt intermediate
197 ;; certificate. This will be used for disaster recovery and will only be
198 ;; used should Let's Encrypt lose the ability to issue with "Let’s
199 ;; Encrypt Authority X3".
200 ("letsencryptauthorityx4.pem"
203 (uri "https://letsencrypt.org/certs/letsencryptauthorityx4.pem")
206 "003dc94c8qwj634h0dq743x7hqv9rdcfaisdksprkmi2jd107xq4"))))))
207 (home-page "https://letsencrypt.org/certificates/")
208 (synopsis "Let's Encrypt root and intermediate certificates")
209 (description "This package provides a certificate store containing only the
210 Let's Encrypt root and intermediate certificates. It is intended to be used
212 (license license:public-domain)))