Blame doc/man3/X509_STORE_CTX_new.pod

Packit c4476c
=pod
Packit c4476c
Packit c4476c
=head1 NAME
Packit c4476c
Packit c4476c
X509_STORE_CTX_new, X509_STORE_CTX_cleanup, X509_STORE_CTX_free,
Packit c4476c
X509_STORE_CTX_init, X509_STORE_CTX_set0_trusted_stack, X509_STORE_CTX_set_cert,
Packit c4476c
X509_STORE_CTX_set0_crls,
Packit c4476c
X509_STORE_CTX_get0_chain, X509_STORE_CTX_set0_verified_chain,
Packit c4476c
X509_STORE_CTX_get0_param, X509_STORE_CTX_set0_param,
Packit c4476c
X509_STORE_CTX_get0_untrusted, X509_STORE_CTX_set0_untrusted,
Packit c4476c
X509_STORE_CTX_get_num_untrusted,
Packit c4476c
X509_STORE_CTX_set_default,
Packit c4476c
X509_STORE_CTX_set_verify,
Packit c4476c
X509_STORE_CTX_verify_fn
Packit c4476c
- X509_STORE_CTX initialisation
Packit c4476c
Packit c4476c
=head1 SYNOPSIS
Packit c4476c
Packit c4476c
 #include <openssl/x509_vfy.h>
Packit c4476c
Packit c4476c
 X509_STORE_CTX *X509_STORE_CTX_new(void);
Packit c4476c
 void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx);
Packit c4476c
 void X509_STORE_CTX_free(X509_STORE_CTX *ctx);
Packit c4476c
Packit c4476c
 int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store,
Packit c4476c
                         X509 *x509, STACK_OF(X509) *chain);
Packit c4476c
Packit c4476c
 void X509_STORE_CTX_set0_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk);
Packit c4476c
Packit c4476c
 void X509_STORE_CTX_set_cert(X509_STORE_CTX *ctx, X509 *x);
Packit c4476c
 STACK_OF(X509) *X509_STORE_CTX_get0_chain(X509_STORE_CTX *ctx);
Packit c4476c
 void X509_STORE_CTX_set0_verified_chain(X509_STORE_CTX *ctx, STACK_OF(X509) *chain);
Packit c4476c
 void X509_STORE_CTX_set0_crls(X509_STORE_CTX *ctx, STACK_OF(X509_CRL) *sk);
Packit c4476c
Packit c4476c
 X509_VERIFY_PARAM *X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx);
Packit c4476c
 void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param);
Packit c4476c
 int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name);
Packit c4476c
Packit c4476c
 STACK_OF(X509)* X509_STORE_CTX_get0_untrusted(X509_STORE_CTX *ctx);
Packit c4476c
 void X509_STORE_CTX_set0_untrusted(X509_STORE_CTX *ctx, STACK_OF(X509) *sk);
Packit c4476c
Packit c4476c
 int X509_STORE_CTX_get_num_untrusted(X509_STORE_CTX *ctx);
Packit c4476c
Packit c4476c
 typedef int (*X509_STORE_CTX_verify_fn)(X509_STORE_CTX *);
Packit c4476c
 void X509_STORE_CTX_set_verify(X509_STORE_CTX *ctx, X509_STORE_CTX_verify_fn verify);
Packit c4476c
Packit c4476c
=head1 DESCRIPTION
Packit c4476c
Packit c4476c
These functions initialise an B<X509_STORE_CTX> structure for subsequent use
Packit c4476c
by X509_verify_cert().
Packit c4476c
Packit c4476c
X509_STORE_CTX_new() returns a newly initialised B<X509_STORE_CTX> structure.
Packit c4476c
Packit c4476c
X509_STORE_CTX_cleanup() internally cleans up an B<X509_STORE_CTX> structure.
Packit c4476c
The context can then be reused with an new call to X509_STORE_CTX_init().
Packit c4476c
Packit c4476c
X509_STORE_CTX_free() completely frees up B<ctx>. After this call B<ctx>
Packit c4476c
is no longer valid.
Packit c4476c
If B<ctx> is NULL nothing is done.
Packit c4476c
Packit c4476c
X509_STORE_CTX_init() sets up B<ctx> for a subsequent verification operation.
Packit c4476c
It must be called before each call to X509_verify_cert(), i.e. a B<ctx> is only
Packit c4476c
good for one call to X509_verify_cert(); if you want to verify a second
Packit c4476c
certificate with the same B<ctx> then you must call X509_STORE_CTX_cleanup()
Packit c4476c
and then X509_STORE_CTX_init() again before the second call to
Packit c4476c
X509_verify_cert(). The trusted certificate store is set to B<store>, the end
Packit c4476c
entity certificate to be verified is set to B<x509> and a set of additional
Packit c4476c
certificates (which will be untrusted but may be used to build the chain) in
Packit c4476c
B<chain>. Any or all of the B<store>, B<x509> and B<chain> parameters can be
Packit c4476c
B<NULL>.
Packit c4476c
Packit c4476c
X509_STORE_CTX_set0_trusted_stack() sets the set of trusted certificates of
Packit c4476c
B<ctx> to B<sk>. This is an alternative way of specifying trusted certificates
Packit c4476c
instead of using an B<X509_STORE>.
Packit c4476c
Packit c4476c
X509_STORE_CTX_set_cert() sets the certificate to be verified in B<ctx> to
Packit c4476c
B<x>.
Packit c4476c
Packit c4476c
X509_STORE_CTX_set0_verified_chain() sets the validated chain used
Packit c4476c
by B<ctx> to be B<chain>.
Packit c4476c
Ownership of the chain is transferred to B<ctx> and should not be
Packit c4476c
free'd by the caller.
Packit c4476c
X509_STORE_CTX_get0_chain() returns a the internal pointer used by the
Packit c4476c
B<ctx> that contains the validated chain.
Packit c4476c
Packit c4476c
X509_STORE_CTX_set0_crls() sets a set of CRLs to use to aid certificate
Packit c4476c
verification to B<sk>. These CRLs will only be used if CRL verification is
Packit c4476c
enabled in the associated B<X509_VERIFY_PARAM> structure. This might be
Packit c4476c
used where additional "useful" CRLs are supplied as part of a protocol,
Packit c4476c
for example in a PKCS#7 structure.
Packit c4476c
Packit c4476c
X509_STORE_CTX_get0_param() retrieves an internal pointer
Packit c4476c
to the verification parameters associated with B<ctx>.
Packit c4476c
Packit c4476c
X509_STORE_CTX_get0_untrusted() retrieves an internal pointer to the
Packit c4476c
stack of untrusted certificates associated with B<ctx>.
Packit c4476c
Packit c4476c
X509_STORE_CTX_set0_untrusted() sets the internal point to the stack
Packit c4476c
of untrusted certificates associated with B<ctx> to B<sk>.
Packit c4476c
Packit c4476c
X509_STORE_CTX_set0_param() sets the internal verification parameter pointer
Packit c4476c
to B<param>. After this call B<param> should not be used.
Packit c4476c
Packit c4476c
X509_STORE_CTX_set_default() looks up and sets the default verification
Packit c4476c
method to B<name>. This uses the function X509_VERIFY_PARAM_lookup() to
Packit c4476c
find an appropriate set of parameters from B<name>.
Packit c4476c
Packit c4476c
X509_STORE_CTX_get_num_untrusted() returns the number of untrusted certificates
Packit c4476c
that were used in building the chain following a call to X509_verify_cert().
Packit c4476c
Packit c4476c
X509_STORE_CTX_set_verify() provides the capability for overriding the default
Packit c4476c
verify function. This function is responsible for verifying chain signatures and
Packit c4476c
expiration times.
Packit c4476c
Packit c4476c
A verify function is defined as an X509_STORE_CTX_verify type which has the
Packit c4476c
following signature:
Packit c4476c
Packit c4476c
 int (*verify)(X509_STORE_CTX *);
Packit c4476c
Packit c4476c
This function should receive the current X509_STORE_CTX as a parameter and
Packit c4476c
return 1 on success or 0 on failure.
Packit c4476c
Packit c4476c
=head1 NOTES
Packit c4476c
Packit c4476c
The certificates and CRLs in a store are used internally and should B<not>
Packit c4476c
be freed up until after the associated B<X509_STORE_CTX> is freed.
Packit c4476c
Packit c4476c
=head1 BUGS
Packit c4476c
Packit c4476c
The certificates and CRLs in a context are used internally and should B<not>
Packit c4476c
be freed up until after the associated B<X509_STORE_CTX> is freed. Copies
Packit c4476c
should be made or reference counts increased instead.
Packit c4476c
Packit c4476c
=head1 RETURN VALUES
Packit c4476c
Packit c4476c
X509_STORE_CTX_new() returns an newly allocates context or B<NULL> is an
Packit c4476c
error occurred.
Packit c4476c
Packit c4476c
X509_STORE_CTX_init() returns 1 for success or 0 if an error occurred.
Packit c4476c
Packit c4476c
X509_STORE_CTX_get0_param() returns a pointer to an B<X509_VERIFY_PARAM>
Packit c4476c
structure or B<NULL> if an error occurred.
Packit c4476c
Packit c4476c
X509_STORE_CTX_cleanup(), X509_STORE_CTX_free(),
Packit c4476c
X509_STORE_CTX_set0_trusted_stack(),
Packit c4476c
X509_STORE_CTX_set_cert(),
Packit c4476c
X509_STORE_CTX_set0_crls() and X509_STORE_CTX_set0_param() do not return
Packit c4476c
values.
Packit c4476c
Packit c4476c
X509_STORE_CTX_set_default() returns 1 for success or 0 if an error occurred.
Packit c4476c
Packit c4476c
X509_STORE_CTX_get_num_untrusted() returns the number of untrusted certificates
Packit c4476c
used.
Packit c4476c
Packit c4476c
=head1 SEE ALSO
Packit c4476c
Packit c4476c
L<X509_verify_cert(3)>
Packit c4476c
L<X509_VERIFY_PARAM_set_flags(3)>
Packit c4476c
Packit c4476c
=head1 HISTORY
Packit c4476c
Packit c4476c
The X509_STORE_CTX_set0_crls() function was added in OpenSSL 1.0.0.
Packit c4476c
The X509_STORE_CTX_get_num_untrusted() function was added in OpenSSL 1.1.0.
Packit c4476c
Packit c4476c
=head1 COPYRIGHT
Packit c4476c
Packit c4476c
Copyright 2009-2016 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