SSL_CTX_ADD1_CHAIN_CERT(3)
π SSL_CTX_ADD1_CHAIN_CERT(3) π
okay so bestie, this page is from the Library Functions Manual and it's literally called SSL_CTX_ADD1_CHAIN_CERT(3). it's giving extra chain certificate processing and honestly it's more fun than it sounds. π
β¨ NAME β¨
SSL_CTX_set0_chain, SSL_CTX_set1_chain, SSL_CTX_add0_chain_cert, SSL_CTX_add1_chain_cert, SSL_CTX_get0_chain_certs, SSL_CTX_clear_chain_certs, SSL_set0_chain, SSL_set1_chain, SSL_add0_chain_cert, SSL_add1_chain_cert, SSL_get0_chain_certs, SSL_clear_chain_certs β extra chain certificate processing
π» SYNOPSIS π»
library βlibsslβ libcrypto #include <openssl/ssl.h>
int
SSL_CTX_set0_chain(SSL_CTX *ctx, STACK_OF(X509) *chain);
int
SSL_CTX_set1_chain(SSL_CTX *ctx, STACK_OF(X509) *chain);
int
SSL_CTX_add0_chain_cert(SSL_CTX *ctx, X509 *cert);
int
SSL_CTX_add1_chain_cert(SSL_CTX *ctx, X509 *cert);
int
SSL_CTX_get0_chain_certs(SSL_CTX *ctx, STACK_OF(X509) **chain);
int
SSL_CTX_clear_chain_certs(SSL_CTX *ctx);
int
SSL_set0_chain(SSL *ssl, STACK_OF(X509) *chain);
int
SSL_set1_chain(SSL *ssl, STACK_OF(X509) *chain);
int
SSL_add0_chain_cert(SSL *ssl, X509 *cert);
int
SSL_add1_chain_cert(SSL *ssl, X509 *cert);
int
SSL_get0_chain_certs(SSL *ssl, STACK_OF(X509) **chain);
int
SSL_clear_chain_certs(SSL *ssl);
πΈ DESCRIPTION πΈ
Okay so picture this: you've got a certificate chain, and these functions are here to manage the extra chain certs. Let's break it down, bestie.
SSL_CTX_set0_chain()andSSL_CTX_set1_chain()set the certificate chain associated with the current certificate ofctxtochain. The chain is not supposed to include the current certificate itself. no cap.SSL_CTX_add0_chain_cert()andSSL_CTX_add1_chain_cert()append the single certificatecertto the chain associated with the current certificate ofctx. just one cert at a time, okay?SSL_CTX_get0_chain_certs()retrieves the chain associated with the current certificate ofctx. get it? got it? good.SSL_CTX_clear_chain_certs()clears the existing chain associated with the current certificate ofctx, if any. this is equivalent to callingSSL_CTX_set0_chain()withchainset toNULL. bye-bye chain π
Each of these functions operates on the current end entity (i.e. server or client) certificate. This is the last certificate loaded or selected on the corresponding ctx structure, for example using SSL_CTX_use_certificate(3).
SSL_set0_chain(), SSL_set1_chain(), SSL_add0_chain_cert(), SSL_add1_chain_cert(), SSL_get0_chain_certs(), and SSL_clear_chain_certs() are similar except that they operate on the ssl connection. same energy, different object. π
Now the 1 vs 0 of it all β this is important:
- The functions containing a
1in their name increment the reference count of the supplied certificate or chain, so it must be freed at some point after the operation. you don't own it forever, bestie. - Those containing a
0do not increment reference counts and the supplied certificate or chain must not be freed after the operation. like, don't touch it. periodt.
The chains associated with an SSL_CTX structure are copied to the new SSL structure when SSL_new(3) is called. Existing SSL structures are not affected by any chains subsequently changed in the parent SSL_CTX. so if you change the parent later, the babies already born don't care. π
One chain can be set for each key type supported by a server. So, for example, an RSA and an ECDSA certificate can have different chains. iconic, honestly. π₯
If any certificates are added using these functions, no certificates added using SSL_CTX_add_extra_chain_cert(3) will be used. that's the rule. no mixing. π
π RETURN VALUES π
These functions return 1 for success or 0 for failure. that's it. that's the whole vibe check. π
π¦ SEE ALSO π¦
π HISTORY π
These functions first appeared in OpenSSL 1.0.2 and have been available since OpenBSD 6.5. so they're not new new, but they're iconic. π
π and that's the whole page, bestie! this beauty came from Debian, dated June 8, 2025, and the page is literally SSL_CTX_ADD1_CHAIN_CERT(3). slay. π
π¦ where this page comes from
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2013 The OpenSSL Project. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms