download: Load *.crt certificate bundles when *.pem files are missing.

Fixes <https://bugs.gnu.org/38254>.

* guix/build/download.scm (make-credendials-with-ca-trust-files): Look
for *.crt files under DIRECTORY when *.pem files cannot be found.
This commit is contained in:
Ludovic Courtès 2019-11-18 10:32:26 +01:00
parent 5544f1e3ea
commit 0d78d0f09c
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -187,10 +187,13 @@ (define (make-credendials-with-ca-trust-files directory)
DIRECTORY. Those authority certificates are checked when DIRECTORY. Those authority certificates are checked when
'peer-certificate-status' is later called." 'peer-certificate-status' is later called."
(let ((cred (make-certificate-credentials)) (let ((cred (make-certificate-credentials))
(files (or (scandir directory (files (match (scandir directory (cut string-suffix? ".pem" <>))
(lambda (file) ((or #f ())
(string-suffix? ".pem" file))) ;; Some distros provide nothing but bundles (*.crt) under
'()))) ;; /etc/ssl/certs, so look for them.
(or (scandir directory (cut string-suffix? ".crt" <>))
'()))
(pem pem))))
(for-each (lambda (file) (for-each (lambda (file)
(let ((file (string-append directory "/" file))) (let ((file (string-append directory "/" file)))
;; Protect against dangling symlinks. ;; Protect against dangling symlinks.
@ -198,7 +201,7 @@ (define (make-credendials-with-ca-trust-files directory)
(set-certificate-credentials-x509-trust-file!* (set-certificate-credentials-x509-trust-file!*
cred file cred file
x509-certificate-format/pem)))) x509-certificate-format/pem))))
(or files '())) files)
cred)) cred))
(define (peer-certificate session) (define (peer-certificate session)