gnu: Add python-pyshp.
[jackhill/guix/guix.git] / gnu / packages / tls.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2021 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net>
5 ;;; Copyright © 2013, 2015 Andreas Enge <andreas@enge.fr>
6 ;;; Copyright © 2015 David Thompson <davet@gnu.org>
7 ;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020 Leo Famulari <leo@famulari.name>
8 ;;; Copyright © 2016, 2017, 2019 Efraim Flashner <efraim@flashner.co.il>
9 ;;; Copyright © 2016, 2017, 2018 Nikita <nikita@n0.is>
10 ;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com>
11 ;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
12 ;;; Copyright © 2017, 2018, 2019, 2020, 2021 Marius Bakke <marius@gnu.org>
13 ;;; Copyright © 2017–2019, 2021 Tobias Geerinckx-Rice <me@tobias.gr>
14 ;;; Copyright © 2017 Rutger Helling <rhelling@mykolab.com>
15 ;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org>
16 ;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
17 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
18 ;;; Copyright © 2021 Solene Rapenne <solene@perso.pw>
19 ;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
20 ;;;
21 ;;; This file is part of GNU Guix.
22 ;;;
23 ;;; GNU Guix is free software; you can redistribute it and/or modify it
24 ;;; under the terms of the GNU General Public License as published by
25 ;;; the Free Software Foundation; either version 3 of the License, or (at
26 ;;; your option) any later version.
27 ;;;
28 ;;; GNU Guix is distributed in the hope that it will be useful, but
29 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
30 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 ;;; GNU General Public License for more details.
32 ;;;
33 ;;; You should have received a copy of the GNU General Public License
34 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
35
36 (define-module (gnu packages tls)
37 #:use-module ((guix licenses) #:prefix license:)
38 #:use-module (guix packages)
39 #:use-module (guix download)
40 #:use-module (guix git-download)
41 #:use-module (guix utils)
42 #:use-module (guix build-system gnu)
43 #:use-module (guix build-system go)
44 #:use-module (guix build-system perl)
45 #:use-module (guix build-system python)
46 #:use-module (guix build-system cmake)
47 #:use-module (guix build-system trivial)
48 #:use-module (gnu packages compression)
49 #:use-module (gnu packages)
50 #:use-module (gnu packages bash)
51 #:use-module (gnu packages check)
52 #:use-module (gnu packages curl)
53 #:use-module (gnu packages dns)
54 #:use-module (gnu packages gawk)
55 #:use-module (gnu packages guile)
56 #:use-module (gnu packages hurd)
57 #:use-module (gnu packages libbsd)
58 #:use-module (gnu packages libffi)
59 #:use-module (gnu packages libidn)
60 #:use-module (gnu packages linux)
61 #:use-module (gnu packages ncurses)
62 #:use-module (gnu packages nettle)
63 #:use-module (gnu packages perl)
64 #:use-module (gnu packages pkg-config)
65 #:use-module (gnu packages python)
66 #:use-module (gnu packages python-crypto)
67 #:use-module (gnu packages python-web)
68 #:use-module (gnu packages python-xyz)
69 #:use-module (gnu packages sphinx)
70 #:use-module (gnu packages texinfo)
71 #:use-module (gnu packages time)
72 #:use-module (gnu packages base)
73 #:use-module (srfi srfi-1))
74
75 (define-public libtasn1
76 (package
77 (name "libtasn1")
78 (version "4.16.0")
79 (source
80 (origin
81 (method url-fetch)
82 (uri (string-append "mirror://gnu/libtasn1/libtasn1-"
83 version ".tar.gz"))
84 (sha256
85 (base32
86 "179jskl7dmfp1rd2khkzmlibzgki4wi6hvmmwfv7q49r728b03qf"))))
87 (build-system gnu-build-system)
88 (arguments
89 `(#:configure-flags '("--disable-static")))
90 (native-inputs `(("perl" ,perl)))
91 (home-page "https://www.gnu.org/software/libtasn1/")
92 (synopsis "ASN.1 library")
93 (description
94 "GNU libtasn1 is a library implementing the ASN.1 notation. It is used
95 for transmitting machine-neutral encodings of data objects in computer
96 networking, allowing for formal validation of data according to some
97 specifications.")
98 (license license:lgpl2.0+)))
99
100 (define-public asn1c
101 (package
102 (name "asn1c")
103 (version "0.9.28")
104 (source (origin
105 (method url-fetch)
106 (uri (string-append "https://lionet.info/soft/asn1c-"
107 version ".tar.gz"))
108 (sha256
109 (base32
110 "1fc64g45ykmv73kdndr4zdm4wxhimhrir4rxnygxvwkych5l81w0"))))
111 (build-system gnu-build-system)
112 (native-inputs
113 `(("perl" ,perl)))
114 (home-page "https://lionet.info/asn1c")
115 (synopsis "ASN.1 to C compiler")
116 (description "The ASN.1 to C compiler takes ASN.1 module
117 files and generates C++ compatible C source code. That code can be
118 used to serialize the native C structures into compact and unambiguous
119 BER/XER/PER-based data files, and deserialize the files back.
120
121 Various ASN.1 based formats are widely used in the industry, such as to encode
122 the X.509 certificates employed in the HTTPS handshake, to exchange control
123 data between mobile phones and cellular networks, to car-to-car communication
124 in intelligent transportation networks.")
125 (license license:bsd-2)))
126
127 (define-public p11-kit
128 (package
129 (name "p11-kit")
130 (version "0.23.22")
131 (source
132 (origin
133 (method url-fetch)
134 (uri (string-append "https://github.com/p11-glue/p11-kit/releases/"
135 "download/" version "/p11-kit-" version ".tar.xz"))
136 (sha256
137 (base32 "1dn6br4v033d3gp2max9lsr3y4q0nj6iyr1yq3kzi8ym7lal13wa"))))
138 (build-system gnu-build-system)
139 (native-inputs
140 `(("pkg-config" ,pkg-config)))
141 (inputs
142 `(("libffi" ,libffi)
143 ("libtasn1" ,libtasn1)))
144 (arguments
145 `(#:configure-flags '("--without-trust-paths")
146 #:phases (modify-phases %standard-phases
147 (add-before 'check 'prepare-tests
148 (lambda _
149 ;; "test-runtime" expects XDG_RUNTIME_DIR to be set up
150 ;; and looks for .cache and other directories (only).
151 ;; For simplicity just drop it since it is irrelevant
152 ;; in the build container.
153 (substitute* "Makefile"
154 (("test-runtime\\$\\(EXEEXT\\)") ""))
155 #t)))))
156 (home-page "https://p11-glue.freedesktop.org/p11-kit.html")
157 (synopsis "PKCS#11 library")
158 (description
159 "p11-kit provides a way to load and enumerate PKCS#11 modules. It
160 provides a standard configuration setup for installing PKCS#11 modules
161 in such a way that they are discoverable. It also solves problems with
162 coordinating the use of PKCS#11 by different components or libraries
163 living in the same process.")
164 (license license:bsd-3)))
165
166 (define-public gnutls
167 (package
168 (name "gnutls")
169 (version "3.6.15")
170 (replacement gnutls-3.6.16)
171 (source (origin
172 (method url-fetch)
173 ;; Note: Releases are no longer on ftp.gnu.org since the
174 ;; schism (after version 3.1.5).
175 (uri (string-append "mirror://gnupg/gnutls/v"
176 (version-major+minor version)
177 "/gnutls-" version ".tar.xz"))
178 (patches (search-patches "gnutls-skip-trust-store-test.patch"
179 "gnutls-cross.patch"
180 "gnutls-CVE-2021-20231.patch"
181 "gnutls-CVE-2021-20232.patch"))
182 (sha256
183 (base32
184 "0n0m93ymzd0q9hbknxc2ycanz49sqlkyyf73g9fk7n787llc7a0f"))))
185 (build-system gnu-build-system)
186 (arguments
187 `(#:tests? ,(not (or (%current-target-system)
188 (hurd-target?)))
189 ;; Ensure we don't keep a reference to net-tools.
190 #:disallowed-references ,(if (hurd-target?) '() (list net-tools))
191 #:configure-flags
192 (list
193 ;; GnuTLS doesn't consult any environment variables to specify
194 ;; the location of the system-wide trust store. Instead it has a
195 ;; configure-time option. Unless specified, its configure script
196 ;; attempts to auto-detect the location by looking for common
197 ;; places in the file system, none of which are present in our
198 ;; chroot build environment. If not found, then no default trust
199 ;; store is used, so each program has to provide its own
200 ;; fallback, and users have to configure each program
201 ;; independently. This seems suboptimal.
202 "--with-default-trust-store-dir=/etc/ssl/certs"
203
204 ;; Tell the build system that we want Guile bindings installed to
205 ;; the output instead of Guiles own module directory.
206 (string-append "--with-guile-site-dir="
207 "$(datarootdir)/guile/site/$(GUILE_EFFECTIVE_VERSION)")
208 (string-append "--with-guile-site-ccache-dir="
209 "$(libdir)/guile/$(GUILE_EFFECTIVE_VERSION)/site-ccache")
210 (string-append "--with-guile-extension-dir="
211 "$(libdir)/guile/$(GUILE_EFFECTIVE_VERSION)/extensions")
212
213 ;; FIXME: Temporarily disable p11-kit support since it is not
214 ;; working on mips64el.
215 "--without-p11-kit")
216
217 #:phases (modify-phases %standard-phases
218 (add-after
219 'install 'move-doc
220 (lambda* (#:key outputs #:allow-other-keys)
221 ;; Copy the 4.1 MiB of section 3 man pages to "doc".
222 (let* ((out (assoc-ref outputs "out"))
223 (doc (assoc-ref outputs "doc"))
224 (mandir (string-append doc "/share/man/man3"))
225 (oldman (string-append out "/share/man/man3")))
226 (mkdir-p mandir)
227 (copy-recursively oldman mandir)
228 (delete-file-recursively oldman)
229 #t))))))
230 (outputs '("out" ;4.4 MiB
231 "debug"
232 "doc")) ;4.1 MiB of man pages
233 (native-inputs
234 `(,@(if (%current-target-system) ;for cross-build
235 `(("guile" ,guile-3.0)) ;to create .go files
236 '())
237 ,@(if (hurd-target?)
238 '()
239 `(("net-tools" ,net-tools)))
240 ("pkg-config" ,pkg-config)
241 ("which" ,which)
242 ,@(if (hurd-target?) '()
243 `(("datefudge" ,datefudge))) ;tests rely on 'datefudge'
244 ("util-linux" ,util-linux))) ;one test needs 'setsid'
245 (inputs
246 `(("guile" ,guile-3.0)))
247 (propagated-inputs
248 ;; These are all in the 'Requires.private' field of gnutls.pc.
249 `(("libtasn1" ,libtasn1)
250 ("libidn2" ,libidn2)
251 ("nettle" ,nettle)
252 ("zlib" ,zlib)))
253 (home-page "https://www.gnu.org/software/gnutls/")
254 (synopsis "Transport layer security library")
255 (description
256 "GnuTLS is a secure communications library implementing the SSL, TLS
257 and DTLS protocols. It is provided in the form of a C library to support the
258 protocols, as well as to parse and write X.509, PKCS #12, OpenPGP and other
259 required structures.")
260 (license license:lgpl2.1+)
261 (properties '((ftp-server . "ftp.gnutls.org")
262 (ftp-directory . "/gcrypt/gnutls")))))
263
264 ;; Replacement package to fix CVE-2021-20305.
265 (define gnutls-3.6.16
266 (package
267 (inherit gnutls)
268 (version "3.6.16")
269 (source (origin
270 (method url-fetch)
271 (uri (string-append "mirror://gnupg/gnutls/v"
272 (version-major+minor version)
273 "/gnutls-" version ".tar.xz"))
274 (patches (search-patches "gnutls-skip-trust-store-test.patch"
275 "gnutls-cross.patch"))
276 (sha256
277 (base32
278 "1czk511pslz367shf32f2jvvkp7y1323bcv88c2qng98mj0v6y8v"))))
279 (arguments
280 (if (%current-target-system)
281 (substitute-keyword-arguments (package-arguments gnutls)
282 ((#:phases phases '%standard-phases)
283 `(modify-phases ,phases
284 (add-before 'configure 'build-eccdata-headers
285 (lambda* (#:key configure-flags #:allow-other-keys)
286 ;; Build the 'ecc/eccdata' program using the native
287 ;; compiler, not the cross-compiler as happens by default,
288 ;; and use it to build lib/nettle/ecc/ecc-*.h. In GnuTLS
289 ;; 3.6.15, this was not necessary because the tarball
290 ;; contained pre-generated lib/nettle/ecc/ecc-*.h files as
291 ;; well as 'ecc/eccdata.stamp'.
292 (let ((jobs (number->string (parallel-job-count)))
293 (patch (assoc-ref %standard-phases
294 'patch-generated-file-shebangs)))
295 (mkdir "+native-build")
296 (with-directory-excursion "+native-build"
297 ;; Build natively, with the native compiler, GMP, etc.
298 (invoke "../configure"
299 (string-append "SHELL=" (which "sh"))
300 (string-append "CONFIG_SHELL=" (which "sh"))
301 "NETTLE_CFLAGS= " "NETTLE_LIBS= "
302 "HOGWEED_CFLAGS= " "HOGWEED_LIBS= "
303 "LIBTASN1_CFLAGS= " "LIBTASN1_LIBS= "
304 "ac_cv_func_nettle_rsa_sec_decrypt=yes"
305 "--without-p11-kit" "--disable-guile")
306 (patch)
307 (invoke "make" "-C" "gl" "-j" jobs)
308 (invoke "make" "-C" "lib/nettle" "V=1" "-j" jobs))
309
310 ;; Copy the files we obtained during native build.
311 (for-each (lambda (file)
312 (install-file file "lib/nettle/ecc"))
313 (find-files
314 "+native-build/lib/nettle/ecc"
315 "^(eccdata\\.stamp|ecc-.*\\.h)$"))))))))
316 (package-arguments gnutls)))
317 (native-inputs
318 (if (%current-target-system)
319 `(("libtasn1" ,libtasn1) ;for 'ecc/eccdata'
320 ("libidn2" ,libidn2)
321 ("nettle" ,nettle)
322 ("zlib" ,zlib)
323 ,@(package-native-inputs gnutls))
324 (package-native-inputs gnutls)))))
325
326 (define-public gnutls/guile-2.0
327 ;; GnuTLS for Guile 2.0.
328 (package/inherit gnutls
329 (name "guile2.0-gnutls")
330 (inputs `(("guile" ,guile-2.0)
331 ,@(alist-delete "guile" (package-inputs gnutls))))))
332
333 (define-public gnutls/dane
334 ;; GnuTLS with build libgnutls-dane, implementing DNS-based
335 ;; Authentication of Named Entities. This is required for GNS functionality
336 ;; by GNUnet and gnURL. This is done in an extra package definition
337 ;; to have the choice between GnuTLS with Dane and without Dane.
338 (package/inherit gnutls
339 (name "gnutls-dane")
340 (inputs `(("unbound" ,unbound)
341 ,@(package-inputs gnutls)))))
342
343 (define-public guile2.2-gnutls
344 (package/inherit gnutls
345 (name "guile2.2-gnutls")
346 (inputs `(("guile" ,guile-2.2)
347 ,@(alist-delete "guile"
348 (package-inputs gnutls))))))
349
350 (define-public guile3.0-gnutls
351 (deprecated-package "guile3.0-gnutls" gnutls))
352
353 (define-public openssl
354 (package
355 (name "openssl")
356 (version "1.1.1j")
357 (replacement openssl-1.1.1k)
358 (source (origin
359 (method url-fetch)
360 (uri (list (string-append "https://www.openssl.org/source/openssl-"
361 version ".tar.gz")
362 (string-append "ftp://ftp.openssl.org/source/"
363 "openssl-" version ".tar.gz")
364 (string-append "ftp://ftp.openssl.org/source/old/"
365 (string-trim-right version char-set:letter)
366 "/openssl-" version ".tar.gz")))
367 (patches (search-patches "openssl-1.1-c-rehash-in.patch"))
368 (sha256
369 (base32
370 "1gw17520vh13izy1xf5q0a2fqgcayymjjj5bk0dlkxndfnszrwma"))))
371 (build-system gnu-build-system)
372 (outputs '("out"
373 "doc" ;6.8 MiB of man3 pages and full HTML documentation
374 "static")) ;6.4 MiB of .a files
375 (native-inputs `(("perl" ,perl)))
376 (arguments
377 `(#:parallel-tests? #f
378 #:test-target "test"
379
380 ;; Changes to OpenSSL sometimes cause Perl to "sneak in" to the closure,
381 ;; so we explicitly disallow it here.
382 #:disallowed-references ,(list (canonical-package perl))
383 #:phases
384 (modify-phases %standard-phases
385 ,@(if (%current-target-system)
386 '((add-before
387 'configure 'set-cross-compile
388 (lambda* (#:key target outputs #:allow-other-keys)
389 (setenv "CROSS_COMPILE" (string-append target "-"))
390 (setenv "CONFIGURE_TARGET_ARCH"
391 (cond
392 ((string-prefix? "i586" target)
393 "hurd-x86")
394 ((string-prefix? "i686" target)
395 "linux-x86")
396 ((string-prefix? "x86_64" target)
397 "linux-x86_64")
398 ((string-prefix? "mips64el" target)
399 "linux-mips64")
400 ((string-prefix? "arm" target)
401 "linux-armv4")
402 ((string-prefix? "aarch64" target)
403 "linux-aarch64")
404 ((string-prefix? "powerpc64le" target)
405 "linux-ppc64le")
406 ((string-prefix? "powerpc64" target)
407 "linux-ppc64")
408 ((string-prefix? "powerpc" target)
409 "linux-ppc")))
410 #t)))
411 '())
412 (replace 'configure
413 (lambda* (#:key outputs #:allow-other-keys)
414 (let* ((out (assoc-ref outputs "out"))
415 (lib (string-append out "/lib")))
416 ;; It's not a shebang so patch-source-shebangs misses it.
417 (substitute* "config"
418 (("/usr/bin/env")
419 (string-append (assoc-ref %build-inputs "coreutils")
420 "/bin/env")))
421 (invoke ,@(if (%current-target-system)
422 '("./Configure")
423 '("./config"))
424 "shared" ;build shared libraries
425 "--libdir=lib"
426
427 ;; The default for this catch-all directory is
428 ;; PREFIX/ssl. Change that to something more
429 ;; conventional.
430 (string-append "--openssldir=" out
431 "/share/openssl-"
432 ,(package-version this-package))
433
434 (string-append "--prefix=" out)
435 (string-append "-Wl,-rpath," lib)
436 ,@(if (%current-target-system)
437 '((getenv "CONFIGURE_TARGET_ARCH"))
438 '())))))
439 (add-after 'install 'move-static-libraries
440 (lambda* (#:key outputs #:allow-other-keys)
441 ;; Move static libraries to the "static" output.
442 (let* ((out (assoc-ref outputs "out"))
443 (lib (string-append out "/lib"))
444 (static (assoc-ref outputs "static"))
445 (slib (string-append static "/lib")))
446 (for-each (lambda (file)
447 (install-file file slib)
448 (delete-file file))
449 (find-files lib "\\.a$"))
450 #t)))
451 (add-after 'install 'move-extra-documentation
452 (lambda* (#:key outputs #:allow-other-keys)
453 ;; Move man3 pages and full HTML documentation to "doc".
454 (let* ((out (assoc-ref outputs "out"))
455 (man3 (string-append out "/share/man/man3"))
456 (html (string-append out "/share/doc/openssl"))
457 (doc (assoc-ref outputs "doc"))
458 (man-target (string-append doc "/share/man/man3"))
459 (html-target (string-append doc "/share/doc/openssl")))
460 (copy-recursively man3 man-target)
461 (delete-file-recursively man3)
462 (copy-recursively html html-target)
463 (delete-file-recursively html)
464 #t)))
465 (add-after
466 'install 'remove-miscellany
467 (lambda* (#:key outputs #:allow-other-keys)
468 ;; The 'misc' directory contains random undocumented shell and Perl
469 ;; scripts. Remove them to avoid retaining a reference on Perl.
470 (let ((out (assoc-ref outputs "out")))
471 (delete-file-recursively (string-append out "/share/openssl-"
472 ,(package-version this-package)
473 "/misc"))
474 #t))))))
475 (native-search-paths
476 (list (search-path-specification
477 (variable "SSL_CERT_DIR")
478 (separator #f) ;single entry
479 (files '("etc/ssl/certs")))
480 (search-path-specification
481 (variable "SSL_CERT_FILE")
482 (file-type 'regular)
483 (separator #f) ;single entry
484 (files '("etc/ssl/certs/ca-certificates.crt")))))
485 (synopsis "SSL/TLS implementation")
486 (description
487 "OpenSSL is an implementation of SSL/TLS.")
488 (license license:openssl)
489 (home-page "https://www.openssl.org/")))
490
491 ;; Replacement package to fix CVE-2021-3449 and CVE-2021-3450.
492 (define openssl-1.1.1k
493 (package
494 (inherit openssl)
495 (version "1.1.1k")
496 (source (origin
497 (method url-fetch)
498 (uri (list (string-append "https://www.openssl.org/source/openssl-"
499 version ".tar.gz")
500 (string-append "ftp://ftp.openssl.org/source/"
501 "openssl-" version ".tar.gz")
502 (string-append "ftp://ftp.openssl.org/source/old/"
503 (string-trim-right version char-set:letter)
504 "/openssl-" version ".tar.gz")))
505 (patches (search-patches "openssl-1.1-c-rehash-in.patch"))
506 (sha256
507 (base32
508 "1rdfzcrxy9y38wqdw5942vmdax9hjhgrprzxm42csal7p5shhal9"))))))
509
510 (define-public openssl-1.0
511 (package
512 (inherit openssl)
513 (name "openssl")
514 (version "1.0.2u")
515 (source (origin
516 (method url-fetch)
517 (uri (list (string-append "https://www.openssl.org/source/openssl-"
518 version ".tar.gz")
519 (string-append "ftp://ftp.openssl.org/source/"
520 "openssl-" version ".tar.gz")
521 (string-append "ftp://ftp.openssl.org/source/old/"
522 (string-trim-right version char-set:letter)
523 "/openssl-" version ".tar.gz")))
524 (sha256
525 (base32
526 "05lxcs4hzyfqd5jn0d9p0fvqna62v2s4pc9qgmq0dpcknkzwdl7c"))
527 (patches (search-patches "openssl-runpath.patch"
528 "openssl-c-rehash-in.patch"))))
529 (outputs '("out"
530 "doc" ;1.5MiB of man3 pages
531 "static")) ;6MiB of .a files
532 (arguments
533 (substitute-keyword-arguments (package-arguments openssl)
534 ;; Parallel build is not supported in 1.0.x.
535 ((#:parallel-build? _ #f) #f)
536 ((#:phases phases)
537 `(modify-phases ,phases
538 (add-before 'patch-source-shebangs 'patch-tests
539 (lambda* (#:key inputs native-inputs #:allow-other-keys)
540 (let ((bash (assoc-ref (or native-inputs inputs) "bash")))
541 (substitute* (find-files "test" ".*")
542 (("/bin/sh")
543 (string-append bash "/bin/sh"))
544 (("/bin/rm")
545 "rm"))
546 #t)))
547 (add-before 'configure 'patch-Makefile.org
548 (lambda* (#:key outputs #:allow-other-keys)
549 ;; The default MANDIR is some unusual place. Fix that.
550 (let ((out (assoc-ref outputs "out")))
551 (patch-makefile-SHELL "Makefile.org")
552 (substitute* "Makefile.org"
553 (("^MANDIR[[:blank:]]*=.*$")
554 (string-append "MANDIR = " out "/share/man\n")))
555 #t)))
556 (replace 'configure
557 ;; Override this phase because OpenSSL 1.0 does not understand -rpath.
558 (lambda* (#:key outputs #:allow-other-keys)
559 (let ((out (assoc-ref outputs "out")))
560 (invoke ,@(if (%current-target-system)
561 '("./Configure")
562 '("./config"))
563 "shared" ;build shared libraries
564 "--libdir=lib"
565
566 ;; The default for this catch-all directory is
567 ;; PREFIX/ssl. Change that to something more
568 ;; conventional.
569 (string-append "--openssldir=" out
570 "/share/openssl-" ,version)
571
572 (string-append "--prefix=" out)
573 ,@(if (%current-target-system)
574 '((getenv "CONFIGURE_TARGET_ARCH"))
575 '())))))
576 (delete 'move-extra-documentation)
577 (add-after 'install 'move-man3-pages
578 (lambda* (#:key outputs #:allow-other-keys)
579 ;; Move section 3 man pages to "doc".
580 (let* ((out (assoc-ref outputs "out"))
581 (man3 (string-append out "/share/man/man3"))
582 (doc (assoc-ref outputs "doc"))
583 (target (string-append doc "/share/man/man3")))
584 (mkdir-p target)
585 (for-each (lambda (file)
586 (rename-file file
587 (string-append target "/"
588 (basename file))))
589 (find-files man3))
590 (delete-file-recursively man3)
591 #t)))
592 ;; XXX: Duplicate this phase to make sure 'version' evaluates
593 ;; in the current scope and not the inherited one.
594 (replace 'remove-miscellany
595 (lambda* (#:key outputs #:allow-other-keys)
596 ;; The 'misc' directory contains random undocumented shell and Perl
597 ;; scripts. Remove them to avoid retaining a reference on Perl.
598 (let ((out (assoc-ref outputs "out")))
599 (delete-file-recursively (string-append out "/share/openssl-"
600 ,version "/misc"))
601 #t)))))))))
602
603 (define-public libressl
604 (package
605 (name "libressl")
606 (version "3.3.3")
607 (source (origin
608 (method url-fetch)
609 (uri (string-append "mirror://openbsd/LibreSSL/"
610 "libressl-" version ".tar.gz"))
611 (sha256
612 (base32
613 "0rihprcgxsydsbcqgd1952k2cfn4jmp7rlyp1c6sglfc6rdmcwd4"))))
614 (build-system gnu-build-system)
615 (arguments
616 `(#:configure-flags
617 (list
618 ;; Do as if 'getentropy' were missing: Linux kernels before 3.17 lack its
619 ;; underlying 'getrandom' system call and ENOSYS isn't properly handled.
620 ;; See <https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00235.html>.
621 "ac_cv_func_getentropy=no"
622 ;; FIXME It's using it's own bundled certificate, instead it should
623 ;; behave like OpenSSL by using environment variables.
624 (string-append "--with-openssldir=" %output
625 "/share/libressl-"
626 ,(package-version this-package))
627 ;; Provide a TLS-enabled netcat.
628 "--enable-nc")))
629 (home-page "https://www.libressl.org/")
630 (synopsis "SSL/TLS implementation")
631 (description "LibreSSL is a version of the TLS/crypto stack, forked from
632 OpenSSL in 2014 with the goals of modernizing the codebase, improving security,
633 and applying best practice development processes. This package also includes a
634 netcat implementation that supports TLS.")
635 ;; Files taken from OpenSSL keep their license, others are under various
636 ;; non-copyleft licenses.
637 (license (list license:openssl
638 (license:non-copyleft
639 "file://COPYING"
640 "See COPYING in the distribution.")))))
641
642 (define-public python-acme
643 (package
644 (name "python-acme")
645 ;; Remember to update the hash of certbot when updating python-acme.
646 (version "1.15.0")
647 (source (origin
648 (method url-fetch)
649 (uri (pypi-uri "acme" version))
650 (sha256
651 (base32
652 "0kgf1d3gl7dg1rz3q4093kf8g0p2d0m40c7qmn96ihz2224wa307"))))
653 (build-system python-build-system)
654 (arguments
655 `(#:phases
656 (modify-phases %standard-phases
657 (add-after 'build 'build-documentation
658 (lambda _
659 (invoke "make" "-C" "docs" "man" "info")))
660 (add-after 'install 'install-documentation
661 (lambda* (#:key outputs #:allow-other-keys)
662 (let* ((out (assoc-ref outputs "out"))
663 (man (string-append out "/share/man/man1"))
664 (info (string-append out "/info")))
665 (install-file "docs/_build/texinfo/acme-python.info" info)
666 (install-file "docs/_build/man/acme-python.1" man)
667 #t))))))
668 (native-inputs
669 `(("python-pytest" ,python-pytest)
670 ;; For documentation
671 ("python-sphinx" ,python-sphinx)
672 ("python-sphinxcontrib-programoutput" ,python-sphinxcontrib-programoutput)
673 ("python-sphinx-rtd-theme" ,python-sphinx-rtd-theme)
674 ("texinfo" ,texinfo)))
675 (propagated-inputs
676 `(("python-josepy" ,python-josepy)
677 ("python-requests" ,python-requests)
678 ("python-requests-toolbelt" ,python-requests-toolbelt)
679 ("python-pytz" ,python-pytz)
680 ("python-pyrfc3339" ,python-pyrfc3339)
681 ("python-pyasn1" ,python-pyasn1)
682 ("python-cryptography" ,python-cryptography)
683 ("python-pyopenssl" ,python-pyopenssl)))
684 (home-page "https://github.com/certbot/certbot")
685 (synopsis "ACME protocol implementation in Python")
686 (description "ACME protocol implementation in Python")
687 (license license:asl2.0)))
688
689 (define-public certbot
690 (package
691 (name "certbot")
692 ;; Certbot and python-acme are developed in the same repository, and their
693 ;; versions should remain synchronized.
694 (version (package-version python-acme))
695 (source (origin
696 (method url-fetch)
697 (uri (pypi-uri "certbot" version))
698 (sha256
699 (base32
700 "1qcznszgqdgx1nhk4vdi896gknvx8rg4w8iw15lwqg6byhiyazyv"))))
701 (build-system python-build-system)
702 (arguments
703 `(,@(substitute-keyword-arguments (package-arguments python-acme)
704 ((#:phases phases)
705 `(modify-phases ,phases
706 (replace 'install-documentation
707 (lambda* (#:key outputs #:allow-other-keys)
708 (let* ((out (assoc-ref outputs "out"))
709 (man1 (string-append out "/share/man/man1"))
710 (man7 (string-append out "/share/man/man7"))
711 (info (string-append out "/info")))
712 (install-file "docs/_build/texinfo/Certbot.info" info)
713 (install-file "docs/_build/man/certbot.1" man1)
714 (install-file "docs/_build/man/certbot.7" man7)
715 #t))))))))
716 (native-inputs
717 `(("python-mock" ,python-mock)
718 ("python-pytest" ,python-pytest)
719 ;; For documentation
720 ("python-sphinx" ,python-sphinx)
721 ("python-sphinx-rtd-theme" ,python-sphinx-rtd-theme)
722 ("python-sphinx-repoze-autointerface" ,python-sphinx-repoze-autointerface)
723 ("python-sphinxcontrib-programoutput" ,python-sphinxcontrib-programoutput)
724 ("texinfo" ,texinfo)))
725 (propagated-inputs
726 `(("python-acme" ,python-acme)
727 ("python-cryptography" ,python-cryptography)
728 ("python-zope-interface" ,python-zope-interface)
729 ("python-pyrfc3339" ,python-pyrfc3339)
730 ("python-pyopenssl" ,python-pyopenssl)
731 ("python-configobj" ,python-configobj)
732 ("python-configargparse" ,python-configargparse)
733 ("python-distro" ,python-distro)
734 ("python-zope-component" ,python-zope-component)
735 ("python-parsedatetime" ,python-parsedatetime)
736 ("python-psutil" ,python-psutil)
737 ("python-requests" ,python-requests)
738 ("python-pytz" ,python-pytz)))
739 (synopsis "Let's Encrypt client by the Electronic Frontier Foundation")
740 (description "Certbot automatically receives and installs X.509 certificates
741 to enable Transport Layer Security (TLS) on servers. It interoperates with the
742 Let’s Encrypt certificate authority (CA), which issues browser-trusted
743 certificates for free.")
744 (home-page "https://certbot.eff.org/")
745 (license license:asl2.0)))
746
747 (define-public letsencrypt
748 (package (inherit certbot)
749 (name "letsencrypt")
750 (properties `((superseded . ,certbot)))))
751
752 (define-public perl-net-ssleay
753 (package
754 (name "perl-net-ssleay")
755 (version "1.88")
756 (source (origin
757 (method url-fetch)
758 (uri (string-append "mirror://cpan/authors/id/C/CH/CHRISN/"
759 "Net-SSLeay-" version ".tar.gz"))
760 (sha256
761 (base32
762 "1pfgh4h3szcpvqlcimc60pjbk9zwls99x5863sva0wc47i4dl010"))))
763 (build-system perl-build-system)
764 (inputs `(("openssl" ,openssl)))
765 (arguments
766 `(#:phases
767 (modify-phases %standard-phases
768 (add-before
769 'configure 'set-ssl-prefix
770 (lambda* (#:key inputs #:allow-other-keys)
771 (setenv "OPENSSL_PREFIX" (assoc-ref inputs "openssl"))
772 #t)))))
773 (synopsis "Perl extension for using OpenSSL")
774 (description
775 "This module offers some high level convenience functions for accessing
776 web pages on SSL servers (for symmetry, the same API is offered for accessing
777 http servers, too), an sslcat() function for writing your own clients, and
778 finally access to the SSL api of the SSLeay/OpenSSL package so you can write
779 servers or clients for more complicated applications.")
780 (license license:perl-license)
781 (home-page "https://metacpan.org/release/Net-SSLeay")))
782
783 (define-public perl-crypt-openssl-rsa
784 (package
785 (name "perl-crypt-openssl-rsa")
786 (version "0.31")
787 (source
788 (origin
789 (method url-fetch)
790 (uri (string-append
791 "mirror://cpan/authors/id/T/TO/TODDR/Crypt-OpenSSL-RSA-"
792 version
793 ".tar.gz"))
794 (sha256
795 (base32
796 "0djl5i6kibl7862b6ih29q8dhg5zpwzq77q9j8hp6xngshx40ws1"))))
797 (build-system perl-build-system)
798 (native-inputs
799 `(("perl-crypt-openssl-guess" ,perl-crypt-openssl-guess)))
800 (inputs
801 `(("perl-crypt-openssl-bignum" ,perl-crypt-openssl-bignum)
802 ("perl-crypt-openssl-random" ,perl-crypt-openssl-random)
803 ("openssl" ,openssl)))
804 (arguments perl-crypt-arguments)
805 (home-page
806 "https://metacpan.org/release/Crypt-OpenSSL-RSA")
807 (synopsis
808 "RSA encoding and decoding, using the openSSL libraries")
809 (description "Crypt::OpenSSL::RSA does RSA encoding and decoding (using the
810 OpenSSL libraries).")
811 (license license:perl-license)))
812
813 (define perl-crypt-arguments
814 `(#:phases (modify-phases %standard-phases
815 (add-before 'configure 'patch-Makefile.PL
816 (lambda* (#:key inputs #:allow-other-keys)
817 (substitute* "Makefile.PL"
818 (("'LIBS'.*=>.*") (string-append "'LIBS' => ['-L"
819 (assoc-ref inputs "openssl")
820 "/lib -lcrypto'],")))
821 #t)))))
822
823 (define-public perl-crypt-openssl-bignum
824 (package
825 (name "perl-crypt-openssl-bignum")
826 (version "0.09")
827 (source
828 (origin
829 (method url-fetch)
830 (uri (string-append
831 "mirror://cpan/authors/id/K/KM/KMX/Crypt-OpenSSL-Bignum-"
832 version
833 ".tar.gz"))
834 (sha256
835 (base32
836 "1p22znbajq91lbk2k3yg12ig7hy5b4vy8igxwqkmbm4nhgxp4ki3"))))
837 (build-system perl-build-system)
838 (inputs `(("openssl" ,openssl)))
839 (arguments perl-crypt-arguments)
840 (home-page
841 "https://metacpan.org/release/Crypt-OpenSSL-Bignum")
842 (synopsis
843 "OpenSSL's multiprecision integer arithmetic in Perl")
844 (description "Crypt::OpenSSL::Bignum provides multiprecision integer
845 arithmetic in Perl.")
846 ;; At your option either gpl1+ or the Artistic License
847 (license license:perl-license)))
848
849 (define-public perl-crypt-openssl-guess
850 (package
851 (name "perl-crypt-openssl-guess")
852 (version "0.11")
853 (source
854 (origin
855 (method url-fetch)
856 (uri (string-append
857 "mirror://cpan/authors/id/A/AK/AKIYM/Crypt-OpenSSL-Guess-"
858 version ".tar.gz"))
859 (sha256
860 (base32
861 "0rvi9l4ljcbhwwvspq019nfq2h2v746dk355h2nwnlmqikiihsxa"))))
862 (build-system perl-build-system)
863 (home-page "https://metacpan.org/release/Crypt-OpenSSL-Guess")
864 (synopsis "Guess the OpenSSL include path")
865 (description
866 "The Crypt::OpenSSL::Guess Perl module provides helpers to guess the
867 correct OpenSSL include path. It is intended for use in your
868 @file{Makefile.PL}.")
869 (license license:perl-license)))
870
871 (define-public perl-crypt-openssl-random
872 (package
873 (name "perl-crypt-openssl-random")
874 (version "0.15")
875 (source
876 (origin
877 (method url-fetch)
878 (uri (string-append
879 "mirror://cpan/authors/id/R/RU/RURBAN/Crypt-OpenSSL-Random-"
880 version
881 ".tar.gz"))
882 (sha256
883 (base32 "1x6ffps8q7mnawmcfq740llzy7i10g3319vap0wiw4d33fm6z1zh"))))
884 (build-system perl-build-system)
885 (native-inputs
886 `(("perl-crypt-openssl-guess" ,perl-crypt-openssl-guess)))
887 (inputs
888 `(("openssl" ,openssl)))
889 (arguments perl-crypt-arguments)
890 (home-page
891 "https://metacpan.org/release/Crypt-OpenSSL-Random")
892 (synopsis
893 "OpenSSL/LibreSSL pseudo-random number generator access")
894 (description "Crypt::OpenSSL::Random is a OpenSSL/LibreSSL pseudo-random
895 number generator")
896 (license license:perl-license)))
897
898 (define-public acme-client
899 (package
900 (name "acme-client")
901 (version "0.1.16")
902 (source (origin
903 (method url-fetch)
904 (uri (string-append "https://kristaps.bsd.lv/" name "/"
905 "snapshots/" name "-portable-"
906 version ".tgz"))
907 (sha256
908 (base32
909 "00q05b3b1dfnfp7sr1nbd212n0mqrycl3cr9lbs51m7ncaihbrz9"))))
910 (build-system gnu-build-system)
911 (arguments
912 '(#:tests? #f ; no test suite
913 #:make-flags
914 (list "CC=gcc"
915 (string-append "PREFIX=" (assoc-ref %outputs "out")))
916 #:phases
917 (modify-phases %standard-phases
918 (add-after 'unpack 'patch-paths
919 (lambda* (#:key inputs #:allow-other-keys)
920 (let ((pem (string-append (assoc-ref inputs "libressl")
921 "/etc/ssl/cert.pem")))
922 (substitute* "http.c"
923 (("/etc/ssl/cert.pem") pem))
924 #t)))
925 (delete 'configure)))) ; no './configure' script
926 (native-inputs
927 `(("pkg-config" ,pkg-config)))
928 (inputs
929 `(("libbsd" ,libbsd)
930 ("libressl" ,libressl)))
931 (synopsis "Let's Encrypt client by the OpenBSD project")
932 (description "acme-client is a Let's Encrypt client implemented in C. It
933 uses a modular design, and attempts to secure itself by dropping privileges and
934 operating in a chroot where possible. acme-client is developed on OpenBSD and
935 then ported to the GNU / Linux environment.")
936 (home-page "https://kristaps.bsd.lv/acme-client/")
937 ;; acme-client is distributed under the ISC license, but the files 'jsmn.h'
938 ;; and 'jsmn.c' are distributed under the Expat license.
939 (license (list license:isc license:expat))))
940
941 ;; The "-apache" variant is the upstreamed prefered variant. A "-gpl"
942 ;; variant exists in addition to the "-apache" one.
943 (define-public mbedtls-apache
944 (package
945 (name "mbedtls-apache")
946 ;; XXX Check whether ‘-Wformat-signedness’ still breaks mbedtls-for-hiawatha
947 ;; when updating.
948 (version "2.23.0")
949 (source
950 (origin
951 (method git-fetch)
952 (uri (git-reference
953 (url "https://github.com/ARMmbed/mbedtls")
954 (commit (string-append "mbedtls-" version))))
955 (sha256
956 (base32 "13fa9h2i989cbf8n8c0j019mshv6wg213va18my1s787lhcq2d62"))
957 (file-name (git-file-name name version))))
958 (build-system cmake-build-system)
959 (arguments
960 `(#:configure-flags
961 (list "-DUSE_SHARED_MBEDTLS_LIBRARY=ON"
962 "-DUSE_STATIC_MBEDTLS_LIBRARY=OFF")
963 #:phases
964 (modify-phases %standard-phases
965 (add-after 'unpack 'make-source-writable
966 (lambda _
967 (for-each make-file-writable (find-files "."))
968 #t)))))
969 (native-inputs
970 `(("perl" ,perl)
971 ("python" ,python)))
972 (synopsis "Small TLS library")
973 (description
974 "@code{mbed TLS}, formerly known as PolarSSL, makes it trivially easy
975 for developers to include cryptographic and SSL/TLS capabilities in their
976 (embedded) products, facilitating this functionality with a minimal
977 coding footprint.")
978 (home-page "https://tls.mbed.org")
979 (license license:asl2.0)))
980
981 ;; The Hiawatha Web server requires some specific features to be enabled.
982 (define-public mbedtls-for-hiawatha
983 (hidden-package
984 (package
985 (inherit mbedtls-apache)
986 (arguments
987 (substitute-keyword-arguments (package-arguments mbedtls-apache)
988 ((#:phases phases)
989 `(modify-phases ,phases
990 (add-before 'configure 'configure-extra-features
991 (lambda _
992 (for-each (lambda (feature)
993 (invoke "scripts/config.pl" "set" feature))
994 (list "MBEDTLS_THREADING_C"
995 "MBEDTLS_THREADING_PTHREAD"))
996 ;; XXX The above enables code that breaks with -Werror…
997 (substitute* "CMakeLists.txt"
998 ((" -Wformat-signedness") ""))
999 #t)))))))))
1000
1001 (define-public dehydrated
1002 (package
1003 (name "dehydrated")
1004 (version "0.7.0")
1005 (source (origin
1006 (method url-fetch)
1007 (uri (string-append
1008 "https://github.com/dehydrated-io/dehydrated/releases/download/"
1009 "v" version "/dehydrated-" version ".tar.gz"))
1010 (sha256
1011 (base32
1012 "1yf4kldyd5y13r6qxrkcbbk74ykngq7jzy0351vb2r3ywp114pqw"))))
1013 (build-system trivial-build-system)
1014 (arguments
1015 `(#:modules ((guix build utils)
1016 (srfi srfi-26))
1017 #:builder
1018 (begin
1019 (use-modules (guix build utils)
1020 (srfi srfi-26))
1021 (let* ((source (assoc-ref %build-inputs "source"))
1022 (tar (assoc-ref %build-inputs "tar"))
1023 (gz (assoc-ref %build-inputs "gzip"))
1024 (out (assoc-ref %outputs "out"))
1025 (bin (string-append out "/bin"))
1026 (doc (string-append out "/share/doc/" ,name "-" ,version))
1027 (man (string-append out "/share/man"))
1028 (bash (in-vicinity (assoc-ref %build-inputs "bash") "bin")))
1029
1030 (setenv "PATH" (string-append gz "/bin"))
1031 (invoke (string-append tar "/bin/tar") "xvf" source)
1032 (chdir (string-append ,name "-" ,version))
1033
1034 (copy-recursively "docs" doc)
1035 (install-file "LICENSE" doc)
1036
1037 (mkdir-p man)
1038 (rename-file (string-append doc "/man")
1039 (string-append man "/man1"))
1040 (for-each (cut invoke "gzip" "-9" <>)
1041 (find-files man ".*"))
1042
1043 (install-file "dehydrated" bin)
1044 (with-directory-excursion bin
1045 (patch-shebang "dehydrated" (list bash))
1046
1047 ;; Do not try to write to the store.
1048 (substitute* "dehydrated"
1049 (("SCRIPTDIR=\"\\$.*\"") "SCRIPTDIR=~/.dehydrated"))
1050
1051 (setenv "PATH" bash)
1052 (wrap-program "dehydrated"
1053 `("PATH" ":" prefix
1054 ,(map (lambda (dir)
1055 (string-append dir "/bin"))
1056 (map (lambda (input)
1057 (assoc-ref %build-inputs input))
1058 '("coreutils"
1059 "curl"
1060 "diffutils"
1061 "gawk"
1062 "grep"
1063 "openssl"
1064 "sed"))))))
1065 #t))))
1066 (inputs
1067 `(("bash" ,bash)
1068 ("coreutils" ,coreutils)
1069 ("curl" ,curl)
1070 ("diffutils" ,diffutils)
1071 ("gawk" ,gawk)
1072 ("grep" ,grep)
1073 ("openssl" ,openssl)
1074 ("sed" ,sed)))
1075 (native-inputs
1076 `(("gzip" ,gzip)
1077 ("tar" ,tar)))
1078 (home-page "https://dehydrated.io/")
1079 (synopsis "Let's Encrypt/ACME client implemented as a shell script")
1080 (description "Dehydrated is a client for signing certificates with an
1081 ACME-server (currently only provided by Let's Encrypt) implemented as a
1082 relatively simple Bash script.")
1083 (license license:expat)))
1084
1085 (define-public go-github-com-certifi-gocertifi
1086 (let ((commit "a5e0173ced670013bfb649c7e806bc9529c986ec")
1087 (revision "1"))
1088 (package
1089 (name "go-github-com-certifi-gocertifi")
1090 (version (git-version "2018.01.18" revision commit))
1091 (source (origin
1092 (method git-fetch)
1093 (uri (git-reference
1094 (url "https://github.com/certifi/gocertifi")
1095 (commit commit)))
1096 (file-name (git-file-name name version))
1097 (sha256
1098 (base32
1099 "1n9drccl3q1rr8wg3nf60slkf1lgsmz5ahifrglbdrc6har3rryj"))))
1100 (build-system go-build-system)
1101 (arguments
1102 '(#:import-path "github.com/certifi/gocertifi"))
1103 (synopsis "X.509 TLS root certificate bundle for Go")
1104 (description "This package is a Go language X.509 TLS root certificate bundle,
1105 derived from Mozilla's collection.")
1106 (home-page "https://certifi.io")
1107 (license license:mpl2.0))))
1108
1109 (define-public s2n
1110 (package
1111 (name "s2n")
1112 (version "1.0.0")
1113 (source (origin
1114 (method git-fetch)
1115 (uri (git-reference
1116 (url (string-append "https://github.com/awslabs/" name))
1117 (commit (string-append "v" version))))
1118 (file-name (git-file-name name version))
1119 (sha256
1120 (base32
1121 "1q6kmgwb8jxmc4ijzk9pkqzz8lsbfsv9hyzqvy944w7306zx1r5h"))))
1122 (build-system cmake-build-system)
1123 (arguments
1124 '(#:tests? #f ; tests fail to build for static library
1125 #:configure-flags
1126 '("-DBUILD_TESTING=OFF"
1127 "-DBUILD_SHARED_LIBS=ON")))
1128 (propagated-inputs
1129 `(("openssl" ,openssl)
1130 ("openssl:static" ,openssl "static")))
1131 (synopsis "SSL/TLS implementation")
1132 (description "This library provides a C99 implementation of SSL/TLS.")
1133 (home-page "https://github.com/awslabs/s2n")
1134 (license license:asl2.0)))