Skip to content

Commit

Permalink
lib-http: test-http-client - Only load existing CAs
Browse files Browse the repository at this point in the history
Otherwise the SSL tests do not properly work.

Fixes Error: HTTP Request failed: Couldn't initialize SSL context: Can't load CA certs from directory /etc/ssl/certs: error:02001002:system library:fopen:No such file or directory: fopen('/etc/pki/tls/cert.pem','r'), error:2006D080:BIO routines:BIO_new_file:no such file, error:0B084002:x509 certificate routines:X509_load_cert_crl_file:system lib
  • Loading branch information
cmouse authored and villesavolainen committed May 28, 2018
1 parent edbed11 commit 0313b5f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/lib-http/test-http-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ int main(int argc, char *argv[])
struct http_client_context *http_cctx;
struct http_client *http_client1, *http_client2, *http_client3, *http_client4;
struct ssl_iostream_settings ssl_set;
struct stat st;
const char *error;

lib_init();
Expand All @@ -377,8 +378,10 @@ int main(int argc, char *argv[])

i_zero(&ssl_set);
ssl_set.allow_invalid_cert = TRUE;
ssl_set.ca_dir = "/etc/ssl/certs"; /* debian */
ssl_set.ca_file = "/etc/pki/tls/cert.pem"; /* redhat */
if (stat("/etc/ssl/certs", &st) == 0 && S_ISDIR(st.st_mode))
ssl_set.ca_dir = "/etc/ssl/certs"; /* debian */
if (stat("/etc/ssl/certs", &st) == 0 && S_ISREG(st.st_mode))
ssl_set.ca_file = "/etc/pki/tls/cert.pem"; /* redhat */

i_zero(&http_set);
http_set.ssl = &ssl_set;
Expand Down

0 comments on commit 0313b5f

Please sign in to comment.