X509_STORE_GET_VERIFY(3ssl)
π X509_STORE_CTX_SET_VERIF(3) β Library Functions Manual
okay bestie, welcome to the X509_STORE_CTX_SET_VERIF(3) page from the Library Functions Manual. This is the one about the user-defined certificate chain verification function, and the whole function squad is:
X509_STORE_CTX_verify_fnX509_STORE_CTX_set_verifyX509_STORE_CTX_get_verifyX509_STORE_set_verifyX509_STORE_set_verify_funcX509_STORE_get_verifyX509_STORE_CTX_check_issued_fnX509_STORE_set_check_issuedX509_STORE_get_check_issuedX509_STORE_CTX_get_check_issued
πΈ SYNOPSIS πΈ
Copy this exactly so your compiler doesn't side-eye you:
#include <openssl/x509_vfy.h>
typedef int
(*X509_STORE_CTX_verify_fn)(X509_STORE_CTX *ctx);
void
X509_STORE_CTX_set_verify(X509_STORE_CTX *ctx,
X509_STORE_CTX_verify_fn verify);
X509_STORE_CTX_verify_fn
X509_STORE_CTX_get_verify(X509_STORE_CTX *ctx);
void
X509_STORE_set_verify(X509_STORE *store,
X509_STORE_CTX_verify_fn verify);
void
X509_STORE_set_verify_func(X509_STORE *store,
X509_STORE_CTX_verify_fn verify);
X509_STORE_CTX_verify_fn
X509_STORE_get_verify(X509_STORE_CTX *ctx);
typedef int
(*X509_STORE_CTX_check_issued_fn)(X509_STORE_CTX *ctx, X509 *subject,
X509 *issuer);
void
X509_STORE_set_check_issued(X509_STORE *store,
X509_STORE_CTX_check_issued_fn check_issued);
X509_STORE_CTX_check_issued_fn
X509_STORE_get_check_issued(X509_STORE *store);
X509_STORE_CTX_check_issued_fn
X509_STORE_CTX_get_check_issued(X509_STORE_CTX *ctx);
π«Ά DESCRIPTION π«Ά
X509_STORE_CTX_set_verify() configures ctx to use the verify argument as the X.509 certificate chain verification function instead of the default verification function built into the library when X509_verify_cert(3) is called.
π¨ real talk: theverifyfunction you provide is only called if theX509_V_FLAG_LEGACY_VERIFYorX509_V_FLAG_NO_ALT_CHAINSflag was set onctxusingX509_STORE_CTX_set_flags(3)orX509_VERIFY_PARAM_set_flags(3). Otherwise, it is ignored and a different algorithm is used that does not support replacing the verification function. no cap.
X509_STORE_set_verify() saves the function pointer verify in the given store object. That pointer will be copied to an X509_STORE_CTX object when store is later passed as an argument to X509_STORE_CTX_init(3).
X509_STORE_set_verify_func() is an alias for X509_STORE_set_verify() implemented as a macro. cute, iconic, same energy.
X509_STORE_set_check_issued() saves the function pointer check_issued in the given store object. That pointer will be copied to an X509_STORE_CTX object when store is later passed as an argument to X509_STORE_CTX_init(3).
The check_issued function provided by the user should check whether a given certificate subject was issued using the CA certificate issuer, and must return 0 on failure and 1 on success. The default implementation ignores the ctx argument and returns success if and only if X509_check_issued(3) returns X509_V_OK.
β οΈ order check, bestie: it is important to pay close attention to the order of theissuerandsubjectarguments. InX509_check_issued(3)the issuer precedes the subject while incheck_issued()the subject comes first. it's giving chaos, lowkey.
π RETURN VALUES π
X509_STORE_CTX_verify_fn()β is supposed to return1to indicate that the chain is valid or0if it is not or if an error occurred.X509_STORE_CTX_get_verify()β returns a function pointer previously set withX509_STORE_CTX_set_verify()orX509_STORE_CTX_init(3), orNULLifctxis uninitialized.X509_STORE_get_verify()β returns the function pointer previously set withX509_STORE_set_verify(), orNULLif that function was not called on the store.X509_STORE_get_check_issued()β returns the function pointer previously set withX509_STORE_set_check_issued(), orNULLif that function was not called on the store.X509_STORE_CTX_get_check_issued()β returns thecheck_issued()function pointer set on theX509_STORE_CTX. This is either thecheck_issued()function inherited from the store used inX509_STORE_CTX_init(3)or the library's default implementation.
π SEE ALSO π
go touch grass in these other pages, they're all part of the lore:
X509_check_issued(3)X509_STORE_CTX_init(3)X509_STORE_CTX_set_error(3)X509_STORE_CTX_set_flags(3)X509_STORE_CTX_set_verify_cb(3)X509_STORE_new(3)X509_STORE_set_flags(3)X509_STORE_set_verify_cb(3)X509_verify_cert(3)X509_VERIFY_PARAM_set_flags(3)
π°οΈ HISTORY π°οΈ
X509_STORE_set_verify_func()first appeared inSSLeay 0.8.0and has been available sinceOpenBSD 2.4.X509_STORE_CTX_set_verify()andX509_STORE_CTX_get_verify()first appeared inOpenSSL 1.1.0and have been available sinceOpenBSD 7.1.X509_STORE_CTX_verify_fn(),X509_STORE_set_verify(), andX509_STORE_get_verify()first appeared inOpenSSL 1.1.0and have been available sinceOpenBSD 7.2.X509_STORE_set_check_issued(),X509_STORE_get_check_issued(), andX509_STORE_CTX_get_check_issued()first appeared inOpenSSL 1.1.0and have been available sinceOpenBSD 7.3.
π BUGS π
The reversal of order of subject and issuer betweencheck_issued()andX509_check_issued(3)is very confusing. It has led to bugs and will cause many more. iykyk π
Debian Β· June 7, 2024 Β· X509_STORE_CTX_SET_VERIFY(3) π«Άβ¨
π¦ where this page comes from
- opensuse-leap 16.0: libressl-devel-doc 4.1.0-bp160.1.1 Β· OpenSSL
- Copyright (c) 2021, 2022 Ingo Schwarze <schwarze@openbsd.org>
- Copyright (c) 2023 Job Snijders <job@openbsd.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms