b3b1eb5735
The function X509_verify_cert checks the value of |ctx->chain| at the beginning, and if it is NULL then it initialises it, along with the value of ctx->untrusted. The normal way to use X509_verify_cert() is to first call X509_STORE_CTX_init(); then set up various parameters etc; then call X509_verify_cert(); then check the results; and finally call X509_STORE_CTX_cleanup(). The initial call to X509_STORE_CTX_init() sets |ctx->chain| to NULL. The only place in the OpenSSL codebase where |ctx->chain| is set to anything other than a non NULL value is in X509_verify_cert itself. Therefore the only ways that |ctx->chain| could be non NULL on entry to X509_verify_cert is if one of the following occurs: 1) An application calls X509_verify_cert() twice without re-initialising in between. 2) An application reaches inside the X509_STORE_CTX structure and changes the value of |ctx->chain| directly. With regards to the second of these, we should discount this - it should not be supported to allow this. With regards to the first of these, the documentation is not exactly crystal clear, but the implication is that you must call X509_STORE_CTX_init() before each call to X509_verify_cert(). If you fail to do this then, at best, the results would be undefined. Calling X509_verify_cert() with |ctx->chain| set to a non NULL value is likely to have unexpected results, and could be dangerous. This commit changes the behaviour of X509_verify_cert() so that it causes an error if |ctx->chain| is anything other than NULL (because this indicates that we have not been initialised properly). It also clarifies the associated documentation. This is a follow up commit to CVE-2015-1793. Reviewed-by: Stephen Henson <steve@openssl.org>
54 lines
1.5 KiB
Text
54 lines
1.5 KiB
Text
=pod
|
|
|
|
=head1 NAME
|
|
|
|
X509_verify_cert - discover and verify X509 certificte chain
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
#include <openssl/x509.h>
|
|
|
|
int X509_verify_cert(X509_STORE_CTX *ctx);
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
The X509_verify_cert() function attempts to discover and validate a
|
|
certificate chain based on parameters in B<ctx>. A complete description of
|
|
the process is contained in the L<verify(1)|verify(1)> manual page.
|
|
|
|
=head1 RETURN VALUES
|
|
|
|
If a complete chain can be built and validated this function returns 1,
|
|
otherwise it return zero, in exceptional circumstances it can also
|
|
return a negative code.
|
|
|
|
If the function fails additional error information can be obtained by
|
|
examining B<ctx> using, for example X509_STORE_CTX_get_error().
|
|
|
|
=head1 NOTES
|
|
|
|
Applications rarely call this function directly but it is used by
|
|
OpenSSL internally for certificate validation, in both the S/MIME and
|
|
SSL/TLS code.
|
|
|
|
The negative return value from X509_verify_cert() can only occur if no
|
|
certificate is set in B<ctx> (due to a programming error); if X509_verify_cert()
|
|
twice without reinitialising B<ctx> in between; or if a retry
|
|
operation is requested during internal lookups (which never happens with
|
|
standard lookup methods). It is however recommended that application check
|
|
for <= 0 return value on error.
|
|
|
|
=head1 BUGS
|
|
|
|
This function uses the header B<x509.h> as opposed to most chain verification
|
|
functiosn which use B<x509_vfy.h>.
|
|
|
|
=head1 SEE ALSO
|
|
|
|
L<X509_STORE_CTX_get_error(3)|X509_STORE_CTX_get_error(3)>
|
|
|
|
=head1 HISTORY
|
|
|
|
X509_verify_cert() is available in all versions of SSLeay and OpenSSL.
|
|
|
|
=cut
|