diff options
author | Jakub Kądziołka <kuba@kadziolka.net> | 2020-01-14 17:59:21 +0100 |
---|---|---|
committer | Marius Bakke <mbakke@fastmail.com> | 2020-01-15 00:25:51 +0100 |
commit | a76a343082d61d5303b61a9e4cbde4ab8515a1e7 (patch) | |
tree | d1eb7b093c1d717c2dc015721fe0f0d4b4d7fda6 | |
parent | bb93042c8beb881ab907fa802eefb3c4091039a2 (diff) |
gnu: curl: Make libcurl respect SSL_CERT_DIR and SSL_CERT_FILE.
* gnu/packages/patches/curl-use-ssl-cert-env.patch: New file.
* gnu/local.mk (dist_patch_DATA): Adjust accordingly.
* gnu/packages/curl.scm (curl)[source]: Use the patch.
[native-search-paths]: Add the new variables.
Signed-off-by: Marius Bakke <mbakke@fastmail.com>
-rw-r--r-- | gnu/local.mk | 1 | ||||
-rw-r--r-- | gnu/packages/curl.scm | 20 | ||||
-rw-r--r-- | gnu/packages/patches/curl-use-ssl-cert-env.patch | 64 |
3 files changed, 81 insertions, 4 deletions
diff --git a/gnu/local.mk b/gnu/local.mk index 62ea29cdbb..659098deb5 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -789,6 +789,7 @@ dist_patch_DATA = \ %D%/packages/patches/csvkit-fix-tests.patch \ %D%/packages/patches/clucene-contribs-lib.patch \ %D%/packages/patches/cube-nocheck.patch \ + %D%/packages/patches/curl-use-ssl-cert-env.patch \ %D%/packages/patches/cursynth-wave-rand.patch \ %D%/packages/patches/cvs-CVE-2017-12836.patch \ %D%/packages/patches/cyrus-sasl-ac-try-run-fix.patch \ diff --git a/gnu/packages/curl.scm b/gnu/packages/curl.scm index ee1cca449b..3d230dc1f0 100644 --- a/gnu/packages/curl.scm +++ b/gnu/packages/curl.scm @@ -9,6 +9,7 @@ ;;; Copyright © 2017, 2018 Tobias Geerinckx-Rice <me@tobias.gr> ;;; Copyright © 2018 Roel Janssen <roel@gnu.org> ;;; Copyright © 2019 Ricardo Wurmus <rekado@elephly.net> +;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net> ;;; ;;; This file is part of GNU Guix. ;;; @@ -57,7 +58,8 @@ version ".tar.xz")) (sha256 (base32 - "0nh3j90w6b97wqcgxjfq55qhkz9s38955fbhwzv2fsi7483j895p")))) + "0nh3j90w6b97wqcgxjfq55qhkz9s38955fbhwzv2fsi7483j895p")) + (patches (search-patches "curl-use-ssl-cert-env.patch")))) (build-system gnu-build-system) (outputs '("out" "doc")) ;1.2 MiB of man3 pages @@ -74,10 +76,20 @@ ("pkg-config" ,pkg-config) ("python" ,python-wrapper))) (native-search-paths - ;; Note: This search path is respected by the `curl` command-line tool only. - ;; Ideally we would bake this into libcurl itself so other users can benefit, - ;; but it's not supported upstream due to thread safety concerns. + ;; These variables are introduced by libcurl-use-ssl-cert-env.patch. (list (search-path-specification + (variable "SSL_CERT_DIR") + (separator #f) ;single entry + (files '("etc/ssl/certs"))) + (search-path-specification + (variable "SSL_CERT_FILE") + (file-type 'regular) + (separator #f) ;single entry + (files '("etc/ssl/certs/ca-certificates.crt"))) + ;; Note: This search path is respected by the `curl` command-line + ;; tool only. Patching libcurl to read it too would bring no + ;; advantages and require maintaining a more complex patch. + (search-path-specification (variable "CURL_CA_BUNDLE") (file-type 'regular) (separator #f) ;single entry diff --git a/gnu/packages/patches/curl-use-ssl-cert-env.patch b/gnu/packages/patches/curl-use-ssl-cert-env.patch new file mode 100644 index 0000000000..c8e80b4445 --- /dev/null +++ b/gnu/packages/patches/curl-use-ssl-cert-env.patch @@ -0,0 +1,64 @@ +Make libcurl respect the SSL_CERT_{DIR,FILE} variables by default. The variables +are fetched during initialization to preserve thread-safety (curl_global_init(3) +must be called when no other threads exist). + +This fixes network functionality in rust:cargo, and probably removes the need +for other future workarounds. +=================================================================== +--- curl-7.66.0.orig/lib/easy.c 2020-01-02 15:43:11.883921171 +0100 ++++ curl-7.66.0/lib/easy.c 2020-01-02 16:18:54.691882797 +0100 +@@ -134,6 +134,9 @@ + # pragma warning(default:4232) /* MSVC extension, dllimport identity */ + #endif + ++char * Curl_ssl_cert_dir = NULL; ++char * Curl_ssl_cert_file = NULL; ++ + /** + * curl_global_init() globally initializes curl given a bitwise set of the + * different features of what to initialize. +@@ -155,6 +158,9 @@ + #endif + } + ++ Curl_ssl_cert_dir = curl_getenv("SSL_CERT_DIR"); ++ Curl_ssl_cert_file = curl_getenv("SSL_CERT_FILE"); ++ + if(!Curl_ssl_init()) { + DEBUGF(fprintf(stderr, "Error: Curl_ssl_init failed\n")); + return CURLE_FAILED_INIT; +@@ -260,6 +266,9 @@ + Curl_ssl_cleanup(); + Curl_resolver_global_cleanup(); + ++ free(Curl_ssl_cert_dir); ++ free(Curl_ssl_cert_file); ++ + #ifdef WIN32 + Curl_win32_cleanup(init_flags); + #endif +diff -ur curl-7.66.0.orig/lib/url.c curl-7.66.0/lib/url.c +--- curl-7.66.0.orig/lib/url.c 2020-01-02 15:43:11.883921171 +0100 ++++ curl-7.66.0/lib/url.c 2020-01-02 16:21:11.563880346 +0100 +@@ -524,6 +524,21 @@ + if(result) + return result; + #endif ++ extern char * Curl_ssl_cert_dir; ++ extern char * Curl_ssl_cert_file; ++ if(Curl_ssl_cert_dir) { ++ if(result = Curl_setstropt(&set->str[STRING_SSL_CAPATH_ORIG], Curl_ssl_cert_dir)) ++ return result; ++ if(result = Curl_setstropt(&set->str[STRING_SSL_CAPATH_PROXY], Curl_ssl_cert_dir)) ++ return result; ++ } ++ ++ if(Curl_ssl_cert_file) { ++ if(result = Curl_setstropt(&set->str[STRING_SSL_CAFILE_ORIG], Curl_ssl_cert_file)) ++ return result; ++ if(result = Curl_setstropt(&set->str[STRING_SSL_CAFILE_PROXY], Curl_ssl_cert_file)) ++ return result; ++ } + } + + set->wildcard_enabled = FALSE; |