Blame doc/man3/X509_STORE_CTX_get_error.pod

Packit c4476c
=pod
Packit c4476c
Packit c4476c
=head1 NAME
Packit c4476c
Packit c4476c
X509_STORE_CTX_get_error, X509_STORE_CTX_set_error,
Packit c4476c
X509_STORE_CTX_get_error_depth, X509_STORE_CTX_set_error_depth,
Packit c4476c
X509_STORE_CTX_get_current_cert, X509_STORE_CTX_set_current_cert,
Packit c4476c
X509_STORE_CTX_get0_cert, X509_STORE_CTX_get1_chain,
Packit c4476c
X509_verify_cert_error_string - get or set certificate verification status
Packit c4476c
information
Packit c4476c
Packit c4476c
=head1 SYNOPSIS
Packit c4476c
Packit c4476c
 #include <openssl/x509.h>
Packit c4476c
Packit c4476c
 int   X509_STORE_CTX_get_error(X509_STORE_CTX *ctx);
Packit c4476c
 void  X509_STORE_CTX_set_error(X509_STORE_CTX *ctx, int s);
Packit c4476c
 int   X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx);
Packit c4476c
 void  X509_STORE_CTX_set_error_depth(X509_STORE_CTX *ctx, int depth);
Packit c4476c
 X509 *X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx);
Packit c4476c
 void  X509_STORE_CTX_set_current_cert(X509_STORE_CTX *ctx, X509 *x);
Packit c4476c
 X509 *X509_STORE_CTX_get0_cert(X509_STORE_CTX *ctx);
Packit c4476c
Packit c4476c
 STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx);
Packit c4476c
Packit c4476c
 const char *X509_verify_cert_error_string(long n);
Packit c4476c
Packit c4476c
=head1 DESCRIPTION
Packit c4476c
Packit c4476c
These functions are typically called after X509_verify_cert() has indicated
Packit c4476c
an error or in a verification callback to determine the nature of an error.
Packit c4476c
Packit c4476c
X509_STORE_CTX_get_error() returns the error code of B<ctx>, see
Packit c4476c
the B<ERROR CODES> section for a full description of all error codes.
Packit c4476c
Packit c4476c
X509_STORE_CTX_set_error() sets the error code of B<ctx> to B<s>. For example
Packit c4476c
it might be used in a verification callback to set an error based on additional
Packit c4476c
checks.
Packit c4476c
Packit c4476c
X509_STORE_CTX_get_error_depth() returns the B<depth> of the error. This is a
Packit c4476c
non-negative integer representing where in the certificate chain the error
Packit c4476c
occurred. If it is zero it occurred in the end entity certificate, one if
Packit c4476c
it is the certificate which signed the end entity certificate and so on.
Packit c4476c
Packit c4476c
X509_STORE_CTX_set_error_depth() sets the error B<depth>.
Packit c4476c
This can be used in combination with X509_STORE_CTX_set_error() to set the
Packit c4476c
depth at which an error condition was detected.
Packit c4476c
Packit c4476c
X509_STORE_CTX_get_current_cert() returns the certificate in B<ctx> which
Packit c4476c
caused the error or B<NULL> if no certificate is relevant.
Packit c4476c
Packit c4476c
X509_STORE_CTX_set_current_cert() sets the certificate B<x> in B<ctx> which
Packit c4476c
caused the error.
Packit c4476c
This value is not intended to remain valid for very long, and remains owned by
Packit c4476c
the caller.
Packit c4476c
It may be examined by a verification callback invoked to handle each error
Packit c4476c
encountered during chain verification and is no longer required after such a
Packit c4476c
callback.
Packit c4476c
If a callback wishes the save the certificate for use after it returns, it
Packit c4476c
needs to increment its reference count via L<X509_up_ref(3)>.
Packit c4476c
Once such a I<saved> certificate is no longer needed it can be freed with
Packit c4476c
L<X509_free(3)>.
Packit c4476c
Packit c4476c
X509_STORE_CTX_get0_cert() retrieves an internal pointer to the
Packit c4476c
certificate being verified by the B<ctx>.
Packit c4476c
Packit c4476c
X509_STORE_CTX_get1_chain() returns a complete validate chain if a previous
Packit c4476c
call to X509_verify_cert() is successful. If the call to X509_verify_cert()
Packit c4476c
is B<not> successful the returned chain may be incomplete or invalid. The
Packit c4476c
returned chain persists after the B<ctx> structure is freed, when it is
Packit c4476c
no longer needed it should be free up using:
Packit c4476c
Packit c4476c
 sk_X509_pop_free(chain, X509_free);
