]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
rustls: make max size of cert and key reasonable
authorYedaya Katsman <yedaya.ka@gmail.com>
Thu, 3 Apr 2025 20:36:05 +0000 (23:36 +0300)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 3 Apr 2025 21:30:36 +0000 (23:30 +0200)
SIZE_MAX is an very overkill size for certificates or keys, lower it to
100KiB for both certificate and keys. The default max size of openssl is
100KiB for the entire chain [1], and it seems firefox fails at ~60kb
[2].

Found by https://github.com/curl/curl/pull/16923

[0] https://docs.openssl.org/3.2/man3/SSL_CTX_set_max_cert_list/#notes
[2] https://0x00.cl/blog/2024/exploring-tls-certs/

Closes #16951

lib/dynbuf.h
lib/vtls/rustls.c

index cc7e5a12ed248cc816a216309bdb97c53f3e8dc5..72471bc104c1dfc55ff0d4e809e8f2634809fb2e 100644 (file)
@@ -99,4 +99,6 @@ char *Curl_dyn_take(struct dynbuf *s, size_t *plen);
 #define DYN_MQTT_RECV       (64*1024)
 #define DYN_MQTT_SEND       0xFFFFFFF
 #define DYN_CRLFILE_SIZE    (400*1024*1024) /* 400mb */
+#define DYN_CERTFILE_SIZE   (100*1024) /* 100KiB */
+#define DYN_KEYFILE_SIZE    (100*1024) /* 100KiB */
 #endif
index 0f07e8e215a420e51689189f11954adf661bd6c9..0087d5cbf79983eb6c3c9926ec887e782e0a826e 100644 (file)
@@ -868,8 +868,8 @@ init_config_builder_client_auth(struct Curl_easy *data,
     return CURLE_SSL_CERTPROBLEM;
   }
 
-  Curl_dyn_init(&cert_contents, SIZE_MAX);
-  Curl_dyn_init(&key_contents, SIZE_MAX);
+  Curl_dyn_init(&cert_contents, DYN_CERTFILE_SIZE);
+  Curl_dyn_init(&key_contents, DYN_KEYFILE_SIZE);
 
   if(!read_file_into(conn_config->clientcert, &cert_contents)) {
     failf(data, "rustls: failed to read client certificate file: '%s'",