gnu: Add kafs-client
[jackhill/guix/guix.git] / gnu / packages / patches / curl-use-ssl-cert-env.patch
1 Make libcurl respect the SSL_CERT_{DIR,FILE} variables by default. The variables
2 are fetched during initialization to preserve thread-safety (curl_global_init(3)
3 must be called when no other threads exist).
4
5 This fixes network functionality in rust:cargo, and probably removes the need
6 for other future workarounds.
7 ===================================================================
8 --- curl-7.66.0.orig/lib/easy.c 2020-01-02 15:43:11.883921171 +0100
9 +++ curl-7.66.0/lib/easy.c 2020-01-02 16:18:54.691882797 +0100
10 @@ -134,6 +134,9 @@
11 # pragma warning(default:4232) /* MSVC extension, dllimport identity */
12 #endif
13
14 +char * Curl_ssl_cert_dir = NULL;
15 +char * Curl_ssl_cert_file = NULL;
16 +
17 /**
18 * curl_global_init() globally initializes curl given a bitwise set of the
19 * different features of what to initialize.
20 @@ -155,6 +158,9 @@
21 #endif
22 }
23
24 + Curl_ssl_cert_dir = curl_getenv("SSL_CERT_DIR");
25 + Curl_ssl_cert_file = curl_getenv("SSL_CERT_FILE");
26 +
27 if(!Curl_ssl_init()) {
28 DEBUGF(fprintf(stderr, "Error: Curl_ssl_init failed\n"));
29 return CURLE_FAILED_INIT;
30 @@ -260,6 +266,9 @@
31 Curl_ssl_cleanup();
32 Curl_resolver_global_cleanup();
33
34 + free(Curl_ssl_cert_dir);
35 + free(Curl_ssl_cert_file);
36 +
37 #ifdef WIN32
38 Curl_win32_cleanup(init_flags);
39 #endif
40 diff -ur curl-7.66.0.orig/lib/url.c curl-7.66.0/lib/url.c
41 --- curl-7.66.0.orig/lib/url.c 2020-01-02 15:43:11.883921171 +0100
42 +++ curl-7.66.0/lib/url.c 2020-01-02 16:21:11.563880346 +0100
43 @@ -524,6 +524,21 @@
44 if(result)
45 return result;
46 #endif
47 + extern char * Curl_ssl_cert_dir;
48 + extern char * Curl_ssl_cert_file;
49 + if(Curl_ssl_cert_dir) {
50 + if(result = Curl_setstropt(&set->str[STRING_SSL_CAPATH_ORIG], Curl_ssl_cert_dir))
51 + return result;
52 + if(result = Curl_setstropt(&set->str[STRING_SSL_CAPATH_PROXY], Curl_ssl_cert_dir))
53 + return result;
54 + }
55 +
56 + if(Curl_ssl_cert_file) {
57 + if(result = Curl_setstropt(&set->str[STRING_SSL_CAFILE_ORIG], Curl_ssl_cert_file))
58 + return result;
59 + if(result = Curl_setstropt(&set->str[STRING_SSL_CAFILE_PROXY], Curl_ssl_cert_file))
60 + return result;
61 + }
62 }
63
64 set->wildcard_enabled = FALSE;