SSL_CTX_SET_MAX_CERT_LIST(3ossl)

πŸ“¦
version 15.1 Β· 3 versions
, in freebsd 15.1

πŸ’… SSL_CTX_SET_MAX_CERT_LIST(3ossl) β€” aka "how big is ur peer's cert chain allowed to be, bestie"

okay so listen 🫢 this page lives in the 3ossl manual section, and it's about the four little functions that put a cap on how much certificate-chain the peer is allowed to throw at you. Think of it as a bouncer at the club door: chain too long, you're not coming in ✨


✨ SYNOPSIS ✨

#include <openssl/ssl.h>

long SSL_CTX_set_max_cert_list(SSL_CTX *ctx, long size);
long SSL_CTX_get_max_cert_list(SSL_CTX *ctx);

long SSL_set_max_cert_list(SSL *ssl, long size);
long SSL_get_max_cert_list(SSL *ctx);

(yes the last param is literally named ctx even though it's an SSL * β€” not me, not my problem, copying it exactly πŸ’€)


πŸŽ€ DESCRIPTION πŸŽ€

Four functions, two setters, two getters, one whole vibe.

  • SSL_CTX_set_max_cert_list() β€” sets the max size allowed for the peer's certificate chain, for all SSL objects created from ctx, to be size bytes. Important detail bestie: the SSL objects inherit whatever setting ctx had at the moment SSL_new(3) got called. So it's a snapshot-at-birth situation πŸ‘‘
  • SSL_CTX_get_max_cert_list() β€” just tells you the maximum size currently set on ctx. nosy but harmless πŸ’…
  • SSL_set_max_cert_list() β€” sets the max size allowed for the peer's certificate chain for ssl to be size bytes. And this one stays valid until a new value is set β€” it doesn't evaporate, it commits πŸ”₯
  • SSL_get_max_cert_list() β€” returns the currently set maximum size for ssl. that's it. that's the whole function 🫢

πŸ¦‹ NOTES πŸ¦‹

So during the handshake, the peer can send a certificate chain. And here's the thing β€” the TLS/SSL standard does not give any maximum size for that chain. None. Zero cap. Wild, right? 😭

OpenSSL handles incoming data with a dynamically allocated buffer. But bestie, you cannot just let a buffer grow forever because a faulty or malicious peer is feeling chaotic β€” so a maximum size for the certificate chain gets set. Protection era πŸ’–

The default value for the maximum certificate chain size is 100kB (30kB on the 16-bit DOS platform, cute little retro moment 🌸). And honestly that should be plenty for normal certificate chains: OpenSSL's default maximum chain length is 10 (peep SSL_CTX_set_verify(3)), and certificates without special extensions are typically 1-2kB each. math is mathing ✨

For special applications it might be necessary to extend the maximum certificate chain size you'll allow the peer to send β€” see for example the work on "Internet X.509 Public Key Infrastructure Proxy Certificate Profile" and "TLS Delegation Protocol" at http://www.ietf.org/ and http://www.globus.org/ πŸ‘€

Under normal conditions it should never be necessary to set a value smaller than the default β€” the buffer is handled dynamically and only uses the memory actually required by the data the peer sent. So like, don't shrink it for funsies, ok? πŸ™ˆ

And if the maximum certificate chain size allowed is exceeded? Handshake fails, hard, with an SSL_R_EXCESSIVE_MESSAGE_SIZE error. blocked. denied. removed from the premises πŸ’€


🌈 RETURN VALUES 🌈

  • SSL_CTX_set_max_cert_list() and SSL_set_max_cert_list() β€” return the previously set value (not the new one, don't get it twisted πŸ‘‘)
  • SSL_CTX_get_max_cert_list() and SSL_get_max_cert_list() β€” return the currently set value ⭐

πŸ’œ SEE ALSO πŸ’œ


Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.


k that's the whole page, go forth and cap ur cert chains responsibly πŸ§šπŸ’–

version 3.5.6 Β· dated 2026-04-07 Β· manual SSL_CTX_SET_MAX_CERT_LIST(3ossl) β€” mwah, see u next manpage bestie πŸ’…πŸŽ€

πŸ“¦ where this page comes from