Packit c4476c
Packit c4476c
X509_verify_cert_error_string() returns a human readable error string for
Packit c4476c
verification error B<n>.
Packit c4476c
Packit c4476c
=head1 RETURN VALUES
Packit c4476c
Packit c4476c
X509_STORE_CTX_get_error() returns B<X509_V_OK> or an error code.
Packit c4476c
Packit c4476c
X509_STORE_CTX_get_error_depth() returns a non-negative error depth.
Packit c4476c
Packit c4476c
X509_STORE_CTX_get_current_cert() returns the certificate which caused the
Packit c4476c
error or B<NULL> if no certificate is relevant to the error.
Packit c4476c
Packit c4476c
X509_verify_cert_error_string() returns a human readable error string for
Packit c4476c
verification error B<n>.
Packit c4476c
Packit c4476c
=head1 ERROR CODES
Packit c4476c
Packit c4476c
A list of error codes and messages is shown below.  Some of the
Packit c4476c
error codes are defined but currently never returned: these are described as
Packit c4476c
"unused".
Packit c4476c
Packit c4476c
=over 4
Packit c4476c
Packit c4476c
=item B<X509_V_OK: ok>
Packit c4476c
Packit c4476c
the operation was successful.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: unable to get issuer certificate>
Packit c4476c
Packit c4476c
the issuer certificate of a locally looked up certificate could not be found.
Packit c4476c
This normally means the list of trusted certificates is not complete.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_UNABLE_TO_GET_CRL: unable to get certificate CRL>
Packit c4476c
Packit c4476c
the CRL of a certificate could not be found.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE: unable to decrypt certificate's signature>
Packit c4476c
Packit c4476c
the certificate signature could not be decrypted. This means that the actual
Packit c4476c
signature value could not be determined rather than it not matching the
Packit c4476c
expected value, this is only meaningful for RSA keys.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE: unable to decrypt CRL's signature>
Packit c4476c
Packit c4476c
the CRL signature could not be decrypted: this means that the actual signature
Packit c4476c
value could not be determined rather than it not matching the expected value.
Packit c4476c
Unused.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY: unable to decode issuer public key>
Packit c4476c
Packit c4476c
the public key in the certificate SubjectPublicKeyInfo could not be read.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_CERT_SIGNATURE_FAILURE: certificate signature failure>
Packit c4476c
Packit c4476c
the signature of the certificate is invalid.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_CRL_SIGNATURE_FAILURE: CRL signature failure>
Packit c4476c
Packit c4476c
the signature of the certificate is invalid.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_CERT_NOT_YET_VALID: certificate is not yet valid>
Packit c4476c
Packit c4476c
the certificate is not yet valid: the notBefore date is after the current time.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_CERT_HAS_EXPIRED: certificate has expired>
Packit c4476c
Packit c4476c
the certificate has expired: that is the notAfter date is before the current time.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_CRL_NOT_YET_VALID: CRL is not yet valid>
Packit c4476c
Packit c4476c
the CRL is not yet valid.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_CRL_HAS_EXPIRED: CRL has expired>
Packit c4476c
Packit c4476c
the CRL has expired.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: format error in certificate's notBefore field>
Packit c4476c
Packit c4476c
the certificate notBefore field contains an invalid time.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD: format error in certificate's notAfter field>
Packit c4476c
Packit c4476c
the certificate notAfter field contains an invalid time.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD: format error in CRL's lastUpdate field>
Packit c4476c
Packit c4476c
the CRL lastUpdate field contains an invalid time.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD: format error in CRL's nextUpdate field>
Packit c4476c
Packit c4476c
the CRL nextUpdate field contains an invalid time.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_OUT_OF_MEM: out of memory>
Packit c4476c
Packit c4476c
an error occurred trying to allocate memory. This should never happen.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: self signed certificate>
Packit c4476c
Packit c4476c
the passed certificate is self signed and the same certificate cannot be found
Packit c4476c
in the list of trusted certificates.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: self signed certificate in certificate chain>
Packit c4476c
Packit c4476c
the certificate chain could be built up using the untrusted certificates but
Packit c4476c
the root could not be found locally.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: unable to get local issuer certificate>
Packit c4476c
Packit c4476c
the issuer certificate could not be found: this occurs if the issuer certificate
Packit c4476c
of an untrusted certificate cannot be found.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: unable to verify the first certificate>
Packit c4476c
Packit c4476c
no signatures could be verified because the chain contains only one certificate
Packit c4476c
and it is not self signed.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_CERT_CHAIN_TOO_LONG: certificate chain too long>
Packit c4476c
Packit c4476c
the certificate chain length is greater than the supplied maximum depth. Unused.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_CERT_REVOKED: certificate revoked>
Packit c4476c
Packit c4476c
the certificate has been revoked.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_INVALID_CA: invalid CA certificate>
Packit c4476c
Packit c4476c
a CA certificate is invalid. Either it is not a CA or its extensions are not
Packit c4476c
consistent with the supplied purpose.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_PATH_LENGTH_EXCEEDED: path length constraint exceeded>
Packit c4476c
Packit c4476c
the basicConstraints path-length parameter has been exceeded.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_INVALID_PURPOSE: unsupported certificate purpose>
Packit c4476c
Packit c4476c
the supplied certificate cannot be used for the specified purpose.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_CERT_UNTRUSTED: certificate not trusted>
Packit c4476c
Packit c4476c
the root CA is not marked as trusted for the specified purpose.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_CERT_REJECTED: certificate rejected>
Packit c4476c
Packit c4476c
the root CA is marked to reject the specified purpose.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_SUBJECT_ISSUER_MISMATCH: subject issuer mismatch>
Packit c4476c
Packit c4476c
the current candidate issuer certificate was rejected because its subject name
Packit c4476c
did not match the issuer name of the current certificate. This is only set
Packit c4476c
if issuer check debugging is enabled it is used for status notification and
Packit c4476c
is B<not> in itself an error.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_AKID_SKID_MISMATCH: authority and subject key identifier mismatch>
Packit c4476c
Packit c4476c
the current candidate issuer certificate was rejected because its subject key
Packit c4476c
identifier was present and did not match the authority key identifier current
Packit c4476c
certificate. This is only set if issuer check debugging is enabled it is used
Packit c4476c
for status notification and is B<not> in itself an error.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH: authority and issuer serial number mismatch>
Packit c4476c
Packit c4476c
the current candidate issuer certificate was rejected because its issuer name
Packit c4476c
and serial number was present and did not match the authority key identifier of
Packit c4476c
the current certificate. This is only set if issuer check debugging is enabled
Packit c4476c
it is used for status notification and is B<not> in itself an error.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_KEYUSAGE_NO_CERTSIGN:key usage does not include certificate signing>
Packit c4476c
Packit c4476c
the current candidate issuer certificate was rejected because its keyUsage
Packit c4476c
extension does not permit certificate signing. This is only set if issuer check
Packit c4476c
debugging is enabled it is used for status notification and is B<not> in itself
Packit c4476c
an error.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_INVALID_EXTENSION: invalid or inconsistent certificate extension>
Packit c4476c
Packit c4476c
A certificate extension had an invalid value (for example an incorrect
Packit c4476c
encoding) or some value inconsistent with other extensions.
Packit c4476c
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_INVALID_POLICY_EXTENSION: invalid or inconsistent certificate policy extension>
Packit c4476c
Packit c4476c
A certificate policies extension had an invalid value (for example an incorrect
Packit c4476c
encoding) or some value inconsistent with other extensions. This error only
Packit c4476c
occurs if policy processing is enabled.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_NO_EXPLICIT_POLICY: no explicit policy>
Packit c4476c
Packit c4476c
The verification flags were set to require and explicit policy but none was
Packit c4476c
present.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_DIFFERENT_CRL_SCOPE: Different CRL scope>
Packit c4476c
Packit c4476c
The only CRLs that could be found did not match the scope of the certificate.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE: Unsupported extension feature>
Packit c4476c
Packit c4476c
Some feature of a certificate extension is not supported. Unused.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_PERMITTED_VIOLATION: permitted subtree violation>
Packit c4476c
Packit c4476c
A name constraint violation occurred in the permitted subtrees.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_EXCLUDED_VIOLATION: excluded subtree violation>
Packit c4476c
Packit c4476c
A name constraint violation occurred in the excluded subtrees.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_SUBTREE_MINMAX: name constraints minimum and maximum not supported>
Packit c4476c
Packit c4476c
A certificate name constraints extension included a minimum or maximum field:
Packit c4476c
this is not supported.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE: unsupported name constraint type>
Packit c4476c
Packit c4476c
An unsupported name constraint type was encountered. OpenSSL currently only
Packit c4476c
supports directory name, DNS name, email and URI types.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX: unsupported or invalid name constraint syntax>
Packit c4476c
Packit c4476c
The format of the name constraint is not recognised: for example an email
Packit c4476c
address format of a form not mentioned in RFC3280. This could be caused by
Packit c4476c
a garbage extension or some new feature not currently supported.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_CRL_PATH_VALIDATION_ERROR: CRL path validation error>
Packit c4476c
Packit c4476c
An error occurred when attempting to verify the CRL path. This error can only
Packit c4476c
happen if extended CRL checking is enabled.
Packit c4476c
Packit c4476c
=item B<X509_V_ERR_APPLICATION_VERIFICATION: application verification failure>
Packit c4476c
Packit c4476c
an application specific error. This will never be returned unless explicitly
Packit c4476c
set by an application.
Packit c4476c
Packit c4476c
=back
Packit c4476c
Packit c4476c
=head1 NOTES
Packit c4476c
Packit c4476c
The above functions should be used instead of directly referencing the fields
Packit c4476c
in the B<X509_VERIFY_CTX> structure.
Packit c4476c
Packit c4476c
In versions of OpenSSL before 1.0 the current certificate returned by
Packit c4476c
X509_STORE_CTX_get_current_cert() was never B<NULL>. Applications should
Packit c4476c
check the return value before printing out any debugging information relating
Packit c4476c
to the current certificate.
Packit c4476c
Packit c4476c
If an unrecognised error code is passed to X509_verify_cert_error_string() the
Packit c4476c
numerical value of the unknown code is returned in a static buffer. This is not
Packit c4476c
thread safe but will never happen unless an invalid code is passed.
Packit c4476c
Packit c4476c
=head1 SEE ALSO
Packit c4476c
Packit c4476c
L<X509_verify_cert(3)>,
Packit c4476c
L<X509_up_ref(3)>,
Packit c4476c
L<X509_free(3)>.
Packit c4476c
Packit c4476c
=head1 COPYRIGHT
Packit c4476c
Packit c4476c
Copyright 2009-2019 The OpenSSL Project Authors. All Rights Reserved.
Packit c4476c
Packit c4476c
Licensed under the OpenSSL license (the "License").  You may not use
Packit c4476c
this file except in compliance with the License.  You can obtain a copy
Packit c4476c
in the file LICENSE in the source distribution or at
Packit c4476c
L<https://www.openssl.org/source/license.html>.
Packit c4476c
Packit c4476c
=cut