X509_STORE_CTX_GET_ERROR(3SSL)
π X509_STORE_CTX_GET_ERROR(3SSL) β the OpenSSL glow-up edition π
okay bestie, sit down, hydrate, because this is the OpenSSL 3SSL manual page about certificate verification status info β aka how you find out why the chain check said no. π
β¨ NAME β¨
These are the girlies in this page, and they all live to get or set certificate verification status information:
X509_STORE_CTX_get_errorX509_STORE_CTX_set_errorX509_STORE_CTX_get_error_depthX509_STORE_CTX_set_error_depthX509_STORE_CTX_get_current_certX509_STORE_CTX_set_current_certX509_STORE_CTX_get0_certX509_STORE_CTX_get1_chainX509_STORE_CTX_get0_current_crlX509_verify_cert_error_string
πΈ 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);
X509_CRL *X509_STORE_CTX_get0_current_crl(const X509_STORE_CTX *ctx);
const char *X509_verify_cert_error_string(long n);
π¦ DESCRIPTION π¦
So here's the tea: you call these functions typically after certificate or chain verification using X509_verify_cert(3) or X509_STORE_CTX_verify(3) has indicated an error β or, plot twist, from inside a verification callback β so you can figure out the nature of an error. π
π the getters and setters, one by one
X509_STORE_CTX_get_error()β returns the error code ofctx.ctxMUST NOT be NULL. Peep the "ERROR CODES" section for the full rundown of every possible code. Heads up, no cap: 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. π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 be NULL.X509_STORE_CTX_get_error_depth()β returns the depth of the error. It's a nonnegative integer showing where in the certificate chain the error happened: if it's 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 be NULL.X509_STORE_CTX_set_error_depth()β sets the error depth. 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. Bestie listen: this value is not intended to remain valid for very long, and it 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 the 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). π«Ά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 free up using:
OSSL_STACK_OF_X509_free(chain);
X509_STORE_CTX_get0_current_crl()β returns an internal pointer to the possibly unverified CRL being actively considered during verification by thectx, orNULL. The returned value isNULLwhen the verification is not considering a specific CRL, or has finished CRL verification. And because this pointer is an internal value used only during X509 verification, the values seen and order in which they are seen if called during the verification callback should not be relied upon to be consistent. πX509_verify_cert_error_string()β returns a human readable error string for verification errorn. iconic, honestly.
π 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_STORE_CTX_get_current_crl()returns the CRL which caused the error orNULLif no CRL 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". π©
X509_V_OK: ok
The operation was successful. slay. β¨
X509_V_ERR_UNSPECIFIED: unspecified certificate verification error
Unspecified error; should not happen. π
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 the X509_V_FLAG_PARTIAL_CHAIN flag 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.
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. β°
X509_V_ERR_CERT_HAS_EXPIRED: certificate has expired
The certificate has expired: that is the "notAfter" date is before the current time. π
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 CRL lastUpdate field 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. π
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 the X509_V_FLAG_PARTIAL_CHAIN flag 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. π«
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
The basicConstraints path-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 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. π§
(okay bestie we're still deep in the error-code saga β these are the rest, stay with me π)
X509_V_ERR_KEYUSAGE_NO_CRL_SIGNβ key usage does not include CRL signing. The key usage field literally does not say it's allowed to sign CRLs. Rude of it, honestly.X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSIONβ unhandled critical CRL extension. There's a critical CRL extension and nobody handled it. Not the vibe.X509_V_ERR_INVALID_NON_CAβ invalid non-CA certificate (has CA markings). The cert is a non-CA certificate but it's got CA markings on it, so it's invalid. Awkward.X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDEDβ proxy path length constraint exceeded. You blew past the proxy path length limit. It's giving "went too far."X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATUREβ key usage does not include digital signature. And because of that it cannot sign certificates, periodt. π«X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWEDβ proxy certificates not allowed, please set the appropriate flag. Proxy certs are a no 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 (think an incorrect encoding, for example) or a value that's inconsistent with other extensions.X509_V_ERR_INVALID_POLICY_EXTENSIONβ invalid or inconsistent certificate policy extension. The certificate policies extension had an invalid value (again, like an incorrect encoding) or a value inconsistent with other extensions. Heads up: this error only shows up 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 there was none present. Nothing to work with. π€·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 isn't supported. Unused.X509_V_ERR_UNNESTED_RESOURCEβ RFC 3779 resource not subset of parent's resources. See RFC 3779 for the details, bestie.X509_V_ERR_PERMITTED_VIOLATIONβ permitted subtree violation. A name constraint violation happened in the permitted subtrees.X509_V_ERR_EXCLUDED_VIOLATIONβ excluded subtree violation. A name constraint violation happened in the excluded subtrees.X509_V_ERR_SUBTREE_MINMAXβ name constraints minimum and maximum not supported. The certificate's name constraints extension included a minimum or maximum field, and that is not supported.X509_V_ERR_APPLICATION_VERIFICATIONβ application verification failure. An application specific error. This one will never be returned unless it's explicitly set by an application callback. Handcrafted, bespoke, artisan error. β¨X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPEβ unsupported name constraint type. You hit a name constraint type that isn't supported. 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 isn't recognised β say an email address format of a form not mentioned in RFC3280. Could be a garbage extension, could be some new feature that isn't currently supported.X509_V_ERR_UNSUPPORTED_NAME_SYNTAXβ unsupported or invalid name syntax. Exactly what it says on the tin.X509_V_ERR_CRL_PATH_VALIDATION_ERRORβ CRL path validation error. Something went wrong while trying to verify the CRL path. This one can only happen if extended CRL checking is enabled.X509_V_ERR_PATH_LOOPβ path loop. Path loop. (it's literally looping, bestie π)X509_V_ERR_HOSTNAME_MISMATCHβ hostname mismatch.X509_V_ERR_EMAIL_MISMATCHβ email address mismatch.X509_V_ERR_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.X509_V_ERR_CA_KEY_TOO_SMALLβ CA certificate key too weak.X509_V_ERR_CA_MD_TOO_WEAKβ CA signature digest algorithm too weak.X509_V_ERR_INVALID_CALLβ invalid certificate verification context.X509_V_ERR_STORE_LOOKUPβ issuer certificate lookup error.X509_V_ERR_NO_VALID_SCTSβ certificate transparency required, but no valid SCTs found.X509_V_ERR_PROXY_SUBJECT_NAME_VIOLATIONβ proxy subject name violation.X509_V_ERR_OCSP_VERIFY_NEEDEDβ OCSP verification needed. Returned by the verify callback to say an OCSP verification is needed.X509_V_ERR_OCSP_VERIFY_FAILEDβ OCSP verification failed. Returned by the verify callback to say OCSP verification failed. πX509_V_ERR_OCSP_CERT_UNKNOWNβ OCSP unknown cert. Returned by the verify callback to say the certificate is not recognized by the OCSP responder.X509_V_ERR_OCSP_RESP_INVALIDβ OCSP response(s) invalid. Returned by the verify callback to say that one or more OCSP responses are invalid.X509_V_ERR_OCSP_SIGNATURE_FAILUREβ OCSP response signature failure. Returned by the verify callback to say OCSP response signature verification failed.X509_V_ERR_OCSP_NOT_YET_VALIDβ OCSP response not yet valid (contains a date in the future). Returned by the verify callback to say the OCSP response has athisUpdatedate in the future. Time traveler behaviour, honestly. π°οΈX509_V_ERR_OCSP_HAS_EXPIREDβ OCSP response has expired. Returned by the verify callback to say the OCSP response has expired.X509_V_ERR_OCSP_NO_RESPONSEβ no OCSP response available for certificate. Returned by the verify callback to say there's no OCSP response available for the certificate.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 isn't a CA, or its extensions aren't 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.X509_V_ERR_MISSING_AUTHORITY_KEY_IDENTIFIERβ AKID is missing. Missing Authority Key Identifier.X509_V_ERR_EMPTY_AUTHORITY_KEY_IDENTIFIERβ AKID has no attributes. Authority Key Identifier has no attributes.X509_V_ERR_AKID_ISSUER_SERIAL_NOT_PAIREDβ issuer and serial number must be paired. Authority Key Identifier issuer and serial number must be paired. They're a set, bestie, you can't split them up. π«Ά
π NOTES β¨
The above functions should be used instead of directly referencing the fields in the X509_VERIFY_CTX structure. Like, don't go rummaging in the struct yourself, use the functions.
In versions of OpenSSL before 1.0, the current certificate returned by X509_STORE_CTX_get_current_cert() was never NULL. So applications should check the return value before printing out any debugging information relating to the current certificate. No cap.
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 it will never happen unless an invalid code is passed. So basically: not your problem unless you did something weird. π
π 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. Yeah. They just swapped them. Iconic behaviour for a doc, unfortunately. π
π SEE ALSO π
Β©οΈ COPYRIGHT π
Copyright 2009-2026 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 a wrap on X509_STORE_CTX_GET_ERROR(3SSL), bestie π this whole thing lives in version 4.0.3, dated 2026-09-29 β go verify some certs and slay π
β¨
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms