]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: httpclient/ssl: verify required
authorWilliam Lallemand <wlallemand@haproxy.org>
Fri, 22 Apr 2022 12:48:45 +0000 (14:48 +0200)
committerWilliam Lallemand <wlallemand@haproxy.org>
Fri, 22 Apr 2022 13:45:47 +0000 (15:45 +0200)
The httpclient HTTPS requests now enable the "verify required" option.
To achieve this, the "@system-ca" ca-file is configured in the
httpclient ssl server. Which means all the system CAs will be loaded at
haproxy startup.

src/http_client.c

index 0e9621713d5d96de9cba78cb391f59fe71e357f8..60d05e6cb8b86a787ce5297a720749344b8f9af1 100644 (file)
@@ -15,6 +15,7 @@
 #include <haproxy/api.h>
 #include <haproxy/applet.h>
 #include <haproxy/cli.h>
+#include <haproxy/ssl_ckch.h>
 #include <haproxy/dynbuf.h>
 #include <haproxy/cfgparse.h>
 #include <haproxy/conn_stream.h>
@@ -1039,7 +1040,11 @@ static int httpclient_precheck()
        if (!httpclient_srv_ssl->id)
                goto err;
 
-       httpclient_srv_ssl->ssl_ctx.verify = SSL_SOCK_VERIFY_NONE;
+       httpclient_srv_ssl->ssl_ctx.verify = SSL_SOCK_VERIFY_REQUIRED;
+       httpclient_srv_ssl->ssl_ctx.ca_file = strdup("@system-ca");
+       if (!ssl_store_load_locations_file(httpclient_srv_ssl->ssl_ctx.ca_file, 1, CAFILE_CERT))
+               goto err;
+
 #endif
 
        /* add the proxy in the proxy list only if everything is successful */