X509_STORE_CTX_SET_FLAGS(3ssl)
π X509_STORE_CTX_SET_FLAGS(3) β like, the whole parameter-initialisation situation
okay bestie so this is a page from the Library Functions Manual (yes that one, the OpenSSL section 3ssl girlies) and it's literally all about the eight functions that poke at the X509_VERIFY_PARAM object hanging out inside your X509_STORE_CTX. parameter initialisation, but make it β¨fashionβ¨.
πΈ NAME πΈ
X509_STORE_CTX_set_flags, X509_STORE_CTX_set_time, X509_STORE_CTX_set_depth, X509_STORE_CTX_set_trust, X509_STORE_CTX_set_purpose, X509_STORE_CTX_get0_param, X509_STORE_CTX_set0_param, X509_STORE_CTX_set_default β X509_STORE_CTX parameter initialisation π
β¨ SYNOPSIS β¨
#include <openssl/x509_vfy.h>
void
X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags);
void
X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long dummy,
time_t time);
void
X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth);
int
X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust);
int
X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose);
X509_VERIFY_PARAM *
X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx);
void
X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx,
X509_VERIFY_PARAM *param);
int
X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name);
π¦ DESCRIPTION π¦
okay so all of these functions operate on the X509_VERIFY_PARAM object that ctx is using. the usual order of operations, iykyk: you call X509_STORE_CTX_init(3) on ctx before these, and X509_verify_cert(3) after. main character sequencing, no cap π
X509_STORE_CTX_set_flags()β sets the internal verification parameter flags toflags. for the whole rundown on what verification flags even mean, go readX509_VERIFY_PARAM_set_flags(3). π³οΈX509_STORE_CTX_set_time()β sets the verification time, usingX509_VERIFY_PARAM_set_time(3). thedummyargument is literally ignored, it's just there living its life. πX509_STORE_CTX_set_depth()β sets the maximum verification depth usingX509_VERIFY_PARAM_set_depth(3). translation: that's the maximum number of untrusted CA certificates that can appear in a chain. so like, the chain limit. βοΈX509_STORE_CTX_set_trust()β sets the trust identifier, which you can also set viaX509_VERIFY_PARAM_set_trust(3). here's the tea: if thetrustargument is0or invalid, or the trust identifier is already set to a non-zero value in theX509_VERIFY_PARAMobject β nothing happens. no action, no drama. πX509_STORE_CTX_set_purpose()β sets the purpose identifier, also settable viaX509_VERIFY_PARAM_set_purpose(3). if thepurposeargument is0or any failure occurs, nothing is changed. respectfully, it stays exactly as it was. π«Ά
and now, the terminology moment, pay attention bestie: from here on, the trust identifier contained in the X509_PURPOSE object associated with purpose is called the βassociated trustβ. iconic name, honestly.
- the function fails if the
purposeargument or the associated trust is invalid but not0. otherwise,X509_STORE_CTX_set_purpose()also does the equivalent of callingX509_STORE_CTX_set_trust()with the associated trust. two-for-one. π - if the purpose identifier is already set to a non-zero value in the
X509_VERIFY_PARAMobject, it is not changed β even if thepurposeargument is valid too. it's taken, sorry. π X509_STORE_CTX_get0_param()β retrieves an internal pointer to the verification parameters associated withctx. just a peek, no take-backs needed. πX509_STORE_CTX_set0_param()β sets the internal verification parameter pointer toparam. β οΈ after this call,paramshould not be used. like, it's been claimed, hands off.X509_STORE_CTX_set_default()β looks up and sets the default verification method toname. it usesX509_VERIFY_PARAM_lookup(3)to find an appropriate set of parameters fromname, then copies them withX509_VERIFY_PARAM_inherit(3). cute little inheritance moment. π§¬
π₯ RETURN VALUES π₯
X509_STORE_CTX_set_trust()returns1if thetrustargument is0or valid, or0if it is invalid but not0. and ngl, a return value of1does not imply that the trust identifier stored in theX509_VERIFY_PARAMobject was actually changed. plot twist. πX509_STORE_CTX_set_purpose()returns1if both thepurposeargument and the associated trust are0or valid. it returns0if either thepurposeargument or the associated trust is invalid but not0. and again β a return value of1does not imply that any data was changed. πX509_STORE_CTX_get0_param()returns a pointer to anX509_VERIFY_PARAMstructure, orNULLif an error occurred. π«X509_STORE_CTX_set_default()returns1for success, or0if an error occurred. β¨
π ERRORS π
here are the diagnostics you can retrieve with ERR_get_error(3), ERR_GET_REASON(3), and ERR_reason_error_string(3):
X509_R_UNKNOWN_TRUST_ID"unknown trust id"βX509_STORE_CTX_set_trust()was called with atrustargument that is invalid but not0. other implementations may also return this whenX509_STORE_CTX_set_purpose()is called with apurposeargument with invalid associated trust.X509_R_UNKNOWN_PURPOSE_ID"unknown purpose id"β thepurposeargument is invalid but not0.
the other functions provide no diagnostics. they simply don't gossip. π
π SEE ALSO π
X509_STORE_CTX_get_error(3), X509_STORE_CTX_new(3), X509_STORE_CTX_set_verify(3), X509_STORE_CTX_set_verify_cb(3), X509_STORE_new(3), X509_STORE_set1_param(3), X509_STORE_set_verify_cb(3), X509_verify_cert(3), X509_VERIFY_PARAM_new(3), X509_VERIFY_PARAM_set_flags(3)
π HISTORY π
a little lore drop for you, bestie β here's the timeline:
X509_STORE_CTX_set_depth()first appeared in OpenSSL 0.9.3 and has been available since OpenBSD 2.4. elder. πX509_STORE_CTX_set_trust()andX509_STORE_CTX_set_purpose()first appeared in OpenSSL 0.9.5 and have been available since OpenBSD 2.7. βX509_STORE_CTX_set_flags()andX509_STORE_CTX_set_time()first appeared in OpenSSL 0.9.6 and have been available since OpenBSD 2.9. π¦X509_STORE_CTX_get0_param(),X509_STORE_CTX_set0_param(), andX509_STORE_CTX_set_default()first appeared in OpenSSL 0.9.8 and have been available since OpenBSD 4.5. the babies of the group. π
β οΈ CAVEATS β οΈ
okay, real talk, this is the part you actually need to internalise:
the precise effect of a successful call toX509_STORE_CTX_set_trust()andX509_STORE_CTX_set_purpose()is unclear unless only one of these functions is used immediately afterX509_STORE_CTX_init(3). that's genuinely fuzzy territory, not a vibe.
it is therefore recommended to use X509_STORE_CTX_get0_param(), X509_VERIFY_PARAM_set_trust(3), and X509_VERIFY_PARAM_set_purpose(3) instead. do that, bestie. save yourself the confusion. π«Ά
π and that's the page!! brought to you by Debian, dated August 29, 2024, filed under X509_STORE_CTX_SET_FLAGS(3) in the Library Functions Manual β go forth and initialise those parameters, you absolute icon. periodt. π
β¨π
π¦ where this page comes from
- opensuse-leap 16.0: libressl-devel-doc 4.1.0-bp160.1.1 Β· OpenSSL
- Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org>
- Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
- Copyright (c) 2009 The OpenSSL Project. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms