projects/guix·blob java-team · refs

259 lines · 10.7 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2016-2017, 2021-2022 Ludovic Courtès <[email protected]>
3;;; Copyright © 2017 Leo Famulari <[email protected]>
4;;; Copyright © 2021 Maxim Cournoyer <[email protected]>
5;;; Copyright © 2021 Raghav Gururajan <[email protected]>
6;;; Copyright © 2025 Luca Kredel <[email protected]>
7;;;
8;;; This file is part of GNU Guix.
9;;;
10;;; GNU Guix is free software; you can redistribute it and/or modify it
11;;; under the terms of the GNU General Public License as published by
12;;; the Free Software Foundation; either version 3 of the License, or (at
13;;; your option) any later version.
14;;;
15;;; GNU Guix is distributed in the hope that it will be useful, but
16;;; WITHOUT ANY WARRANTY; without even the implied warranty of
17;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;;; GNU General Public License for more details.
19;;;
20;;; You should have received a copy of the GNU General Public License
21;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
22
23(define-module (gnu packages certs)
24 #:use-module ((guix licenses) #:prefix license:)
25 #:use-module (guix packages)
26 #:use-module (guix utils)
27 #:use-module (guix download)
28 #:use-module (guix gexp)
29 #:use-module (guix git-download)
30 #:use-module (guix build-system copy)
31 #:use-module (guix build-system gnu)
32 #:use-module (guix build-system trivial)
33 #:use-module (guix build-system go)
34 #:use-module (gnu packages)
35 #:use-module (gnu packages nss)
36 #:use-module (gnu packages curl)
37 #:use-module (gnu packages python)
38 #:use-module (gnu packages perl)
39 #:use-module (gnu packages golang-crypto)
40 #:use-module (gnu packages golang-build)
41 #:use-module (gnu packages tls))
42
43(define-public certdata2pem
44 (let ((revision "1")
45 (commit "4c576f350f44186d439179f63d5be19f710a73f5"))
46 (package
47 (name "certdata2pem")
48 (version "0.0.0") ;no version
49 (source (origin
50 (method url-fetch)
51 (uri (string-append
52 "https://raw.githubusercontent.com/sabotage-linux/sabotage/"
53 commit "/KEEP/certdata2pem.c"))
54 (sha256
55 (base32
56 "1rywp29q4l1cs2baplkbcravxqs4kw2cys4yifhfznbc210pskq6"))))
57 (build-system gnu-build-system)
58 (arguments
59 `(#:phases (modify-phases %standard-phases
60 (delete 'configure)
61 (add-before 'build 'fix-extension
62 (lambda _
63 (substitute* "certdata2pem.c"
64 (("\\.crt")
65 ".pem"))))
66 (replace 'build
67 (lambda _
68 (invoke ,(cc-for-target) "certdata2pem.c"
69 "-o" "certdata2pem")))
70 (delete 'check) ;no test suite
71 (replace 'install
72 (lambda* (#:key outputs #:allow-other-keys)
73 (let ((out (assoc-ref outputs "out")))
74 (install-file "certdata2pem"
75 (string-append out "/bin"))))))))
76 (home-page "https://github.com/sabotage-linux/")
77 (synopsis "Utility to split TLS certificates data into multiple PEM files")
78 (description "This is a C version of the certdata2pem Python utility
79that was originally contributed to Debian.")
80 (license license:isc))))
81
82(define-public desec-certbot-hook
83 (let ((commit "68da7abc0793602fd336962a7e2348b57c5d6fd6")
84 (revision "0"))
85 (package
86 (name "desec-certbot-hook")
87 (version
88 (git-version "0" revision commit))
89 (source
90 (origin
91 (method git-fetch)
92 (uri
93 (git-reference
94 (url "https://github.com/desec-io/desec-certbot-hook")
95 (commit commit)))
96 (file-name (git-file-name name version))
97 (sha256
98 (base32 "0qjqk6i85b1y7fgzcx74r4gn2i4dkjza34hkzp6kyn9hrb8f2gv2"))))
99 (build-system copy-build-system)
100 (arguments
101 `(#:phases
102 (modify-phases %standard-phases
103 (add-after 'unpack 'patch-script
104 (lambda* (#:key inputs #:allow-other-keys)
105 (substitute* "hook.sh"
106 ;; The hook-script look for '.dedynauth' file in $PWD.
107 ;; But users cannot create or edit files in store.
108 ;; So we patch the hook-script to look for '.dedynauth' file,
109 ;; in /etc/desec.
110 (("\\$\\(pwd\\)")
111 "/etc/desec")
112 ;; Make absolute reference to curl program.
113 (("curl")
114 (string-append (assoc-ref inputs "curl")
115 "/bin/curl"))))))
116 #:install-plan
117 '(("." "etc/desec" #:include ("hook.sh")))))
118 (inputs
119 (list curl))
120 (synopsis "Certbot DNS challenge automatization for deSEC")
121 (description "The deSEC can be used to obtain certificates with certbot
122DNS ownership verification. With the help of this hook script, you can obtain
123your Let's Encrypt certificate using certbot with authorization provided by the
124DNS challenge mechanism, that is, you will not need a running web server or any
125port forwarding to your local machine.")
126 (home-page "https://desec.io")
127 (license license:expat))))
128
129(define-public le-certs
130 (package
131 (name "le-certs")
132 (version "1")
133 (source #f)
134 (build-system trivial-build-system)
135 (arguments
136 '(#:modules ((guix build utils))
137 #:builder
138 (begin
139 (use-modules (guix build utils))
140 (let ((root-rsa (assoc-ref %build-inputs "isrgrootx1.pem"))
141 (root-ecdsa (assoc-ref %build-inputs "isrgrootx2.pem"))
142 (intermediate-rsa (assoc-ref %build-inputs "letsencryptauthorityr3.pem"))
143 (intermediate-ecdsa (assoc-ref %build-inputs "letsencryptauthoritye1.pem"))
144 (backup-rsa (assoc-ref %build-inputs "letsencryptauthorityr4.pem"))
145 (backup-ecdsa (assoc-ref %build-inputs "letsencryptauthoritye2.pem"))
146 (out (string-append (assoc-ref %outputs "out") "/etc/ssl/certs"))
147 (openssl (assoc-ref %build-inputs "openssl"))
148 (perl (assoc-ref %build-inputs "perl")))
149 (mkdir-p out)
150 (for-each
151 (lambda (cert)
152 (copy-file cert (string-append out "/"
153 (strip-store-file-name cert))))
154 (list root-rsa root-ecdsa
155 intermediate-rsa intermediate-ecdsa
156 backup-rsa backup-ecdsa))
157
158 ;; Create hash symlinks suitable for OpenSSL ('SSL_CERT_DIR' and
159 ;; similar.)
160 (chdir (string-append %output "/etc/ssl/certs"))
161 (invoke (string-append perl "/bin/perl")
162 (string-append openssl "/bin/c_rehash")
163 ".")))))
164 (native-inputs
165 (list openssl perl)) ;for 'c_rehash'
166 (inputs
167 `(; The Let's Encrypt root certificate, "ISRG Root X1".
168 ("isrgrootx1.pem"
169 ,(origin
170 (method url-fetch)
171 (uri "https://letsencrypt.org/certs/isrgrootx1.pem")
172 (sha256
173 (base32
174 "1la36n2f31j9s03v847ig6ny9lr875q3g7smnq33dcsmf2i5gd92"))))
175 ; Upcoming ECDSA Let's Encrypt root certificate, "ISRG Root X2"
176 ; Let's Encrypt describes it as "Active, limited availability"
177 ("isrgrootx2.pem"
178 ,(origin
179 (method url-fetch)
180 (uri "https://letsencrypt.org/certs/isrg-root-x2.pem")
181 (sha256
182 (base32
183 "04xh8912nwkghqydbqvvmslpqbcafgxgjh9qnn0z2vgy24g8hgd1"))))
184 ;; "Let’s Encrypt Authority R3", the active Let's Encrypt intermediate
185 ;; RSA certificate.
186 ("letsencryptauthorityr3.pem"
187 ,(origin
188 (method url-fetch)
189 (uri "https://letsencrypt.org/certs/lets-encrypt-r3.pem")
190 (sha256
191 (base32
192 "0clxry49rx6qd3pgbzknpgzywbg3j96zy0227wwjnwivqj7inzhp"))))
193 ;; "Let’s Encrypt Authority E1", the active Let's Encrypt intermediate
194 ;; ECDSA certificate.
195 ("letsencryptauthoritye1.pem"
196 ,(origin
197 (method url-fetch)
198 (uri "https://letsencrypt.org/certs/lets-encrypt-e1.pem")
199 (sha256
200 (base32
201 "1zwrc6dlk1qig0z23x6x7fib14rrw41ccbf2ds0rw75zccc59xx0"))))
202 ;; "Let’s Encrypt Authority R4", the backup Let's Encrypt intermediate
203 ;; RSA certificate. This will be used for disaster recovery and will only be
204 ;; used should Let's Encrypt lose the ability to issue with "Let’s
205 ;; Encrypt Authority R3".
206 ("letsencryptauthorityr4.pem"
207 ,(origin
208 (method url-fetch)
209 (uri "https://letsencrypt.org/certs/lets-encrypt-r4.pem")
210 (sha256
211 (base32
212 "09bzxzbwb9x2xxan3p1fyj1pi2p5yks0879gwz5f28y9mzq8vmd8"))))
213 ;; "Let’s Encrypt Authority E2", the backup Let's Encrypt intermediate
214 ;; ECDSA certificate. This will be used for disaster recovery and will
215 ;; only be used should Let's Encrypt lose the ability to issue with "Let’s
216 ;; Encrypt Authority E1".
217 ("letsencryptauthoritye2.pem"
218 ,(origin
219 (method url-fetch)
220 (uri "https://letsencrypt.org/certs/lets-encrypt-e2.pem")
221 (sha256
222 (base32
223 "1wfmsa29lyi9dkh6xdcamb2rhkp5yl2ppnsgrzcrjl5c7gbqh9ml"))))))
224 (home-page "https://letsencrypt.org/certificates/")
225 (synopsis "Let's Encrypt root and intermediate certificates")
226 (description "This package provides a certificate store containing only the
227Let's Encrypt root and intermediate certificates. It is intended to be used
228within Guix.")
229 (license license:public-domain)))
230
231(define-public mkcert
232 (package
233 (name "mkcert")
234 (version "1.4.4")
235 (source
236 (origin
237 (method git-fetch)
238 (uri (git-reference
239 (url "https://github.com/FiloSottile/mkcert")
240 (commit (string-append "v" version))))
241 (file-name (git-file-name name version))
242 (sha256
243 (base32 "0ms9mjspiwlsgsnir0ccj3w8vhvrphf5i6k9q3hrz47y2a6igh0l"))))
244 (build-system go-build-system)
245 (arguments
246 (list
247 #:import-path "filippo.io/mkcert"
248 #:build-flags
249 #~(list (string-append "-ldflags=-X main.Version="
250 #$version))))
251 (native-inputs (list go-golang-org-x-net
252 go-software-sslmate-com-src-go-pkcs12))
253 (synopsis "Zero-config tool to make locally trusted development
254 certificates")
255 (description
256 "mkcert is a simple tool for making locally-trusted development
257 certificates. It requires no configuration.")
258 (home-page "https://github.com/FiloSottile/mkcert")
259 (license license:bsd-3)))