X509_STORE_CTX_GET_ERROR(3ossl)
π NAME π
okay bestie, this is the manual page for X509_STORE_CTX_GET_ERROR(3ossl) β the OpenSSL glow-up for getting and setting certificate verification status info β¨. It covers X509_STORE_CTX_get_error, X509_STORE_CTX_set_error, X509_STORE_CTX_get_error_depth, X509_STORE_CTX_set_error_depth, X509_STORE_CTX_get_current_cert, X509_STORE_CTX_set_current_cert, X509_STORE_CTX_get0_cert, X509_STORE_CTX_get1_chain, and X509_verify_cert_error_string β all here to get or set certificate verification status information. iykyk π
π¦ SYNOPSIS π¦
#include <openssl/x509.h>
int X509_STORE_CTX_get_error(const X509_STORE_CTX *ctx);
void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx, int s);
int X509_STORE_CTX_get_error_depth(const X509_STORE_CTX *ctx);
void X509_STORE_CTX_set_error_depth(X509_STORE_CTX *ctx, int depth);
X509 *X509_STORE_CTX_get_current_cert(const X509_STORE_CTX *ctx);
void X509_STORE_CTX_set_current_cert(X509_STORE_CTX *ctx, X509 *x);
X509 *X509_STORE_CTX_get0_cert(const X509_STORE_CTX *ctx);
STACK_OF(X509) *X509_STORE_CTX_get1_chain(const X509_STORE_CTX *ctx);
const char *X509_verify_cert_error_string(long n);
πΈ DESCRIPTION πΈ
So here's the vibe: these functions are typically called after certificate or chain verification using X509_verify_cert(3) or X509_STORE_CTX_verify(3) has indicated an error, or inside a verification callback to figure out the nature of an error. Very detective-core, very useful. π΅οΈββοΈ
X509_STORE_CTX_get_error()β returns the error code ofctx.ctxMUST NOT beNULL. See the "ERROR CODES" section for a full description of all error codes. It may return a code!= X509_V_OKeven ifX509_verify_cert()did not indicate an error, likely because a verification callback function has waived the error. sneaky but valid. πX509_STORE_CTX_set_error()β sets the error code ofctxtos. For example it might be used in a verification callback to set an error based on additional checks.ctxMUST NOT beNULL.X509_STORE_CTX_get_error_depth()β returns the depth of the error. This is a nonnegative integer representing where in the certificate chain the error occurred. If it is zero it occurred in the end entity certificate, one if it is the certificate which signed the end entity certificate and so on.ctxMUST NOT beNULL. chain lore fr fr. βοΈX509_STORE_CTX_set_error_depth()β sets the error depth. This can be used in combination withX509_STORE_CTX_set_error()to set the depth at which an error condition was detected.X509_STORE_CTX_get_current_cert()β returns the current certificate inctx. If an error occurred, the current certificate will be the one that is most closely related to the error, or possiblyNULLif no such certificate is relevant.X509_STORE_CTX_set_current_cert()β sets the certificatexinctxwhich caused the error. This value is not intended to remain valid for very long, and remains owned by the caller. It may be examined by a verification callback invoked to handle each error encountered during chain verification and is no longer required after such a callback. If a callback wishes to save the certificate for use after it returns, it needs to increment its reference count viaX509_up_ref(3). Once such a saved certificate is no longer needed it can be freed withX509_free(3). reference-counting girlies stay winning. πX509_STORE_CTX_get0_cert()β retrieves an internal pointer to the certificate being verified by thectx. It may beNULLif a raw public key is being verified.X509_STORE_CTX_get1_chain()β returns a complete validate chain if a previous verification is successful. Otherwise the returned chain may be incomplete or invalid. The returned chain persists after thectxstructure is freed. When it is no longer needed it should be freed using:
OSSL_STACK_OF_X509_free(chain);
X509_verify_cert_error_string()β returns a human readable error string for verification errorn. tiny function, big "explain it to me like I'm in the group chat" energy. π¬
β¨ RETURN VALUES β¨
X509_STORE_CTX_get_error()β returnsX509_V_OKor an error code.X509_STORE_CTX_get_error_depth()β returns a nonnegative error depth.X509_STORE_CTX_get_current_cert()β returns the certificate which caused the error orNULLif no certificate is relevant to the error.X509_verify_cert_error_string()β returns a human readable error string for verification errorn.
π₯ ERROR CODES π₯
A list of error codes and messages is shown below. Some of the error codes are defined but currently never returned: these are described as "unused". So if you see "unused", don't come for me β that's literally what the page says. π
X509_V_OKβok. The operation was successful. πX509_V_ERR_UNSPECIFIEDβunspecified certificate verification error. Unspecified error; should not happen. spooky. π»X509_V_ERR_UNABLE_TO_GET_ISSUER_CERTβunable to get issuer certificate. The issuer certificate of a locally looked up certificate could not be found. This normally means the list of trusted certificates is not complete. To allow any certificate (not only a self-signed one) in the trust store to terminate the chain theX509_V_FLAG_PARTIAL_CHAINflag may be set.X509_V_ERR_UNABLE_TO_GET_CRLβunable to get certificate CRL. The CRL of a certificate could not be found.X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATUREβunable to decrypt certificate's signature. The certificate signature could not be decrypted. This means that the actual signature value could not be determined rather than it not matching the expected value, this is only meaningful for RSA keys. RSA-specific lore, noted.X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATUREβunable to decrypt CRL's signature. The CRL signature could not be decrypted: this means that the actual signature value could not be determined rather than it not matching the expected value. Unused.X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEYβunable to decode issuer public key. The public key in the certificate "SubjectPublicKeyInfo" field could not be read.X509_V_ERR_CERT_SIGNATURE_FAILUREβcertificate signature failure. The signature of the certificate is invalid.X509_V_ERR_CRL_SIGNATURE_FAILUREβCRL signature failure. The signature of the CRL is invalid.X509_V_ERR_CERT_NOT_YET_VALIDβcertificate is not yet valid. The certificate is not yet valid: the "notBefore" date is after the current time. not me being early πX509_V_ERR_CERT_HAS_EXPIREDβcertificate has expired. The certificate has expired: that is the "notAfter" date is before the current time. rip bozo πX509_V_ERR_CRL_NOT_YET_VALIDβCRL is not yet valid. The CRL is not yet valid.X509_V_ERR_CRL_HAS_EXPIREDβCRL has expired. The CRL has expired.X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELDβformat error in certificate's notBefore field. The certificate "notBefore" field contains an invalid time.X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELDβformat error in certificate's notAfter field. The certificate "notAfter" field contains an invalid time.X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELDβformat error in CRL's lastUpdate field. The CRLlastUpdatefield contains an invalid time.X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELDβformat error in CRL's nextUpdate field. The CRL "nextUpdate" field contains an invalid time.X509_V_ERR_OUT_OF_MEMβout of memory. An error occurred trying to allocate memory. the struggle.X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERTβself-signed certificate. The passed certificate is self-signed and the same certificate cannot be found in the list of trusted certificates.X509_V_ERR_SELF_SIGNED_CERT_IN_CHAINβself-signed certificate in certificate chain. The certificate chain could be built up using the untrusted certificates but no suitable trust anchor (which typically is a self-signed root certificate) could be found in the trust store.X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLYβunable to get local issuer certificate. The issuer certificate could not be found: this occurs if the issuer certificate of an untrusted certificate cannot be found.X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATUREβunable to verify the first certificate. No signatures could be verified because the chain contains only one certificate and it is not self-signed and theX509_V_FLAG_PARTIAL_CHAINflag is not set.X509_V_ERR_CERT_CHAIN_TOO_LONGβcertificate chain too long. The certificate chain length is greater than the supplied maximum depth.X509_V_ERR_CERT_REVOKEDβcertificate revoked. The certificate has been revoked. blocked and reported π«X509_V_ERR_NO_ISSUER_PUBLIC_KEYβissuer certificate doesn't have a public key. The issuer certificate does not have a public key.X509_V_ERR_PATH_LENGTH_EXCEEDEDβpath length constraint exceeded. ThebasicConstraintspath-length parameter has been exceeded.X509_V_ERR_INVALID_PURPOSEβunsuitable certificate purpose. The target certificate cannot be used for the specified purpose.X509_V_ERR_CERT_UNTRUSTEDβcertificate not trusted. The root CA is not marked as trusted for the specified purpose.X509_V_ERR_CERT_REJECTEDβcertificate rejected. The root CA is marked to reject the specified purpose.X509_V_ERR_SUBJECT_ISSUER_MISMATCHβsubject issuer mismatch. The current candidate issuer certificate was rejected because its subject name did not match the issuer name of the current certificate.X509_V_ERR_AKID_SKID_MISMATCHβauthority and subject key identifier mismatch. The current candidate issuer certificate was rejected because its subject key identifier was present and did not match the authority key identifier of the current certificate.X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCHβauthority and issuer serial number mismatch. The current candidate issuer certificate was rejected because its issuer name and serial number was present and did not match the authority key identifier of the current certificate.X509_V_ERR_KEYUSAGE_NO_CERTSIGNβkey usage does not include certificate signing. The current candidate issuer certificate was rejected because its "keyUsage" extension does not permit certificate signing.X509_V_ERR_UNABLE_TO_GET_CRL_ISSUERβunable to get CRL issuer certificate. Unable to get CRL issuer certificate.X509_V_ERR_UNHANDLED_CRITICAL_EXTENSIONβunhandled critical extension. Unhandled critical extension. critical and unhandled? iconic but concerning.X509_V_ERR_KEYUSAGE_NO_CRL_SIGNβkey usage does not include CRL signing. Key usage does not include CRL signing.X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSIONβunhandled critical CRL extension. Unhandled critical CRL extension.X509_V_ERR_INVALID_NON_CAβinvalid non-CA certificate (has CA markings). Invalid non-CA certificate has CA markings.X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDEDβproxy path length constraint exceeded. Proxy path length constraint exceeded.X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATUREβkey usage does not include digital signature. Key usage does not include digital signature, and therefore cannot sign certificates.X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWEDβ proxy certificates not allowed, please set the appropriate flag: proxy certificates are not allowed unless theX509_V_FLAG_ALLOW_PROXY_CERTSflag is set. πX509_V_ERR_INVALID_EXTENSIONβ invalid or inconsistent certificate extension: a certificate extension had an invalid value (like an incorrect encoding) or some value inconsistent with other extensions. π«X509_V_ERR_INVALID_POLICY_EXTENSIONβ invalid or inconsistent certificate policy extension: a certificate policies extension had an invalid value (like an incorrect encoding) or some value inconsistent with other extensions. This error only occurs if policy processing is enabled. β¨X509_V_ERR_NO_EXPLICIT_POLICYβ no explicit policy: the verification flags were set to require an explicit policy, but none was present. πX509_V_ERR_DIFFERENT_CRL_SCOPEβ different CRL scope: the only CRLs that could be found did not match the scope of the certificate. πX509_V_ERR_UNSUPPORTED_EXTENSION_FEATUREβ unsupported extension feature: some feature of a certificate extension is not supported. Unused. πX509_V_ERR_UNNESTED_RESOURCEβ RFC 3779 resource not subset of parent's resources: see RFC 3779 for details. π¦X509_V_ERR_PERMITTED_VIOLATIONβ permitted subtree violation: a name constraint violation occurred in the permitted subtrees. π¨X509_V_ERR_EXCLUDED_VIOLATIONβ excluded subtree violation: a name constraint violation occurred in the excluded subtrees. π¨X509_V_ERR_SUBTREE_MINMAXβ name constraints minimum and maximum not supported: a certificate name constraints extension included a minimum or maximum field, and this is not supported. πX509_V_ERR_APPLICATION_VERIFICATIONβ application verification failure: an application specific error. This will never be returned unless explicitly set by an application callback. πX509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPEβ unsupported name constraint type: an unsupported name constraint type was encountered. OpenSSL currently only supports directory name, DNS name, email and URI types. πX509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAXβ unsupported or invalid name constraint syntax: the format of the name constraint is not recognised, for example an email address format of a form not mentioned inRFC3280. This could be caused by a garbage extension or some new feature not currently supported. π§X509_V_ERR_UNSUPPORTED_NAME_SYNTAXβ unsupported or invalid name syntax: unsupported or invalid name syntax. π«X509_V_ERR_CRL_PATH_VALIDATION_ERRORβ CRL path validation error: an error occurred when attempting to verify the CRL path. This error can only happen if extended CRL checking is enabled. π₯X509_V_ERR_PATH_LOOPβ path loop: path loop. πX509_V_ERR_HOSTNAME_MISMATCHβ hostname mismatch: hostname mismatch. π¬X509_V_ERR_EMAIL_MISMATCHβ email address mismatch: email address mismatch. π§X509_V_ERR_IP_ADDRESS_MISMATCHβ IP address mismatch: IP address mismatch. πX509_V_ERR_DANE_NO_MATCHβ no matching DANE TLSA records: DANE TLSA authentication is enabled, but no TLSA records matched the certificate chain. This error is only possible inopenssl-s_client(1). π¦X509_V_ERR_EE_KEY_TOO_SMALLβ EE certificate key too weak: EE certificate key too weak. π₯ΊX509_V_ERR_CA_KEY_TOO_SMALLβ CA certificate key too weak: CA certificate key too weak. π₯ΊX509_V_ERR_CA_MD_TOO_WEAKβ CA signature digest algorithm too weak: CA signature digest algorithm too weak. π₯ΊX509_V_ERR_INVALID_CALLβ invalid certificate verification context: invalid certificate verification context. πX509_V_ERR_STORE_LOOKUPβ issuer certificate lookup error: issuer certificate lookup error. πX509_V_ERR_NO_VALID_SCTSβ certificate transparency required, but no valid SCTs found: Certificate Transparency required, but no valid SCTs found. πX509_V_ERR_PROXY_SUBJECT_NAME_VIOLATIONβ proxy subject name violation: proxy subject name violation. π©X509_V_ERR_OCSP_VERIFY_NEEDEDβ OCSP verification needed: returned by the verify callback to indicate an OCSP verification is needed. π£X509_V_ERR_OCSP_VERIFY_FAILEDβ OCSP verification failed: returned by the verify callback to indicate OCSP verification failed. πX509_V_ERR_OCSP_CERT_UNKNOWNβ OCSP unknown cert: returned by the verify callback to indicate that the certificate is not recognized by the OCSP responder. πX509_V_ERR_UNSUPPORTED_SIGNATURE_ALGORITHMβ unsupported signature algorithm: cannot find certificate signature algorithm. π§©X509_V_ERR_SIGNATURE_ALGORITHM_MISMATCHβ subject signature algorithm and issuer public key algorithm mismatch: the issuer's public key is not of the type required by the signature in the subject's certificate. π«X509_V_ERR_SIGNATURE_ALGORITHM_INCONSISTENCYβ cert info signature and signature algorithm mismatch: the algorithm given in the certificate info is inconsistent with the one used for the certificate signature. π΅βπ«X509_V_ERR_INVALID_CAβ invalid CA certificate: a CA certificate is invalid. Either it is not a CA or its extensions are not consistent with the supplied purpose. π«X509_V_ERR_RPK_UNTRUSTEDβ raw public key untrusted, no trusted keys configured: no TLS records were configured to validate the raw public key, or DANE was not enabled on the connection. π
π«Ά NOTES, BESTIE π«Ά
The above functions should be used instead of directly referencing the fields in the X509_VERIFY_CTX structure. like, pls use the functions, not the raw fields β it's giving "please do not touch the internals" energy π
In versions of OpenSSL before 1.0, the current certificate returned by X509_STORE_CTX_get_current_cert() was never NULL. Applications should check the return value before printing out any debugging information relating to the current certificate. π
If an unrecognised error code is passed to X509_verify_cert_error_string(), the numerical value of the unknown code is returned in a static buffer. This is not thread safe but will never happen unless an invalid code is passed. β οΈ
π BUGS π
Previous versions of this documentation swapped the meaning of the X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT and X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY error codes. so if you're reading an old copy, beware β the receipts were mixed up π
π SEE ALSO π
π COPYRIGHT π
Copyright 2009-2023 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. π
okay bestie, that's the whole page β this one comes from OpenSSL 3.5.6, dated 2026-04-07, and it's filed under the very iconic name X509_STORE_CTX_GET_ERROR(3ossl) π
π¦ 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