SSL_CTX_ADD_EXTRA_CHAIN_CERT(3ossl)
π SSL_CTX_ADD_EXTRA_CHAIN_CERT π
okay bestie, welcome to the 3ossl manual page, and no this is not the SSL one you're thinking of, this is the extra-chain-cert one, and it's lowkey iconic. sit down, hydrate, let's go π«Ά
β¨ NAME β¨
SSL_CTX_add_extra_chain_cert, SSL_CTX_get_extra_chain_certs, SSL_CTX_get_extra_chain_certs_only, SSL_CTX_clear_extra_chain_certs β add, get or clear extra chain certificates π
πΈ SYNOPSIS πΈ
#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);
look at those four little lines. so tidy. so slay. π
π¦ DESCRIPTION π¦
SSL_CTX_add_extra_chain_cert()β adds the certificatex509to the extra chain certificates associated withctx. and the bestie part? you can add several certificates, one after another, like stacking bracelets. obsessed. β¨SSL_CTX_get_extra_chain_certs()β retrieves the extra chain certificates associated withctx, OR, if the extra chain is empty, the chain associated with the current certificate ofctx. and here's the tea: the returned stack should not be freed by the caller. don't do it. it's not yours. πSSL_CTX_get_extra_chain_certs_only()β retrieves the extra chain certificates associated withctx. just the extras, no substitutions, no surprises. and again: the returned stack should not be freed by the caller. periodt.SSL_CTX_clear_extra_chain_certs()β clears ALL extra chain certificates associated withctx. total reset. main character wipe-the-whiteboard energy. π
and the plot twist: these functions are implemented as macros. not real functions. macros. iykyk. π§
π NOTES π
when you're sending a certificate chain, the extra chain certificates go out in order following the end entity certificate. that's the lineup, respect the lineup. π
if no chain is specified, the library will try to complete the chain from the available CA certificates in the trusted CA storage β go check SSL_CTX_load_verify_locations(3). β¨
and the big one, the one you cannot skip: the x509 certificate you hand to SSL_CTX_add_extra_chain_cert() will be freed by the library when the SSL_CTX is destroyed. so an application should not free the x509 object. do not double free. i am literally begging. π
π RESTRICTIONS π
okay so. only one set of extra chain certificates can be specified per SSL_CTX structure. one. single. set.
which means different chains for different certificates β for example if both RSA and DSA certificates are specified by the same server β cannot be specified using this function. and neither can different SSL structures with the same parent SSL_CTX. nope. not happening here. π
want more flexibility? use functions such as SSL_add1_chain_cert() instead. that's your upgrade path, bestie. π¦
β RETURN VALUES β
SSL_CTX_add_extra_chain_cert() and SSL_CTX_clear_extra_chain_certs() return 1 on success and 0 for failure. π
and if you get a 0? check out the error stack to find out the reason for failure. don't just sit there guessing, the answer is right there. π
π₯ SEE ALSO π₯
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)
the whole friend group fr fr. go say hi. π«Ά
π 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>. πΈ
okay that's the whole page, you ate it, no crumbs left. this was OpenSSL 3.5.9, dated 2026-09-2, signing off β go build a chain, bestie, and remember: don't free that stack. π β¨π
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms