X509_STORE_S...ERIFY_CB_FUNC(3ossl)
π NAME π
ok so this whole page is about setting the verification callback for an X509_STORE, bestie. Here's every single one of the little guys living on this page (yes, all of them, we do NOT skip π
):
X509_STORE_set_lookup_crls_cb,X509_STORE_set_verify_funcX509_STORE_get_cleanup,X509_STORE_set_cleanupX509_STORE_get_lookup_crls,X509_STORE_set_lookup_crlsX509_STORE_get_lookup_certs,X509_STORE_set_lookup_certsX509_STORE_get_check_policy,X509_STORE_set_check_policyX509_STORE_get_cert_crl,X509_STORE_set_cert_crlX509_STORE_get_check_crl,X509_STORE_set_check_crlX509_STORE_get_get_crl,X509_STORE_set_get_crlX509_STORE_get_check_revocation,X509_STORE_set_check_revocationX509_STORE_get_check_issued,X509_STORE_set_check_issuedX509_STORE_CTX_get1_issuer,X509_STORE_get_get_issuer,X509_STORE_set_get_issuerX509_STORE_CTX_get_verify,X509_STORE_set_verifyX509_STORE_get_verify_cb,X509_STORE_set_verify_cb_func,X509_STORE_set_verify_cbX509_STORE_CTX_cert_crl_fn,X509_STORE_CTX_check_crl_fn,X509_STORE_CTX_check_issued_fn,X509_STORE_CTX_check_policy_fn,X509_STORE_CTX_check_revocation_fn,X509_STORE_CTX_cleanup_fn,X509_STORE_CTX_get_crl_fn,X509_STORE_CTX_get_issuer_fn,X509_STORE_CTX_lookup_certs_fn,X509_STORE_CTX_lookup_crls_fn
...and what they do is set verification callback. That's the whole vibe. β¨
This page lives in the 3ossl manual, iykyk π«Ά
β¨ SYNOPSIS β¨
#include <openssl/x509_vfy.h>
typedef int (*X509_STORE_CTX_get_issuer_fn)(X509 **issuer,
X509_STORE_CTX *ctx, X509 *x);
typedef int (*X509_STORE_CTX_check_issued_fn)(X509_STORE_CTX *ctx,
X509 *x, X509 *issuer);
typedef int (*X509_STORE_CTX_check_revocation_fn)(X509_STORE_CTX *ctx);
typedef int (*X509_STORE_CTX_get_crl_fn)(X509_STORE_CTX *ctx,
X509_CRL **crl, X509 *x);
typedef int (*X509_STORE_CTX_check_crl_fn)(X509_STORE_CTX *ctx, X509_CRL *crl);
typedef int (*X509_STORE_CTX_cert_crl_fn)(X509_STORE_CTX *ctx,
X509_CRL *crl, X509 *x);
typedef int (*X509_STORE_CTX_check_policy_fn)(X509_STORE_CTX *ctx);
typedef STACK_OF(X509) *(*X509_STORE_CTX_lookup_certs_fn)(X509_STORE_CTX *ctx,
const X509_NAME *nm);
typedef STACK_OF(X509_CRL) *(*X509_STORE_CTX_lookup_crls_fn)(const
X509_STORE_CTX *ctx,
const X509_NAME *nm);
typedef int (*X509_STORE_CTX_cleanup_fn)(X509_STORE_CTX *ctx);
void X509_STORE_set_verify_cb(X509_STORE *xs,
X509_STORE_CTX_verify_cb verify_cb);
X509_STORE_CTX_verify_cb X509_STORE_get_verify_cb(const X509_STORE_CTX *ctx);
void X509_STORE_set_verify(X509_STORE *xs, X509_STORE_CTX_verify_fn verify);
X509_STORE_CTX_verify_fn X509_STORE_CTX_get_verify(const X509_STORE_CTX *ctx);
int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x);
X509_STORE_CTX_get_issuer_fn X509_STORE_get_get_issuer(const X509_STORE_CTX *ctx);
void X509_STORE_set_get_issuer(X509_STORE *xs,
X509_STORE_CTX_get_issuer_fn get_issuer);
void X509_STORE_set_check_issued(X509_STORE *xs,
X509_STORE_CTX_check_issued_fn check_issued);
X509_STORE_CTX_check_issued_fn
X509_STORE_get_check_issued(const X509_STORE_CTX *ctx);
void X509_STORE_set_check_revocation(X509_STORE *xs,
X509_STORE_CTX_check_revocation_fn check_revocation);
X509_STORE_CTX_check_revocation_fn
X509_STORE_get_check_revocation(const X509_STORE_CTX *ctx);
void X509_STORE_set_get_crl(X509_STORE *xs,
X509_STORE_CTX_get_crl_fn get_crl);
X509_STORE_CTX_get_crl_fn X509_STORE_get_get_crl(const X509_STORE_CTX *ctx);
void X509_STORE_set_check_crl(X509_STORE *xs,
X509_STORE_CTX_check_crl_fn check_crl);
X509_STORE_CTX_check_crl_fn
X509_STORE_get_check_crl(const X509_STORE_CTX *ctx);
void X509_STORE_set_cert_crl(X509_STORE *xs,
X509_STORE_CTX_cert_crl_fn cert_crl);
X509_STORE_CTX_cert_crl_fn X509_STORE_get_cert_crl(const X509_STORE_CTX *ctx);
void X509_STORE_set_check_policy(X509_STORE *xs,
X509_STORE_CTX_check_policy_fn check_policy);
X509_STORE_CTX_check_policy_fn
X509_STORE_get_check_policy(const X509_STORE_CTX *ctx);
void X509_STORE_set_lookup_certs(X509_STORE *xs,
X509_STORE_CTX_lookup_certs_fn lookup_certs);
X509_STORE_CTX_lookup_certs_fn
X509_STORE_get_lookup_certs(const X509_STORE_CTX *ctx);
void X509_STORE_set_lookup_crls(X509_STORE *xs,
X509_STORE_CTX_lookup_crls_fn lookup_crls);
X509_STORE_CTX_lookup_crls_fn
X509_STORE_get_lookup_crls(const X509_STORE_CTX *ctx);
void X509_STORE_set_cleanup(X509_STORE *xs,
X509_STORE_CTX_cleanup_fn cleanup);
X509_STORE_CTX_cleanup_fn X509_STORE_get_cleanup(const X509_STORE_CTX *ctx);
/* Aliases */
void X509_STORE_set_verify_cb_func(X509_STORE *st,
X509_STORE_CTX_verify_cb verify_cb);
void X509_STORE_set_verify_func(X509_STORE *xs,
X509_STORE_CTX_verify_fn verify);
void X509_STORE_set_lookup_crls_cb(X509_STORE *xs,
X509_STORE_CTX_lookup_crls_fn lookup_crls);
π¦ DESCRIPTION π¦
okok let's go one by one, bestie, because there's a LOT here and every single one matters π₯
X509_STORE_set_verify_cb() sets the verification callback of xs to verify_cb, and yeah it straight-up overwrites whatever callback was there before, no warning, no takebacks π. The callback you assign with this function becomes a default for the one that can be assigned directly to the corresponding X509_STORE_CTX β so like, it's the vibes the ctx inherits, not the final say. Peep X509_STORE_CTX_set_verify_cb(3) for the tea. π«
X509_STORE_set_verify() sets the final chain verification function for xs to verify. Its whole job? Go through the chain of certificates and check that all signatures are valid, and that the current time is inside the limits of each certificate's first and last validity time β°. The final chain verification functions must return 0 on failure and 1 on success. If you don't hand over a chain verification function, the internal default function gets used instead β she's the main character when nobody else shows up π.
X509_STORE_CTX_get1_issuer() tries to find a certificate from the store component of ctx whose subject name matches the issuer name of x, and that is accepted by the check_issued function in ctx. On success it assigns to *issuer the first match that has a suitable validity period β or otherwise the one with the latest expiration date out of all the matching certificates ποΈ. If the function returns 1, the caller is responsible for freeing *issuer (yes, you, bestie, that's your chore π§Ή). And heads up: this search does NOT support backtracking. Fr fr, no going back.
X509_STORE_set_get_issuer() sets the function get_issuer, which is used to get the "best" candidate issuer certificate of the given certificate x. When such a certificate is found, get_issuer must up-ref and assign it to *issuer, then return 1. Otherwise get_issuer must return 0 if not found, and -1 (or 0) on failure. If X509_STORE_set_get_issuer() isn't used, or if get_issuer is NULL, then X509_STORE_CTX_get1_issuer() is used as the default implementation β¨.
X509_STORE_set_check_issued() sets the function that checks a given certificate x is issued by the issuer certificate issuer. This function must return 0 on failure β among other things, if x hasn't been issued with issuer β and 1 on success β
. If no function to get the issuer is provided, the internal default function will be used instead.
X509_STORE_set_check_revocation() sets the revocation checking function. Its purpose is to look through the final chain and check the revocation status for each certificate π. It must return 0 on failure and 1 on success. If no function to get the issuer is provided, the internal default function will be used instead.
X509_STORE_set_get_crl() sets the function to get the CRL for a given certificate x. When found, the CRL must be assigned to *crl. This function must return 0 on failure and 1 on success. If no function to get the issuer is provided, the internal default function will be used instead.
X509_STORE_set_check_crl() sets the function to check the validity of the given crl. This function must return 0 on failure and 1 on success. If no function to get the issuer is provided, the internal default function will be used instead.
X509_STORE_set_cert_crl() sets the function to check the revocation status of the given certificate x against the given crl. This function must return 0 on failure and 1 on success. If no function to get the issuer is provided, the internal default function will be used instead.
X509_STORE_set_check_policy() sets the function to check the policies of all the certificates in the final chain. This function must return 0 on failure and 1 on success. If no function to get the issuer is provided, the internal default function will be used instead.
X509_STORE_set_lookup_certs() and X509_STORE_set_lookup_crls() set the functions to look up all the certs or all the CRLs that match the given name nm πΈ. These functions return NULL on failure, and a pointer to a stack of certificates (X509) or to a stack of CRLs (X509_CRL) on success. If no function to get the issuer is provided, the internal default function will be used instead.
X509_STORE_set_cleanup() sets the final cleanup function, which is called when the context (X509_STORE_CTX) is being torn down π§Ό. This function doesn't return any value. If no function to get the issuer is provided, the internal default function will be used instead.
X509_STORE_get_verify_cb(), X509_STORE_CTX_get_verify(), X509_STORE_get_get_issuer(), X509_STORE_get_check_issued(), X509_STORE_get_check_revocation(), X509_STORE_get_get_crl(), X509_STORE_get_check_crl(), X509_STORE_set_verify(), X509_STORE_set_get_issuer(), X509_STORE_get_cert_crl(), X509_STORE_get_check_policy(), X509_STORE_get_lookup_certs(), X509_STORE_get_lookup_crls() and X509_STORE_get_cleanup() all return the function pointer assigned with X509_STORE_set_check_issued(), X509_STORE_set_check_revocation(), X509_STORE_set_get_crl(), X509_STORE_set_check_crl(), X509_STORE_set_cert_crl(), X509_STORE_set_check_policy(), X509_STORE_set_lookup_certs(), X509_STORE_set_lookup_crls() and X509_STORE_set_cleanup(), or NULL if no assignment has been made. (So like, no assignment = NULL, she's not gonna make something up for you π.)
X509_STORE_set_verify_cb_func(), X509_STORE_set_verify_func() and X509_STORE_set_lookup_crls_cb() are aliases for X509_STORE_set_verify_cb(), X509_STORE_set_verify() and X509_STORE_set_lookup_crls, available as macros for backward compatibility π«Ά.
π NOTES π
All the callbacks from an X509_STORE are inherited by the corresponding X509_STORE_CTX structure when it is initialized π. See X509_STORE_CTX_set_verify_cb(3) for further details.
bestie this page is long so it comes in two parts, and you're reading part 1 rn β more is coming, don't go anywhere π
π BUGS π
okay so historically? the macro version of this function was the only one available before OpenSSL 1.0.0. that's it, that's the whole bug report bestie π like, imagine only having the macro. we don't talk about the pre-1.0.0 era. π
π RETURN VALUES π
okay so here's the vibe check on what you actually get back:
- the
X509_STORE_set_*()functions β do not return a value. nothing. nada. they just do the thing and dip. no receipts. π«Ά - the
X509_STORE_get_*()functions β these ones return a pointer of the appropriate function type. you get your lil function pointer back, slay. β¨ X509_STORE_CTX_get1_issuer()β this one's a lil more chatty:- returns 1 if a suitable certificate is found π
- returns 0 if not found π
- returns -1 on other error π
π SEE ALSO π
go read these next, they're all part of the same friend group fr fr:
X509_STORE_CTX_set_verify_cb(3)X509_STORE_CTX_get0_chain(3)X509_STORE_CTX_verify_cb(3)X509_STORE_CTX_verify_fn(3)CMS_verify(3)
π HISTORY π
storytime, bestie, because the lore here is real:
X509_STORE_set_verify_cb()was added in OpenSSL 1.0.0. iconic behavior, honestly.- then a whole squad showed up in OpenSSL 1.1.0 β and no, i'm not skipping a single one of them, periodt:
X509_STORE_set_verify_cb()X509_STORE_get_verify_cb()X509_STORE_set_verify()X509_STORE_CTX_get_verify()X509_STORE_set_get_issuer()X509_STORE_get_get_issuer()X509_STORE_set_check_issued()X509_STORE_get_check_issued()X509_STORE_set_check_revocation()X509_STORE_get_check_revocation()X509_STORE_set_get_crl()X509_STORE_get_get_crl()X509_STORE_set_check_crl()X509_STORE_get_check_crl()X509_STORE_set_cert_crl()X509_STORE_get_cert_crl()X509_STORE_set_check_policy()X509_STORE_get_check_policy()X509_STORE_set_lookup_certs()X509_STORE_get_lookup_certs()X509_STORE_set_lookup_crls()X509_STORE_get_lookup_crls()X509_STORE_set_cleanup()X509_STORE_get_cleanup()
all twenty-four of them, bestie, added together in 1.1.0. the way that's an entire graduating class πβ¨
βοΈ COPYRIGHT βοΈ
Copyright 2009-2021 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>.
π yes bestie, read the license. it's giving legally binding. no cap.
okay that's a wrap on this whole page!! π this was version 3.5.9, dated 2026-09-2X, and the page itself is X509_STORE_S...ERIFY_CB_FUNC(3ossl). go forth and verify those certs, you absolute legend ππ¦β¨
π¦ 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