SSL_CTX_SET1...Y_CERT_STORE(3ossl)

πŸ“¦ version 3.5.0, in opensuse-leap 16.0

πŸ’– 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() and SSL_CTX_set1_verify_cert_store() β€” they set the certificate store used for certificate verification to st. πŸ¦‹
  • SSL_CTX_set0_chain_cert_store() and SSL_CTX_set1_chain_cert_store() β€” they set the certificate store used for certificate chain building to st. 🧚
  • SSL_set0_verify_cert_store(), SSL_set1_verify_cert_store(), SSL_set0_chain_cert_store() and SSL_set1_chain_cert_store() β€” same energy, except they apply to the SSL structure ssl. lowkey identical but scoped differently 🫢
  • SSL_CTX_get0_verify_chain_store(), SSL_get0_verify_chain_store(), SSL_CTX_get0_chain_cert_store() and SSL_get0_chain_cert_store() β€” these ones retrieve the objects you previously set via the calls above. a pointer to the object (or NULL if 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_CTX structure are copied to any SSL structures when SSL_new() is called. so as a result, SSL structures will not be affected if the parent SSL_CTX store 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" in openssl-verification-options(1). (yes, same page, twice, it's fine, go read it πŸ“–)
  • if the mode SSL_MODE_NO_AUTO_CHAIN is set or a certificate chain is configured already (for example using the functions such as SSL_CTX_add1_chain_cert(3) or SSL_CTX_add_extra_chain_cert(3)) then automatic chain building is disabled. βœ‹
  • if the mode SSL_MODE_NO_AUTO_CHAIN is 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_CTX is 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:


⭐ HISTORY ⭐

these functions were added in OpenSSL 1.0.2. vintage. still ate. πŸ™ˆ


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