gnu: OpenSSL: Remove obsolete code.
[jackhill/guix/guix.git] / gnu / packages / tls.scm
CommitLineData
233e7676 1;;; GNU Guix --- Functional package management for GNU
3c0f7910 2;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
05f6e601 3;;; Copyright © 2014, 2015, 2016, 2017, 2018 Mark H Weaver <mhw@netris.org>
29a7c98a 4;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net>
cc2b77df 5;;; Copyright © 2013, 2015 Andreas Enge <andreas@enge.fr>
9fd0838b 6;;; Copyright © 2015 David Thompson <davet@gnu.org>
2a5b5bfd 7;;; Copyright © 2015, 2016, 2017, 2018 Leo Famulari <leo@famulari.name>
2ed12d3f 8;;; Copyright © 2016, 2017 Efraim Flashner <efraim@flashner.co.il>
0741932b 9;;; Copyright © 2016, 2017, 2018 Nils Gillmann <ng0@n0.is>
375cef6c 10;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com>
ee33f9a7 11;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
d5c472a2 12;;; Copyright © 2017, 2018 Marius Bakke <mbakke@fastmail.com>
fe15613c 13;;; Copyright © 2017, 2018 Tobias Geerinckx-Rice <me@tobias.gr>
fbf5ca3c 14;;; Copyright © 2017 Rutger Helling <rhelling@mykolab.com>
e8b3a158 15;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org>
7543f865 16;;;
233e7676 17;;; This file is part of GNU Guix.
7543f865 18;;;
233e7676 19;;; GNU Guix is free software; you can redistribute it and/or modify it
7543f865
LC
20;;; under the terms of the GNU General Public License as published by
21;;; the Free Software Foundation; either version 3 of the License, or (at
22;;; your option) any later version.
23;;;
233e7676 24;;; GNU Guix is distributed in the hope that it will be useful, but
7543f865
LC
25;;; WITHOUT ANY WARRANTY; without even the implied warranty of
26;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27;;; GNU General Public License for more details.
28;;;
29;;; You should have received a copy of the GNU General Public License
233e7676 30;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
7543f865 31
a7fd7b68 32(define-module (gnu packages tls)
e9aa8d0c 33 #:use-module ((guix licenses) #:prefix license:)
7543f865
LC
34 #:use-module (guix packages)
35 #:use-module (guix download)
29a7c98a 36 #:use-module (guix utils)
7543f865 37 #:use-module (guix build-system gnu)
cc2b77df 38 #:use-module (guix build-system perl)
7890e3ba 39 #:use-module (guix build-system python)
88522738 40 #:use-module (guix build-system cmake)
587d1752 41 #:use-module (guix build-system haskell)
e8b3a158 42 #:use-module (guix build-system trivial)
f61e0e79 43 #:use-module (gnu packages compression)
013ce67b 44 #:use-module (gnu packages)
e8b3a158 45 #:use-module (gnu packages bash)
ac257f12 46 #:use-module (gnu packages check)
e8b3a158 47 #:use-module (gnu packages curl)
5b9aa107 48 #:use-module (gnu packages dns)
e8b3a158 49 #:use-module (gnu packages gawk)
1ffa7090 50 #:use-module (gnu packages guile)
587d1752
RW
51 #:use-module (gnu packages haskell)
52 #:use-module (gnu packages haskell-check)
53 #:use-module (gnu packages haskell-crypto)
0581c273 54 #:use-module (gnu packages libbsd)
27e86bed 55 #:use-module (gnu packages libffi)
866f469e 56 #:use-module (gnu packages libidn)
5d4c90ae 57 #:use-module (gnu packages linux)
7890e3ba 58 #:use-module (gnu packages ncurses)
27e86bed 59 #:use-module (gnu packages nettle)
1ffa7090 60 #:use-module (gnu packages perl)
27e86bed 61 #:use-module (gnu packages pkg-config)
7890e3ba 62 #:use-module (gnu packages python)
cc6f4912 63 #:use-module (gnu packages python-crypto)
1b2f753d 64 #:use-module (gnu packages python-web)
44d10b1f 65 #:use-module (gnu packages python-xyz)
a31f4d35 66 #:use-module (gnu packages texinfo)
33dc54b0 67 #:use-module (gnu packages time)
079f013b
LC
68 #:use-module (gnu packages base)
69 #:use-module (srfi srfi-1))
7543f865
LC
70
71(define-public libtasn1
72 (package
73 (name "libtasn1")
2a5b5bfd 74 (version "4.13")
7543f865
LC
75 (source
76 (origin
77 (method url-fetch)
78 (uri (string-append "mirror://gnu/libtasn1/libtasn1-"
79 version ".tar.gz"))
80 (sha256
81 (base32
2a5b5bfd 82 "1jlc1iahj8k3haz28j55nzg7sgni5h41vqy461i1bpbx6668wlky"))))
7543f865 83 (build-system gnu-build-system)
d9f84612
MB
84 (arguments
85 `(#:configure-flags '("--disable-static")))
3ea110b7 86 (native-inputs `(("perl" ,perl)))
6fd52309 87 (home-page "https://www.gnu.org/software/libtasn1/")
f50d2669 88 (synopsis "ASN.1 library")
7543f865 89 (description
79c311b8
LC
90 "GNU libtasn1 is a library implementing the ASN.1 notation. It is used
91for transmitting machine-neutral encodings of data objects in computer
a22dc0c4
LC
92networking, allowing for formal validation of data according to some
93specifications.")
e9aa8d0c 94 (license license:lgpl2.0+)))
7543f865 95
375cef6c
HG
96(define-public asn1c
97 (package
98 (name "asn1c")
ff7da7e0 99 (version "0.9.28")
375cef6c
HG
100 (source (origin
101 (method url-fetch)
102 (uri (string-append "https://lionet.info/soft/asn1c-"
103 version ".tar.gz"))
104 (sha256
105 (base32
ff7da7e0 106 "1fc64g45ykmv73kdndr4zdm4wxhimhrir4rxnygxvwkych5l81w0"))))
375cef6c
HG
107 (build-system gnu-build-system)
108 (native-inputs
109 `(("perl" ,perl)))
110 (home-page "https://lionet.info/asn1c")
111 (synopsis "ASN.1 to C compiler")
112 (description "The ASN.1 to C compiler takes ASN.1 module
113files and generates C++ compatible C source code. That code can be
114used to serialize the native C structures into compact and unambiguous
115BER/XER/PER-based data files, and deserialize the files back.
116
117Various ASN.1 based formats are widely used in the industry, such as to encode
118the X.509 certificates employed in the HTTPS handshake, to exchange control
119data between mobile phones and cellular networks, to car-to-car communication
120in intelligent transportation networks.")
121 (license license:bsd-2)))
122
27e86bed
AE
123(define-public p11-kit
124 (package
125 (name "p11-kit")
39855bfe 126 (version "0.23.15")
27e86bed
AE
127 (source
128 (origin
129 (method url-fetch)
e6ad9bda
MB
130 (uri (string-append "https://github.com/p11-glue/p11-kit/releases/"
131 "download/" version "/p11-kit-" version ".tar.gz"))
39855bfe 132 (patches (search-patches "p11-kit-jks-timestamps.patch"))
27e86bed
AE
133 (sha256
134 (base32
39855bfe 135 "166pwj00cffv4qq4dvx0k53zka0b0r1fa0whc49007vsqyh3khgp"))))
27e86bed
AE
136 (build-system gnu-build-system)
137 (native-inputs
138 `(("pkg-config" ,pkg-config)))
139 (inputs
140 `(("libffi" ,libffi)
141 ("libtasn1" ,libtasn1)))
142 (arguments
d5c472a2
MB
143 `(#:configure-flags '("--without-trust-paths")
144 #:phases (modify-phases %standard-phases
145 (add-before 'check 'prepare-tests
146 (lambda _
147 ;; "test-runtime" expects XDG_RUNTIME_DIR to be set up
148 ;; and looks for .cache and other directories (only).
149 ;; For simplicity just drop it since it is irrelevant
150 ;; in the build container.
151 (substitute* "Makefile"
152 (("test-runtime\\$\\(EXEEXT\\)") ""))
153 #t)))))
4631e6c9 154 (home-page "https://p11-glue.freedesktop.org/p11-kit.html")
27e86bed
AE
155 (synopsis "PKCS#11 library")
156 (description
157 "p11-kit provides a way to load and enumerate PKCS#11 modules. It
158provides a standard configuration setup for installing PKCS#11 modules
159in such a way that they are discoverable. It also solves problems with
160coordinating the use of PKCS#11 by different components or libraries
161living in the same process.")
e9aa8d0c 162 (license license:bsd-3)))
27e86bed 163
7543f865
LC
164(define-public gnutls
165 (package
166 (name "gnutls")
06f5bc4e 167 (version "3.6.5")
d7d408d5
LC
168 (source (origin
169 (method url-fetch)
170 (uri
171 ;; Note: Releases are no longer on ftp.gnu.org since the
172 ;; schism (after version 3.1.5).
d93627e4 173 (string-append "mirror://gnupg/gnutls/v"
29a7c98a 174 (version-major+minor version)
d93627e4 175 "/gnutls-" version ".tar.xz"))
06f5bc4e 176 (patches (search-patches "gnutls-skip-trust-store-test.patch"))
d7d408d5
LC
177 (sha256
178 (base32
06f5bc4e
MB
179 "0ddvg97dyrh8dkffv1mdc0knxx5my3qdbzv97s4a6jggmk9wwgh7"))
180 (modules '((guix build utils)))
181 (snippet
182 '(begin
183 ;; XXX: The generated configure script in GnuTLS 3.6.5
184 ;; apparently does not know about Guile 2.2.
185 (substitute* "configure"
186 (("guile_versions_to_search=\"2\\.0 1\\.8\"")
187 "guile_versions_to_search=\"2.2 2.0 1.8\""))
188 #t))))
7543f865 189 (build-system gnu-build-system)
b94ae0b8 190 (arguments
76b21274
LF
191 `(; Ensure we don't keep a reference to this buggy software.
192 #:disallowed-references (,net-tools)
193 #:configure-flags
a0700787 194 (list
aa7c7f21
MW
195 ;; GnuTLS doesn't consult any environment variables to specify
196 ;; the location of the system-wide trust store. Instead it has a
197 ;; configure-time option. Unless specified, its configure script
198 ;; attempts to auto-detect the location by looking for common
8f65585b 199 ;; places in the file system, none of which are present in our
aa7c7f21
MW
200 ;; chroot build environment. If not found, then no default trust
201 ;; store is used, so each program has to provide its own
202 ;; fallback, and users have to configure each program
203 ;; independently. This seems suboptimal.
866f469e
MW
204 "--with-default-trust-store-dir=/etc/ssl/certs"
205
206 ;; FIXME: Temporarily disable p11-kit support since it is not
207 ;; working on mips64el.
606c6380
LC
208 "--without-p11-kit")
209
210 #:phases (modify-phases %standard-phases
211 (add-after
212 'install 'move-doc
213 (lambda* (#:key outputs #:allow-other-keys)
214 ;; Copy the 4.1 MiB of section 3 man pages to "doc".
215 (let* ((out (assoc-ref outputs "out"))
216 (doc (assoc-ref outputs "doc"))
9cdce047 217 (mandir (string-append doc "/share/man/man3"))
606c6380
LC
218 (oldman (string-append out "/share/man/man3")))
219 (mkdir-p mandir)
220 (copy-recursively oldman mandir)
221 (delete-file-recursively oldman)
222 #t))))))
223 (outputs '("out" ;4.4 MiB
224 "debug"
225 "doc")) ;4.1 MiB of man pages
a1db0975 226 (native-inputs
c06d8ba5 227 `(("net-tools" ,net-tools)
5d4c90ae 228 ("pkg-config" ,pkg-config)
d2fcfd3d 229 ("which" ,which)))
7543f865 230 (inputs
a0700787 231 `(("guile" ,guile-2.2)))
7543f865 232 (propagated-inputs
d2fcfd3d 233 ;; These are all in the 'Requires.private' field of gnutls.pc.
7543f865 234 `(("libtasn1" ,libtasn1)
55e61c4d 235 ("libidn2" ,libidn2)
866f469e 236 ("nettle" ,nettle)
f61e0e79 237 ("zlib" ,zlib)))
c19700c3 238 (home-page "https://www.gnu.org/software/gnutls/")
f50d2669 239 (synopsis "Transport layer security library")
7543f865 240 (description
a22dc0c4 241 "GnuTLS is a secure communications library implementing the SSL, TLS
79c311b8 242and DTLS protocols. It is provided in the form of a C library to support the
a22dc0c4
LC
243protocols, as well as to parse and write X.5009, PKCS 12, OpenPGP and other
244required structures.")
63e8bb12
LC
245 (license license:lgpl2.1+)
246 (properties '((ftp-server . "ftp.gnutls.org")
247 (ftp-directory . "/gcrypt/gnutls")))))
cc2b77df 248
079f013b 249(define-public gnutls/guile-2.2
a0700787
LC
250 (deprecated-package "guile2.2-gnutls" gnutls))
251
252(define-public gnutls/guile-2.0
253 ;; GnuTLS for Guile 2.0.
079f013b 254 (package
58ea4d40 255 (inherit gnutls)
a0700787
LC
256 (name "guile2.0-gnutls")
257 (inputs `(("guile" ,guile-2.0)
58ea4d40 258 ,@(alist-delete "guile" (package-inputs gnutls))))))
079f013b 259
5b9aa107 260(define-public gnutls/dane
261 ;; GnuTLS with build libgnutls-dane, implementing DNS-based
262 ;; Authentication of Named Entities. This is required for GNS functionality
263 ;; by GNUnet and gnURL. This is done in an extra package definition
264 ;; to have the choice between GnuTLS with Dane and without Dane.
265 (package
266 (inherit gnutls)
267 (name "gnutls-dane")
268 (inputs `(("unbound" ,unbound)
269 ,@(package-inputs gnutls)))))
270
cc2b77df
AE
271(define-public openssl
272 (package
273 (name "openssl")
01710194 274 (version "1.0.2p")
cc2b77df 275 (source (origin
4cff124b 276 (method url-fetch)
bdf0b6fc
MB
277 (uri (list (string-append "https://www.openssl.org/source/openssl-"
278 version ".tar.gz")
279 (string-append "ftp://ftp.openssl.org/source/"
4cff124b
LC
280 name "-" version ".tar.gz")
281 (string-append "ftp://ftp.openssl.org/source/old/"
282 (string-trim-right version char-set:letter)
283 "/" name "-" version ".tar.gz")))
284 (sha256
285 (base32
01710194 286 "003xh9f898i56344vpvpxxxzmikivxig4xwlm7vbi7m8n43qxaah"))
fc1adab1 287 (patches (search-patches "openssl-runpath.patch"
1d8de185 288 "openssl-c-rehash-in.patch"))))
cc2b77df 289 (build-system gnu-build-system)
8c78aeb7 290 (outputs '("out"
a909b576 291 "doc" ;1.5MiB of man3 pages
8c78aeb7 292 "static")) ;6MiB of .a files
cc2b77df
AE
293 (native-inputs `(("perl" ,perl)))
294 (arguments
d03781c3
LC
295 `(#:disallowed-references (,perl)
296 #:parallel-build? #f
cc2b77df
AE
297 #:parallel-tests? #f
298 #:test-target "test"
8c9ec203
LF
299
300 ;; Changes to OpenSSL sometimes cause Perl to "sneak in" to the closure,
301 ;; so we explicitly disallow it here.
302 #:disallowed-references ,(list (canonical-package perl))
cc2b77df 303 #:phases
b6cb1358 304 (modify-phases %standard-phases
4fb254a3 305 (add-before
86c8f1da 306 'configure 'patch-Makefile.org
4fb254a3
LC
307 (lambda* (#:key outputs #:allow-other-keys)
308 ;; The default MANDIR is some unusual place. Fix that.
309 (let ((out (assoc-ref outputs "out")))
86c8f1da 310 (patch-makefile-SHELL "Makefile.org")
4fb254a3
LC
311 (substitute* "Makefile.org"
312 (("^MANDIR[[:blank:]]*=.*$")
313 (string-append "MANDIR = " out "/share/man\n")))
314 #t)))
b6cb1358
LC
315 (replace
316 'configure
317 (lambda* (#:key outputs #:allow-other-keys)
318 (let ((out (assoc-ref outputs "out")))
0d98cb9a 319 (invoke "./config"
5011d3f4
SB
320 "shared" ;build shared libraries
321 "--libdir=lib"
4fb254a3 322
5011d3f4
SB
323 ;; The default for this catch-all directory is
324 ;; PREFIX/ssl. Change that to something more
325 ;; conventional.
326 (string-append "--openssldir=" out
327 "/share/openssl-" ,version)
4fb254a3 328
18784d8f 329 (string-append "--prefix=" out)))))
fe8199a8
LC
330 (add-after
331 'install 'make-libraries-writable
332 (lambda* (#:key outputs #:allow-other-keys)
333 ;; Make libraries writable so that 'strip' does its job.
334 (let ((out (assoc-ref outputs "out")))
335 (for-each (lambda (file)
336 (chmod file #o644))
337 (find-files (string-append out "/lib")
338 "\\.so"))
339 #t)))
8c78aeb7
LC
340 (add-after 'install 'move-static-libraries
341 (lambda* (#:key outputs #:allow-other-keys)
342 ;; Move static libraries to the "static" output.
343 (let* ((out (assoc-ref outputs "out"))
344 (lib (string-append out "/lib"))
345 (static (assoc-ref outputs "static"))
346 (slib (string-append static "/lib")))
8c78aeb7
LC
347 (for-each (lambda (file)
348 (install-file file slib)
349 (delete-file file))
350 (find-files lib "\\.a$"))
351 #t)))
a909b576
LC
352 (add-after 'install 'move-man3-pages
353 (lambda* (#:key outputs #:allow-other-keys)
354 ;; Move section 3 man pages to "doc".
355 (let* ((out (assoc-ref outputs "out"))
356 (man3 (string-append out "/share/man/man3"))
357 (doc (assoc-ref outputs "doc"))
358 (target (string-append doc "/share/man/man3")))
359 (mkdir-p target)
360 (for-each (lambda (file)
361 (rename-file file
362 (string-append target "/"
363 (basename file))))
364 (find-files man3))
5c838ec9 365 (delete-file-recursively man3)
a909b576 366 #t)))
b6cb1358
LC
367 (add-before
368 'patch-source-shebangs 'patch-tests
369 (lambda* (#:key inputs native-inputs #:allow-other-keys)
370 (let ((bash (assoc-ref (or native-inputs inputs) "bash")))
371 (substitute* (find-files "test" ".*")
372 (("/bin/sh")
08a78c2f 373 (string-append bash "/bin/sh"))
b6cb1358 374 (("/bin/rm")
86c8f1da
MW
375 "rm"))
376 #t)))
784d6e91
LC
377 (add-after
378 'install 'remove-miscellany
379 (lambda* (#:key outputs #:allow-other-keys)
380 ;; The 'misc' directory contains random undocumented shell and Perl
381 ;; scripts. Remove them to avoid retaining a reference on Perl.
382 (let ((out (assoc-ref outputs "out")))
383 (delete-file-recursively (string-append out "/share/openssl-"
384 ,version "/misc"))
385 #t))))))
cc2b77df 386 (native-search-paths
cc2b77df
AE
387 (list (search-path-specification
388 (variable "SSL_CERT_DIR")
5d7a47cc 389 (separator #f) ;single entry
cc2b77df
AE
390 (files '("etc/ssl/certs")))
391 (search-path-specification
392 (variable "SSL_CERT_FILE")
5d7a47cc
MB
393 (file-type 'regular)
394 (separator #f) ;single entry
cc2b77df
AE
395 (files '("etc/ssl/certs/ca-certificates.crt")))))
396 (synopsis "SSL/TLS implementation")
397 (description
e881752c 398 "OpenSSL is an implementation of SSL/TLS.")
e9aa8d0c 399 (license license:openssl)
4631e6c9 400 (home-page "https://www.openssl.org/")))
cc2b77df 401
763899f0
LF
402(define-public openssl-next
403 (package
404 (inherit openssl)
405 (name "openssl")
6ec43b0d 406 (version "1.1.1a")
763899f0
LF
407 (source (origin
408 (method url-fetch)
77576be4
MB
409 (uri (list (string-append "https://www.openssl.org/source/openssl-"
410 version ".tar.gz")
411 (string-append "ftp://ftp.openssl.org/source/"
763899f0
LF
412 name "-" version ".tar.gz")
413 (string-append "ftp://ftp.openssl.org/source/old/"
414 (string-trim-right version char-set:letter)
415 "/" name "-" version ".tar.gz")))
9e9e5d5a 416 (patches (search-patches "openssl-1.1-c-rehash-in.patch"))
763899f0
LF
417 (sha256
418 (base32
6ec43b0d 419 "0hcz7znzznbibpy3iyyhvlqrq44y88plxwdj32wjzgbwic7i687w"))))
763899f0 420 (outputs '("out"
6ec43b0d 421 "doc" ; 6.8 MiB of man3 pages and full HTML documentation
9e9e5d5a 422 "static")) ; 6.4 MiB of .a files
763899f0
LF
423 (arguments
424 (substitute-keyword-arguments (package-arguments openssl)
425 ((#:phases phases)
426 `(modify-phases ,phases
427 (delete 'patch-tests) ; These two phases are not needed by
6ec43b0d 428 (delete 'patch-Makefile.org) ; OpenSSL 1.1.
763899f0 429
fc184fe2
MB
430 ;; Override configure phase since -rpath is now a configure option.
431 (replace 'configure
763899f0 432 (lambda* (#:key outputs #:allow-other-keys)
fc184fe2
MB
433 (let* ((out (assoc-ref outputs "out"))
434 (lib (string-append out "/lib")))
9e9e5d5a
LF
435 ;; It's not a shebang so patch-source-shebangs misses it.
436 (substitute* "config"
437 (("/usr/bin/env")
438 (string-append (assoc-ref %build-inputs "coreutils")
439 "/bin/env")))
0d98cb9a 440 (invoke "./config"
5011d3f4
SB
441 "shared" ;build shared libraries
442 "--libdir=lib"
fc184fe2 443
5011d3f4
SB
444 ;; The default for this catch-all directory is
445 ;; PREFIX/ssl. Change that to something more
446 ;; conventional.
447 (string-append "--openssldir=" out
448 "/share/openssl-" ,version)
fc184fe2 449
5011d3f4 450 (string-append "--prefix=" out)
799de468 451 (string-append "-Wl,-rpath," lib)))))
fc184fe2 452
9e9e5d5a
LF
453 (delete 'move-man3-pages)
454 (add-after 'install 'move-extra-documentation
455 (lambda* (#:key outputs #:allow-other-keys)
456 ;; Move man3 pages and full HTML documentation to "doc".
457 (let* ((out (assoc-ref outputs "out"))
458 (man3 (string-append out "/share/man/man3"))
459 (html (string-append out "/share/doc/openssl"))
460 (doc (assoc-ref outputs "doc"))
461 (man-target (string-append doc "/share/man/man3"))
462 (html-target (string-append doc "/share/doc/openssl")))
463 (copy-recursively man3 man-target)
464 (delete-file-recursively man3)
465 (copy-recursively html html-target)
466 (delete-file-recursively html)
467 #t)))
fc184fe2
MB
468 ;; XXX: Duplicate this phase to make sure 'version' evaluates
469 ;; in the current scope and not the inherited one.
470 (replace 'remove-miscellany
471 (lambda* (#:key outputs #:allow-other-keys)
472 ;; The 'misc' directory contains random undocumented shell and Perl
473 ;; scripts. Remove them to avoid retaining a reference on Perl.
474 (let ((out (assoc-ref outputs "out")))
475 (delete-file-recursively (string-append out "/share/openssl-"
476 ,version "/misc"))
763899f0
LF
477 #t)))))))))
478
cb6a802c
AE
479(define-public libressl
480 (package
481 (name "libressl")
0effadca 482 (version "2.7.4")
644e5f17
TGR
483 (source (origin
484 (method url-fetch)
485 (uri (string-append "mirror://openbsd/LibreSSL/"
486 name "-" version ".tar.gz"))
487 (sha256
488 (base32
0effadca 489 "19kxa5i97q7p6rrps9qm0nd8zqhdjvzx02j72400c73cl2nryfhy"))))
cb6a802c 490 (build-system gnu-build-system)
a2d64899
LC
491 (arguments
492 ;; Do as if 'getentropy' was missing since older Linux kernels lack it
493 ;; and libc would return ENOSYS, which is not properly handled.
494 ;; See <https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00235.html>.
df08f385
LF
495 '(#:configure-flags '("ac_cv_func_getentropy=no"
496 ;; Provide a TLS-enabled netcat.
497 "--enable-nc")))
cb6a802c
AE
498 (native-search-paths
499 ;; FIXME: These two variables must designate a single file or directory
500 ;; and are not actually "search paths." In practice it works OK in
501 ;; user profiles because there's always just one item that matches the
502 ;; specification.
503 (list (search-path-specification
504 (variable "SSL_CERT_DIR")
505 (files '("etc/ssl/certs")))
506 (search-path-specification
507 (variable "SSL_CERT_FILE")
508 (files '("etc/ssl/certs/ca-certificates.crt")))))
2ed12d3f 509 (home-page "https://www.libressl.org/")
cb6a802c 510 (synopsis "SSL/TLS implementation")
df08f385
LF
511 (description "LibreSSL is a version of the TLS/crypto stack, forked from
512OpenSSL in 2014 with the goals of modernizing the codebase, improving security,
513and applying best practice development processes. This package also includes a
514netcat implementation that supports TLS.")
cb6a802c
AE
515 ;; Files taken from OpenSSL keep their license, others are under various
516 ;; non-copyleft licenses.
517 (license (list license:openssl
518 (license:non-copyleft
519 "file://COPYING"
520 "See COPYING in the distribution.")))))
521
6cefd53d 522(define-public python-acme
7890e3ba 523 (package
6cefd53d 524 (name "python-acme")
686d4259 525 ;; Remember to update the hash of certbot when updating python-acme.
ed362d16 526 (version "0.31.0")
7890e3ba 527 (source (origin
9495cf9a 528 (method url-fetch)
f349d36e 529 (uri (pypi-uri "acme" version))
881006b6
MB
530 (sha256
531 (base32
ed362d16 532 "1gxjv09c695lj8swspa390nch117i60qkrgy135383vfk00jsp3y"))))
7890e3ba
LF
533 (build-system python-build-system)
534 (arguments
6cefd53d 535 `(#:phases
9bee9d87 536 (modify-phases %standard-phases
1fc8476d
MB
537 (add-after 'build 'build-documentation
538 (lambda _
d4bd2453 539 (invoke "make" "-C" "docs" "man" "info")))
1fc8476d 540 (add-after 'install 'install-documentation
50a7963a
LF
541 (lambda* (#:key outputs #:allow-other-keys)
542 (let* ((out (assoc-ref outputs "out"))
543 (man (string-append out "/share/man/man1"))
544 (info (string-append out "/info")))
1fc8476d
MB
545 (install-file "docs/_build/texinfo/acme-python.info" info)
546 (install-file "docs/_build/man/acme-python.1" man)
547 #t))))))
50a7963a 548 ;; TODO: Add optional inputs for testing.
7890e3ba 549 (native-inputs
4ae65558 550 `(("python-mock" ,python-mock)
b494bbe4 551 ("python-pytest" ,python-pytest)
50a7963a
LF
552 ;; For documentation
553 ("python-sphinx" ,python-sphinx)
554 ("python-sphinxcontrib-programoutput" ,python-sphinxcontrib-programoutput)
555 ("python-sphinx-rtd-theme" ,python-sphinx-rtd-theme)
50a7963a 556 ("texinfo" ,texinfo)))
7890e3ba 557 (propagated-inputs
92572184
LF
558 `(("python-josepy" ,python-josepy)
559 ("python-six" ,python-six)
6cefd53d 560 ("python-requests" ,python-requests)
b494bbe4 561 ("python-requests-toolbelt" ,python-requests-toolbelt)
6cefd53d
LF
562 ("python-pytz" ,python-pytz)
563 ("python-pyrfc3339" ,python-pyrfc3339)
564 ("python-pyasn1" ,python-pyasn1)
565 ("python-cryptography" ,python-cryptography)
566 ("python-pyopenssl" ,python-pyopenssl)))
4631e6c9 567 (home-page "https://github.com/certbot/certbot")
7890e3ba
LF
568 (synopsis "ACME protocol implementation in Python")
569 (description "ACME protocol implementation in Python")
570 (license license:asl2.0)))
571
9495cf9a 572(define-public certbot
9fd0838b 573 (package
9495cf9a 574 (name "certbot")
686d4259
LF
575 ;; Certbot and python-acme are developed in the same repository, and their
576 ;; versions should remain synchronized.
577 (version (package-version python-acme))
9fd0838b
DT
578 (source (origin
579 (method url-fetch)
f349d36e 580 (uri (pypi-uri name version))
9fd0838b
DT
581 (sha256
582 (base32
ed362d16 583 "0wq4jgyzli684h154w26xplp0fzyks2vlrnmhafhyb0h1bw9cc8c"))))
9fd0838b
DT
584 (build-system python-build-system)
585 (arguments
fed1898d 586 `(,@(substitute-keyword-arguments (package-arguments python-acme)
f26d6e4e
LF
587 ((#:phases phases)
588 `(modify-phases ,phases
1fc8476d 589 (replace 'install-documentation
f26d6e4e
LF
590 (lambda* (#:key outputs #:allow-other-keys)
591 (let* ((out (assoc-ref outputs "out"))
592 (man1 (string-append out "/share/man/man1"))
593 (man7 (string-append out "/share/man/man7"))
594 (info (string-append out "/info")))
1fc8476d
MB
595 (install-file "docs/_build/texinfo/Certbot.info" info)
596 (install-file "docs/_build/man/certbot.1" man1)
597 (install-file "docs/_build/man/certbot.7" man7)
598 #t))))))))
f9263d9a 599 ;; TODO: Add optional inputs for testing.
9fd0838b 600 (native-inputs
fed1898d 601 `(("python-nose" ,python-nose)
4ae65558 602 ("python-mock" ,python-mock)
f9263d9a 603 ;; For documentation
fed1898d
LF
604 ("python-sphinx" ,python-sphinx)
605 ("python-sphinx-rtd-theme" ,python-sphinx-rtd-theme)
606 ("python-sphinx-repoze-autointerface" ,python-sphinx-repoze-autointerface)
607 ("python-sphinxcontrib-programoutput" ,python-sphinxcontrib-programoutput)
f9263d9a 608 ("texinfo" ,texinfo)))
9fd0838b 609 (propagated-inputs
fed1898d
LF
610 `(("python-acme" ,python-acme)
611 ("python-zope-interface" ,python-zope-interface)
612 ("python-pyrfc3339" ,python-pyrfc3339)
613 ("python-pyopenssl" ,python-pyopenssl)
614 ("python-configobj" ,python-configobj)
615 ("python-configargparse" ,python-configargparse)
616 ("python-zope-component" ,python-zope-component)
617 ("python-parsedatetime" ,python-parsedatetime)
618 ("python-six" ,python-six)
619 ("python-psutil" ,python-psutil)
620 ("python-requests" ,python-requests)
621 ("python-pytz" ,python-pytz)))
d8a1be63 622 (synopsis "Let's Encrypt client by the Electronic Frontier Foundation")
80968df0
TGR
623 (description "Certbot automatically receives and installs X.509 certificates
624to enable Transport Layer Security (TLS) on servers. It interoperates with the
625Let’s Encrypt certificate authority (CA), which issues browser-trusted
626certificates for free.")
24778368 627 (home-page "https://certbot.eff.org/")
9fd0838b
DT
628 (license license:asl2.0)))
629
9495cf9a
LF
630(define-public letsencrypt
631 (package (inherit certbot)
56ab55d1
LF
632 (name "letsencrypt")
633 (properties `((superseded . ,certbot)))))
9495cf9a 634
cc2b77df
AE
635(define-public perl-net-ssleay
636 (package
637 (name "perl-net-ssleay")
fe15613c 638 (version "1.85")
cc2b77df
AE
639 (source (origin
640 (method url-fetch)
641 (uri (string-append "mirror://cpan/authors/id/M/MI/MIKEM/"
642 "Net-SSLeay-" version ".tar.gz"))
643 (sha256
644 (base32
fe15613c 645 "1j5h4ycm8538397l204d2d5fkm9595aj174pj7bkpbhwzfwqi0cx"))))
cc2b77df
AE
646 (build-system perl-build-system)
647 (inputs `(("openssl" ,openssl)))
648 (arguments
1084ec08
MW
649 `(#:phases
650 (modify-phases %standard-phases
1084ec08
MW
651 (add-before
652 'configure 'set-ssl-prefix
653 (lambda* (#:key inputs #:allow-other-keys)
654 (setenv "OPENSSL_PREFIX" (assoc-ref inputs "openssl"))
655 #t)))))
cc2b77df
AE
656 (synopsis "Perl extension for using OpenSSL")
657 (description
658 "This module offers some high level convenience functions for accessing
659web pages on SSL servers (for symmetry, the same API is offered for accessing
660http servers, too), an sslcat() function for writing your own clients, and
661finally access to the SSL api of the SSLeay/OpenSSL package so you can write
662servers or clients for more complicated applications.")
2f3108ad 663 (license license:perl-license)
9aba9b12 664 (home-page "https://metacpan.org/release/Net-SSLeay")))
4532c0c0
DM
665
666(define-public perl-crypt-openssl-rsa
667 (package
668 (name "perl-crypt-openssl-rsa")
a9994b27 669 (version "0.31")
4532c0c0
DM
670 (source
671 (origin
672 (method url-fetch)
673 (uri (string-append
683b8d47 674 "mirror://cpan/authors/id/T/TO/TODDR/Crypt-OpenSSL-RSA-"
4532c0c0
DM
675 version
676 ".tar.gz"))
677 (sha256
678 (base32
a9994b27 679 "0djl5i6kibl7862b6ih29q8dhg5zpwzq77q9j8hp6xngshx40ws1"))))
4532c0c0 680 (build-system perl-build-system)
683b8d47
TGR
681 (native-inputs
682 `(("perl-crypt-openssl-guess" ,perl-crypt-openssl-guess)))
4532c0c0
DM
683 (inputs
684 `(("perl-crypt-openssl-bignum" ,perl-crypt-openssl-bignum)
685 ("perl-crypt-openssl-random" ,perl-crypt-openssl-random)
686 ("openssl" ,openssl)))
687 (arguments perl-crypt-arguments)
688 (home-page
9aba9b12 689 "https://metacpan.org/release/Crypt-OpenSSL-RSA")
4532c0c0
DM
690 (synopsis
691 "RSA encoding and decoding, using the openSSL libraries")
692 (description "Crypt::OpenSSL::RSA does RSA encoding and decoding (using the
693OpenSSL libraries).")
2f3108ad 694 (license license:perl-license)))
adff71ca
DM
695
696(define perl-crypt-arguments
697 `(#:phases (modify-phases %standard-phases
698 (add-before 'configure 'patch-Makefile.PL
699 (lambda* (#:key inputs #:allow-other-keys)
700 (substitute* "Makefile.PL"
701 (("'LIBS'.*=>.*") (string-append "'LIBS' => ['-L"
702 (assoc-ref inputs "openssl")
703 "/lib -lcrypto'],")))
704 #t)))))
705
706(define-public perl-crypt-openssl-bignum
707 (package
708 (name "perl-crypt-openssl-bignum")
7e8aac18 709 (version "0.09")
adff71ca
DM
710 (source
711 (origin
712 (method url-fetch)
713 (uri (string-append
714 "mirror://cpan/authors/id/K/KM/KMX/Crypt-OpenSSL-Bignum-"
715 version
716 ".tar.gz"))
717 (sha256
718 (base32
7e8aac18 719 "1p22znbajq91lbk2k3yg12ig7hy5b4vy8igxwqkmbm4nhgxp4ki3"))))
adff71ca
DM
720 (build-system perl-build-system)
721 (inputs `(("openssl" ,openssl)))
722 (arguments perl-crypt-arguments)
723 (home-page
9aba9b12 724 "https://metacpan.org/release/Crypt-OpenSSL-Bignum")
adff71ca
DM
725 (synopsis
726 "OpenSSL's multiprecision integer arithmetic in Perl")
727 (description "Crypt::OpenSSL::Bignum provides multiprecision integer
728arithmetic in Perl.")
729 ;; At your option either gpl1+ or the Artistic License
2f3108ad 730 (license license:perl-license)))
cccb4d26 731
c80590f6
TGR
732(define-public perl-crypt-openssl-guess
733 (package
734 (name "perl-crypt-openssl-guess")
735 (version "0.11")
736 (source
737 (origin
738 (method url-fetch)
739 (uri (string-append
740 "mirror://cpan/authors/id/A/AK/AKIYM/Crypt-OpenSSL-Guess-"
741 version ".tar.gz"))
742 (sha256
743 (base32
744 "0rvi9l4ljcbhwwvspq019nfq2h2v746dk355h2nwnlmqikiihsxa"))))
745 (build-system perl-build-system)
9aba9b12 746 (home-page "https://metacpan.org/release/Crypt-OpenSSL-Guess")
c80590f6
TGR
747 (synopsis "Guess the OpenSSL include path")
748 (description
749 "The Crypt::OpenSSL::Guess Perl module provides helpers to guess the
750correct OpenSSL include path. It is intended for use in your
751@file{Makefile.PL}.")
752 (license license:perl-license)))
753
cccb4d26
DM
754(define-public perl-crypt-openssl-random
755 (package
756 (name "perl-crypt-openssl-random")
b30c23c4 757 (version "0.13")
cccb4d26
DM
758 (source
759 (origin
760 (method url-fetch)
761 (uri (string-append
762 "mirror://cpan/authors/id/R/RU/RURBAN/Crypt-OpenSSL-Random-"
763 version
764 ".tar.gz"))
765 (sha256
766 (base32
b30c23c4 767 "0vmvrb3shrzjzri3qn524dzdasbq8zhhbpc1vmq8sx68n4jhizb0"))))
cccb4d26 768 (build-system perl-build-system)
b30c23c4
TGR
769 (native-inputs
770 `(("perl-crypt-openssl-guess" ,perl-crypt-openssl-guess)))
771 (inputs
772 `(("openssl" ,openssl)))
cccb4d26
DM
773 (arguments perl-crypt-arguments)
774 (home-page
9aba9b12 775 "https://metacpan.org/release/Crypt-OpenSSL-Random")
cccb4d26
DM
776 (synopsis
777 "OpenSSL/LibreSSL pseudo-random number generator access")
778 (description "Crypt::OpenSSL::Random is a OpenSSL/LibreSSL pseudo-random
779number generator")
2f3108ad 780 (license license:perl-license)))
0581c273
LF
781
782(define-public acme-client
783 (package
784 (name "acme-client")
4a6b2a21 785 (version "0.1.16")
0581c273
LF
786 (source (origin
787 (method url-fetch)
788 (uri (string-append "https://kristaps.bsd.lv/" name "/"
789 "snapshots/" name "-portable-"
790 version ".tgz"))
791 (sha256
792 (base32
4a6b2a21 793 "00q05b3b1dfnfp7sr1nbd212n0mqrycl3cr9lbs51m7ncaihbrz9"))))
0581c273
LF
794 (build-system gnu-build-system)
795 (arguments
796 '(#:tests? #f ; no test suite
797 #:make-flags
798 (list "CC=gcc"
799 (string-append "PREFIX=" (assoc-ref %outputs "out")))
800 #:phases
801 (modify-phases %standard-phases
7c1a7bf4
LF
802 (add-after 'unpack 'patch-paths
803 (lambda* (#:key inputs #:allow-other-keys)
804 (let ((pem (string-append (assoc-ref inputs "libressl")
805 "/etc/ssl/cert.pem")))
806 (substitute* "http.c"
807 (("/etc/ssl/cert.pem") pem))
808 #t)))
0581c273 809 (delete 'configure)))) ; no './configure' script
4b569a4f
LF
810 (native-inputs
811 `(("pkg-config" ,pkg-config)))
0581c273
LF
812 (inputs
813 `(("libbsd" ,libbsd)
814 ("libressl" ,libressl)))
815 (synopsis "Let's Encrypt client by the OpenBSD project")
816 (description "acme-client is a Let's Encrypt client implemented in C. It
817uses a modular design, and attempts to secure itself by dropping privileges and
818operating in a chroot where possible. acme-client is developed on OpenBSD and
819then ported to the GNU / Linux environment.")
820 (home-page "https://kristaps.bsd.lv/acme-client/")
821 ;; acme-client is distributed under the ISC license, but the files 'jsmn.h'
822 ;; and 'jsmn.c' are distributed under the Expat license.
823 (license (list license:isc license:expat))))
88522738 824
825;; The "-apache" variant is the upstreamed prefered variant. A "-gpl"
826;; variant exists in addition to the "-apache" one.
827(define-public mbedtls-apache
828 (package
829 (name "mbedtls-apache")
5a7899fd 830 (version "2.16.0")
88522738 831 (source
832 (origin
833 (method url-fetch)
834 ;; XXX: The download links on the website are script redirection links
835 ;; which effectively lead to the format listed in the uri here.
836 (uri (string-append "https://tls.mbed.org/download/mbedtls-"
837 version "-apache.tgz"))
838 (sha256
839 (base32
5a7899fd 840 "1qlscr0m97favkqmrlj90rlgw40h8lcypxz0snvr1iwkj1pbbnp3"))))
88522738 841 (build-system cmake-build-system)
a64d9d56
RW
842 (arguments
843 `(#:configure-flags
844 (list "-DUSE_SHARED_MBEDTLS_LIBRARY=ON")))
88522738 845 (native-inputs
38a9bf80
TGR
846 `(("perl" ,perl)
847 ("python" ,python)))
88522738 848 (synopsis "Small TLS library")
849 (description
850 "@code{mbed TLS}, formerly known as PolarSSL, makes it trivially easy
851for developers to include cryptographic and SSL/TLS capabilities in their
852(embedded) products, facilitating this functionality with a minimal
853coding footprint.")
854 (home-page "https://tls.mbed.org")
855 (license license:asl2.0)))
587d1752 856
8e87aa04
TGR
857;; The Hiawatha Web server requires some specific features to be enabled.
858(define-public mbedtls-for-hiawatha
859 (hidden-package
860 (package
861 (inherit mbedtls-apache)
862 (arguments
863 (substitute-keyword-arguments
864 `(#:phases
865 (modify-phases %standard-phases
866 (add-after 'configure 'configure-extra-features
867 (lambda _
868 (for-each (lambda (feature)
869 (invoke "scripts/config.pl" "set" feature))
870 (list "MBEDTLS_THREADING_C"
871 "MBEDTLS_THREADING_PTHREAD"))
872 #t)))
873 ,@(package-arguments mbedtls-apache)))))))
874
587d1752
RW
875(define-public ghc-tls
876 (package
877 (name "ghc-tls")
66c5de39 878 (version "1.4.1")
587d1752
RW
879 (source (origin
880 (method url-fetch)
881 (uri (string-append "https://hackage.haskell.org/package/"
882 "tls/tls-" version ".tar.gz"))
883 (sha256
884 (base32
66c5de39 885 "1y083724mym28n6xfaz7pcc7zqxdhjpaxpbvzxfbs25qq2px3smv"))))
587d1752
RW
886 (build-system haskell-build-system)
887 (inputs
f54f0475 888 `(("ghc-cereal" ,ghc-cereal)
587d1752
RW
889 ("ghc-data-default-class" ,ghc-data-default-class)
890 ("ghc-memory" ,ghc-memory)
891 ("ghc-cryptonite" ,ghc-cryptonite)
892 ("ghc-asn1-types" ,ghc-asn1-types)
893 ("ghc-asn1-encoding" ,ghc-asn1-encoding)
894 ("ghc-x509" ,ghc-x509)
895 ("ghc-x509-store" ,ghc-x509-store)
896 ("ghc-x509-validation" ,ghc-x509-validation)
897 ("ghc-async" ,ghc-async)
898 ("ghc-network" ,ghc-network)
899 ("ghc-hourglass" ,ghc-hourglass)))
900 (native-inputs
901 `(("ghc-tasty" ,ghc-tasty)
902 ("ghc-tasty-quickcheck" ,ghc-tasty-quickcheck)
903 ("ghc-quickcheck" ,ghc-quickcheck)))
904 (home-page "https://github.com/vincenthz/hs-tls")
905 (synopsis
906 "TLS/SSL protocol native implementation (Server and Client)")
907 (description
908 "Native Haskell TLS and SSL protocol implementation for server and client.
909This provides a high-level implementation of a sensitive security protocol,
910eliminating a common set of security issues through the use of the advanced
911type system, high level constructions and common Haskell features. Currently
912implement the SSL3.0, TLS1.0, TLS1.1 and TLS1.2 protocol, and support RSA and
913Ephemeral (Elliptic curve and regular) Diffie Hellman key exchanges, and many
914extensions.")
915 (license license:bsd-3)))
e8b3a158
CL
916
917(define-public dehydrated
918 (package
919 (name "dehydrated")
920 (version "0.6.2")
921 (source (origin
922 (method url-fetch/tarbomb)
923 (uri (string-append
924 "https://github.com/lukas2511/dehydrated/archive/v"
925 version ".tar.gz"))
926 (sha256
927 (base32
928 "03p80yj6bnzjc6dkp5hb9wpplmlrla8n5src71cnzw4rj53q8cqn"))
929 (file-name (string-append name "-" version ".tar.gz"))))
930 (build-system trivial-build-system)
931 (arguments
932 `(#:modules ((guix build utils))
933 #:builder
934 (begin
935 (use-modules (guix build utils))
936 (let* ((source (assoc-ref %build-inputs "source"))
937 (out (assoc-ref %outputs "out"))
938 (bin (string-append out "/bin"))
939 (bash (in-vicinity (assoc-ref %build-inputs "bash") "bin")))
940 (mkdir-p bin)
941 (with-directory-excursion bin
942 (copy-file
943 (in-vicinity source (string-append "/dehydrated-" ,version
944 "/dehydrated"))
945 (in-vicinity bin "dehydrated"))
946 (patch-shebang "dehydrated" (list bash))
947
948 ;; Do not try to write in the store.
949 (substitute* "dehydrated"
950 (("SCRIPTDIR=\"\\$.*\"") "SCRIPTDIR=~/.dehydrated"))
951
952 (setenv "PATH" bash)
953 (wrap-program "dehydrated"
954 `("PATH" ":" prefix
955 ,(map (lambda (dir)
956 (string-append dir "/bin"))
957 (map (lambda (input)
958 (assoc-ref %build-inputs input))
959 '("coreutils"
960 "curl"
961 "diffutils"
962 "gawk"
963 "grep"
964 "openssl"
965 "sed"))))))
966 #t))))
967 (inputs
968 `(("bash" ,bash)
969 ("coreutils" ,coreutils)
970 ("curl" ,curl)
971 ("diffutils" ,diffutils)
972 ("gawk" ,gawk)
973 ("grep" ,grep)
974 ("openssl" ,openssl)
975 ("sed" ,sed)))
976 (home-page "https://dehydrated.io/")
977 (synopsis "Let's Encrypt/ACME client implemented as a shell script")
978 (description "Dehydrated is a client for signing certificates with an
979ACME-server (currently only provided by Let's Encrypt) implemented as a
980relatively simple Bash script.")
981 (license license:expat)))