SSL_CTX_SET_CERT_STORE(3ossl)
π SSL_CTX_SET_CERT_STORE π
okay so this is the OpenSSL manual page SSL_CTX_SET_CERT_STORE(3ossl) and bestie, it's literally all about manipulating X509 certificate verification storage. iconique. let's get into it π«Ά
β¨ NAME β¨
SSL_CTX_set_cert_store, SSL_CTX_set1_cert_store, SSL_CTX_get_cert_store β 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);
like, look at her. three functions. all baddies. πΈ
π¦ DESCRIPTION π¦
SSL_CTX_set_cert_store()β sets/replaces the certificate verification storage ofctxto/withstore. If anotherX509_STOREobject is currently set inctx, it will beX509_STORE_free()ed. and okay this is the big one:SSL_CTX_set_cert_store()will take ownership of thestore, i.e., the callX509_STORE_free(store)is no longer needed. so like, don't double-free her, that's not the vibe πSSL_CTX_set1_cert_store()β also sets/replaces the certificate verification storage ofctxto/withstore, but this one increments the store's reference count first. If anotherX509_STOREobject is currently set inctx, it will beX509_STORE_free()ed. basically the "no take-backs, we share" version πSSL_CTX_get_cert_store()β returns a pointer to the current certificate verification storage.ctxMUST NOT beNULL. no cap, do not passNULL, she will not survive that π
π§ NOTES π§
so to actually verify the certificates presented by the peer, trusted CA certificates must be accessed. those CA certs are made available via lookup methods, handled inside the X509_STORE. and from the X509_STORE the X509_STORE_CTX used when verifying certificates is created. it's giving chain of custody π
typically the trusted certificate store is handled indirectly via using SSL_CTX_load_verify_locations(3). but using the SSL_CTX_set_cert_store() and SSL_CTX_get_cert_store() functions it is possible to manipulate the X509_STORE object beyond the SSL_CTX_load_verify_locations(3) call. so, like, you can go deeper. main character energy β¨
currently no detailed documentation on how to use the X509_STORE object is available. Not all members of the X509_STORE are used when the verification takes place. so will e.g. the verify_callback() be overridden with the verify_callback() set via the SSL_CTX_set_verify(3) family of functions. This document must therefore be updated when documentation about the X509_STORE object and its handling becomes available. (honestly? we're all just waiting for the docs to drop π)
β οΈ important warning bestie:SSL_CTX_set_cert_store()does not increment the store's reference count, so it should not be used to assign anX509_STOREthat is owned by anotherSSL_CTX. like, that store belongs to someone else, hands off π«Ά
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 whole recipe, periodt π
π RESTRICTIONS π
the X509_STORE structure used by an SSL_CTX is used for verifying peer certificates and building certificate chains, it is also shared by every child SSL structure. so like every child SSL is literally borrowing the same store, no duplicates, no drama.
applications wanting finer control can use functions such as SSL_CTX_set1_verify_cert_store() instead. iykyk π
β RETURN VALUES β
SSL_CTX_set_cert_store()β does not return diagnostic output. (she's a void, she says nothing, she just is)SSL_CTX_set1_cert_store()β does not return diagnostic output either. same energy πSSL_CTX_get_cert_store()β returns the current setting β¨
π₯ SEE ALSO π₯
go read those too, they're all connected fr fr π¦
π 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 page babes π β this absolute icon of a manpage is from OpenSSL 3.5.6, dated 2026-04-07, and it's filed under SSL_CTX_SET_CERT_STORE(3ossl). slay, go verify some certificates responsibly πβ¨
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms