SSL_CTX_SET_CERT_STORE(3ossl)
π SSL_CTX_SET_CERT_STORE π
okay bestie, welcome to the OpenSSL section 3ossl glow-up of SSL_CTX_SET_CERT_STORE(3ossl) β it's the page about messing with your X509 certificate verification storage. yes, the name is a whole mouthful, we don't make the rules. let's get into it π
β¨ NAME β¨
SSL_CTX_set_cert_store, SSL_CTX_set1_cert_store, SSL_CTX_get_cert_store β the girlies that manipulate X509 certificate verification storage π¦
πΈ SYNOPSIS πΈ
#include <openssl/ssl.h>
void SSL_CTX_set_cert_store(SSL_CTX *ctx, X509_STORE *store);
void SSL_CTX_set1_cert_store(SSL_CTX *ctx, X509_STORE *store);
X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *ctx);
π DESCRIPTION π
SSL_CTX_set_cert_store() sets or replaces the certificate verification storage of ctx to/with store. If there's already another X509_STORE object chillin' in ctx, it gets X509_STORE_free()ed, no hesitation, it's giving eviction notice. and like β heads up β SSL_CTX_set_cert_store() takes ownership of the store, which means the call X509_STORE_free(store) is no longer needed. it's hers now. periodt.
SSL_CTX_set1_cert_store() also sets or replaces the certificate verification storage of ctx to/with store, but this one is respectful: the store's reference count gets incremented π₯. And if another X509_STORE object is currently set in ctx, that one still gets X509_STORE_free()ed. so it's polite about the new one, ruthless about the old one. main character energy honestly.
SSL_CTX_get_cert_store() returns a pointer to the current certificate verification storage. oh and ctx MUST NOT be NULL β like, that's non-negotiable, bestie, don't do it π
π§ NOTES π§
so to verify the certificates the peer is serving you, trusted CA certificates have to be accessed. those CA certificates are made available via lookup methods, handled inside the X509_STORE. and from the X509_STORE, the X509_STORE_CTX that gets used when verifying certificates is created. it's a whole pipeline π
typically the trusted certificate store is handled indirectly by using SSL_CTX_load_verify_locations(3). but with the SSL_CTX_set_cert_store() and SSL_CTX_get_cert_store() functions, you can manipulate the X509_STORE object beyond the SSL_CTX_load_verify_locations(3) call. slay.
ngl, currently there's no detailed documentation on how to use theX509_STOREobject. and not all members of theX509_STOREare used when the verification takes place. so for example, theverify_callback()will be overridden with theverify_callback()set via theSSL_CTX_set_verify(3)family of functions. so this document must therefore be updated when documentation about theX509_STOREobject and its handling becomes available. we're waiting π
SSL_CTX_set_cert_store() does not increment the store's reference count, so it should not be used to assign an X509_STORE that is owned by another SSL_CTX. like, that's someone else's man, don't.
to share X509_STOREs between two SSL_CTXs, use SSL_CTX_get_cert_store() to get the X509_STORE from the first SSL_CTX, and then use SSL_CTX_set1_cert_store() to assign to the second SSL_CTX and increment the reference count of the X509_STORE. that's the correct way, iykyk π«Ά
π RESTRICTIONS π
the X509_STORE structure used by an SSL_CTX is used for verifying peer certificates and building certificate chains, and it's also shared by every child SSL structure. so it's a communal situation. applications wanting finer control can use functions such as SSL_CTX_set1_verify_cert_store() instead. β¨
β RETURN VALUES β
SSL_CTX_set_cert_store() does not return diagnostic output.
SSL_CTX_set1_cert_store() does not return diagnostic output.
SSL_CTX_get_cert_store() returns the current setting.
π SEE ALSO π
π COPYRIGHT π
Copyright 2001-2024 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 π this was 3.5.9, dated 2026-09-29, straight from the OpenSSL girlies themselves β SSL_CTX_SET_CERT_STORE(3ossl), out πβ¨
π¦ 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