SSL_CTX_SET_CERT_STORE(3ossl)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’… 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 of ctx to/with store. If another X509_STORE object is currently set in ctx, it will be X509_STORE_free()ed. and okay this is the big one: SSL_CTX_set_cert_store() will take ownership of the store, i.e., the call X509_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 of ctx to/with store, but this one increments the store's reference count first. If another X509_STORE object is currently set in ctx, it will be X509_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. ctx MUST NOT be NULL. no cap, do not pass NULL, 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 an X509_STORE that is owned by another SSL_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 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