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_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
  • X509_STORE_CTX_get0_current_crl
  • X509_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 of ctx. ctx MUST 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_OK even if X509_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 of ctx to s. For example it might be used in a verification callback to set an error based on additional checks. ctx MUST 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. ctx MUST NOT be NULL.
  • X509_STORE_CTX_set_error_depth() β€” sets the error depth. Can be used in combination with X509_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 in ctx. If an error occurred, the current certificate will be the one that is most closely related to the error, or possibly NULL if no such certificate is relevant.
  • X509_STORE_CTX_set_current_cert() β€” sets the certificate x in ctx which 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 via X509_up_ref(3). Once such a saved certificate is no longer needed it can be freed with X509_free(3). 🫢
  • X509_STORE_CTX_get0_cert() β€” retrieves an internal pointer to the certificate being verified by the ctx. It may be NULL if 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 the ctx structure 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 the ctx, or NULL. The returned value is NULL when 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 error n. iconic, honestly.

πŸ’œ RETURN VALUES πŸ’œ

  • X509_STORE_CTX_get_error() returns X509_V_OK or 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 or NULL if no certificate is relevant to the error.
  • X509_STORE_CTX_get_current_crl() returns the CRL which caused the error or NULL if no CRL is relevant to the error.
  • X509_verify_cert_error_string() returns a human readable error string for verification error n.

🌈 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 the X509_V_FLAG_ALLOW_PROXY_CERTS flag 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 in openssl-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 a thisUpdate date 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 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