SSL_CTX_ADD_EXTRA_CHAIN_CERT(3SSL)
π NAME π
okay so bestie, gather round, because today we're talking about the girlies that handle extra chain certificates: SSL_CTX_add_extra_chain_cert, SSL_CTX_get_extra_chain_certs, SSL_CTX_get_extra_chain_certs_only, and SSL_CTX_clear_extra_chain_certs. Their whole thing? add, get, or clear those extra chain certs. that's it, that's the job, and they ate π
this is all part of the OpenSSL 3SSL manual, so you already know it's iconic.
β¨ SYNOPSIS β¨
like, here's the actual shape of it, no notes:
#include <openssl/ssl.h>
long SSL_CTX_add_extra_chain_cert(SSL_CTX *ctx, X509 *x509);
long SSL_CTX_get_extra_chain_certs(SSL_CTX *ctx, STACK_OF(X509) **sk);
long SSL_CTX_get_extra_chain_certs_only(SSL_CTX *ctx, STACK_OF(X509) **sk);
long SSL_CTX_clear_extra_chain_certs(SSL_CTX *ctx);
πΈ DESCRIPTION πΈ
okay so like, one by one, here's the tea:
SSL_CTX_add_extra_chain_cert()β this one adds the certificatex509to the extra chain certificates that are associated withctx. and the vibe? you can add several certificates, one after another. stack 'em up bestie π«ΆSSL_CTX_get_extra_chain_certs()β this one retrieves the extra chain certificates associated withctx. but plot twist: if the extra chain is empty, it hands you the chain associated with the current certificate ofctxinstead. and important β the returned stack should not be freed by the caller. do not touch, do not free, it's not yours πSSL_CTX_get_extra_chain_certs_only()β this one retrieves just the extra chain certificates associated withctx. no fallback, no surprises. and same rule, bestie: the returned stack should not be freed by the caller.SSL_CTX_clear_extra_chain_certs()β and this one? it clears all the extra chain certificates associated withctx. clean slate, fresh start, slay β¨
oh and also, lowkey important: all of these functions are implemented as macros.
π¦ NOTES π¦
when you're sending a certificate chain, the extra chain certificates get sent in order, following the end entity certificate. so like, order matters, don't be chaotic about it.
if no chain is specified, the library will try to complete the chain from the available CA certificates in the trusted CA storage β check out SSL_CTX_load_verify_locations(3) for that one.
β οΈ okay this part is so important: thex509certificate you hand toSSL_CTX_add_extra_chain_cert()will be freed by the library when theSSL_CTXis destroyed. so an application should not free thex509object. not you. not ever. the library has custody, periodt π
π RESTRICTIONS π
and now the fine print, because there is always fine print:
only one set of extra chain certificates can be specified per SSL_CTX structure. so like, different chains for different certificates β for example, if both RSA and DSA certificates are specified by the same server β or different SSL structures with the same parent SSL_CTX? yeah, none of that can be specified using this function. it's giving limited range π
for more flexibility, functions such as SSL_add1_chain_cert() should be used instead.
π RETURN VALUES π
SSL_CTX_add_extra_chain_cert()andSSL_CTX_clear_extra_chain_certs()return1on success and0for failure.
and if you get a failure? check out the error stack to find out the reason. the error stack will tell you what went wrong, bestie, it's the group chat receipts π₯
β SEE ALSO β
go read these next, iykyk:
ssl(7)SSL_CTX_use_certificate(3)SSL_CTX_set_client_cert_cb(3)SSL_CTX_load_verify_locations(3)SSL_CTX_set0_chain(3)SSL_CTX_set1_chain(3)SSL_CTX_add0_chain_cert(3)SSL_CTX_add1_chain_cert(3)SSL_set0_chain(3)SSL_set1_chain(3)SSL_add0_chain_cert(3)SSL_add1_chain_cert(3)SSL_CTX_build_cert_chain(3)SSL_build_cert_chain(3)
π COPYRIGHT π
Copyright 2000-2018 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>.
and that's the whole page bestie, no cap π this was OpenSSL 4.0.3, dated 2026-09-29, the SSL_CTX_ADD_EXTRA_CHAIN_CERT(3SSL) page β go forth and manage your chains responsibly, mwah πβ¨
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms