You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

125 lines
5.0 KiB

;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015 Andreas Enge <>
;;; Copyright © 2015 Mark H Weaver <>
;;; This file is part of GNU Guix.
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; GNU General Public License for more details.
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix. If not, see <>.
(define-module (gnu packages certs)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix packages)
#:use-module (guix download)
#:use-module (guix build-system gnu)
#:use-module (guix build-system trivial)
#:use-module (gnu packages)
#:use-module (gnu packages gnuzilla)
#:use-module (gnu packages openssl)
#:use-module (gnu packages python))
(define certdata2pem
(name "certdata2pem")
(version "2013")
(method url-fetch)
(file-name "")
(build-system trivial-build-system)
`(("python" ,python-2)))
`(#:modules ((guix build utils))
(use-modules (guix build utils))
(let ((bin (string-append %output "/bin")))
(copy-file (assoc-ref %build-inputs "source") "")
(chmod "" #o555)
(substitute* ""
(string-append (assoc-ref %build-inputs "python")
;; Use the file extension .pem instead of .crt.
(("crt") "pem"))
(mkdir-p bin)
(copy-file ""
(string-append bin "/"))))))
(synopsis "Python script to extract .pem data from certificate collection")
" is a Python script to transform X.509 certificate
\"source code\" as contained, for example, in the Mozilla sources, into
.pem formatted certificates.")
(license license:gpl2+)
(home-page "")))
(define-public nss-certs
(package (inherit nss) ; to reuse the source, version and some metadata
(name "nss-certs")
(build-system gnu-build-system)
(outputs '("out"))
`(("certdata2pem" ,certdata2pem)
("openssl" ,openssl)))
(inputs '())
(propagated-inputs '())
`(#:modules ((guix build gnu-build-system)
(guix build utils)
(rnrs io ports)
(srfi srfi-26)
(ice-9 regex))
'unpack 'install
(lambda _
(let ((certsdir (string-append %output "/etc/ssl/certs/"))
(trusted-rx (make-regexp "^# openssl-trust=[a-zA-Z]"
(define (maybe-install-cert file)
(let ((cert (call-with-input-file file get-string-all)))
(when (regexp-exec trusted-rx cert)
(string-append certsdir file)
(cut display cert <>)))))
(mkdir-p certsdir)
(with-directory-excursion "nss/lib/ckfw/builtins/"
;; extract single certificates from blob
(system* "" "certdata.txt")
;; copy selected .pem files into the output
(for-each maybe-install-cert
(find-files "." ".*\\.pem")))
(with-directory-excursion certsdir
;; create symbolic links for and by openssl
;; Strangely, the call (system* "c_rehash" certsdir)
;; from inside the build dir fails with
;; "Usage error; try -help."
;; This looks like a bug in openssl-1.0.2, but we can also
;; switch into the target directory.
(system* "c_rehash" "."))))
(map (cut assq <> %standard-phases)
'(set-paths install-locale unpack)))))
(synopsis "CA certificates from Mozilla")
"This package provides certificates for Certification Authorities (CA)
taken from the NSS package and thus ultimately from the Mozilla project.")))