SSL_CTX_SET1...Y_CERT_STORE(3ossl)
π NAME π
okay so bestie, this page is about the whole little family of functions that set and get the cert store used for certificate verification or chain building:
SSL_CTX_set0_verify_cert_store, SSL_CTX_set1_verify_cert_store, SSL_CTX_set0_chain_cert_store, SSL_CTX_set1_chain_cert_store, SSL_set0_verify_cert_store, SSL_set1_verify_cert_store, SSL_set0_chain_cert_store, SSL_set1_chain_cert_store, SSL_CTX_get0_verify_cert_store, SSL_CTX_get0_chain_cert_store, SSL_get0_verify_cert_store, SSL_get0_chain_cert_store β set certificate verification or chain store. that's the whole vibe π
(this is all from the OpenSSL manual, section 3ossl, iykyk β¨)
β¨ SYNOPSIS β¨
like, here's the whole cast, bestie π
#include <openssl/ssl.h>
int SSL_CTX_set0_verify_cert_store(SSL_CTX *ctx, X509_STORE *st);
int SSL_CTX_set1_verify_cert_store(SSL_CTX *ctx, X509_STORE *st);
int SSL_CTX_set0_chain_cert_store(SSL_CTX *ctx, X509_STORE *st);
int SSL_CTX_set1_chain_cert_store(SSL_CTX *ctx, X509_STORE *st);
int SSL_CTX_get0_verify_cert_store(SSL_CTX *ctx, X509_STORE **st);
int SSL_CTX_get0_chain_cert_store(SSL_CTX *ctx, X509_STORE **st);
int SSL_set0_verify_cert_store(SSL *ctx, X509_STORE *st);
int SSL_set1_verify_cert_store(SSL *ctx, X509_STORE *st);
int SSL_set0_chain_cert_store(SSL *ctx, X509_STORE *st);
int SSL_set1_chain_cert_store(SSL *ctx, X509_STORE *st);
int SSL_get0_verify_cert_store(SSL *ctx, X509_STORE **st);
int SSL_get0_chain_cert_store(SSL *ctx, X509_STORE **st);
(also yes, the SSL ones literally take a parameter named ctx β it's giving SSL *ctx, that's canonical, don't come for me π)
πΈ DESCRIPTION πΈ
so like, two flavours: verify stores and chain stores, and two scopes: SSL_CTX and SSL. iconic separation, no notes π
SSL_CTX_set0_verify_cert_store()andSSL_CTX_set1_verify_cert_store()β they set the certificate store used for certificate verification tost. π¦SSL_CTX_set0_chain_cert_store()andSSL_CTX_set1_chain_cert_store()β they set the certificate store used for certificate chain building tost. π§SSL_set0_verify_cert_store(),SSL_set1_verify_cert_store(),SSL_set0_chain_cert_store()andSSL_set1_chain_cert_store()β same energy, except they apply to theSSLstructuressl. lowkey identical but scoped differently π«ΆSSL_CTX_get0_verify_chain_store(),SSL_get0_verify_chain_store(),SSL_CTX_get0_chain_cert_store()andSSL_get0_chain_cert_store()β these ones retrieve the objects you previously set via the calls above. a pointer to the object (orNULLif no such object has been set) gets written to*st. get you a function that can do both π
β οΈ plot twist: all of these functions are implemented as macros. not kidding. so:
- ones containing a 1 increment the reference count of the supplied store, so it must be freed at some point after the operation. you will be responsible for that cleanup, bestie, sorry π
- ones containing a 0 do not increment reference counts, and the supplied store MUST NOT be freed after the operation. like, do not. periodt. π₯
π NOTES π
- the store pointers associated with an
SSL_CTXstructure are copied to anySSLstructures whenSSL_new()is called. so as a result,SSLstructures will not be affected if the parentSSL_CTXstore pointer is set to a new value. it's giving "you are your own person now" π - the verification store is used to verify the certificate chain sent by the peer: that is, an SSL/TLS client will use the verification store to verify the server's certificate chain, and an SSL/TLS server will use it to verify any client certificate chain. mutual vibes check π
- the chain store is used to build the certificate chain. the details of the chain building and checking process are described in "Certification Path Building" in
openssl-verification-options(1)and "Certification Path Validation" inopenssl-verification-options(1). (yes, same page, twice, it's fine, go read it π) - if the mode
SSL_MODE_NO_AUTO_CHAINis set or a certificate chain is configured already (for example using the functions such asSSL_CTX_add1_chain_cert(3)orSSL_CTX_add_extra_chain_cert(3)) then automatic chain building is disabled. β - if the mode
SSL_MODE_NO_AUTO_CHAINis set then automatic chain building is disabled. (yes this is literally listed again, the manpage said it twice, i don't make the rules π) - if the chain or the verification store is not set then the store associated with the parent
SSL_CTXis used instead, to retain compatibility with previous versions of OpenSSL. legacy support slay β
π RETURN VALUES π
all these functions return 1 for success and 0 for failure. binary queen, no in-between π
π¦ SEE ALSO π¦
go read these next, bestie, they're all connected:
ssl(7)SSL_CTX_add_extra_chain_cert(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)
β HISTORY β
these functions were added in OpenSSL 1.0.2. vintage. still ate. π
π COPYRIGHT π
Copyright 2013-2022 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're basically an expert now, go forth and manage those cert stores π§ββοΈβ¨
πΈ this has been OpenSSL 3.5.0, dated 2026-09-25, page SSL_CTX_SET1...Y_CERT_STORE(3ossl) β ty for coming to my ted talk, mwah π«Άπ
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms