Blame doc/man3/SSL_CTX_add1_chain_cert.pod

Packit Service 084de1
=pod
Packit Service 084de1
Packit Service 084de1
=head1 NAME
Packit Service 084de1
Packit Service 084de1
SSL_CTX_set0_chain, SSL_CTX_set1_chain, SSL_CTX_add0_chain_cert,
Packit Service 084de1
SSL_CTX_add1_chain_cert, SSL_CTX_get0_chain_certs, SSL_CTX_clear_chain_certs,
Packit Service 084de1
SSL_set0_chain, SSL_set1_chain, SSL_add0_chain_cert, SSL_add1_chain_cert,
Packit Service 084de1
SSL_get0_chain_certs, SSL_clear_chain_certs, SSL_CTX_build_cert_chain,
Packit Service 084de1
SSL_build_cert_chain, SSL_CTX_select_current_cert,
Packit Service 084de1
SSL_select_current_cert, SSL_CTX_set_current_cert, SSL_set_current_cert - extra
Packit Service 084de1
chain certificate processing
Packit Service 084de1
Packit Service 084de1
=head1 SYNOPSIS
Packit Service 084de1
Packit Service 084de1
 #include <openssl/ssl.h>
Packit Service 084de1
Packit Service 084de1
 int SSL_CTX_set0_chain(SSL_CTX *ctx, STACK_OF(X509) *sk);
Packit Service 084de1
 int SSL_CTX_set1_chain(SSL_CTX *ctx, STACK_OF(X509) *sk);
Packit Service 084de1
 int SSL_CTX_add0_chain_cert(SSL_CTX *ctx, X509 *x509);
Packit Service 084de1
 int SSL_CTX_add1_chain_cert(SSL_CTX *ctx, X509 *x509);
Packit Service 084de1
 int SSL_CTX_get0_chain_certs(SSL_CTX *ctx, STACK_OF(X509) **sk);
Packit Service 084de1
 int SSL_CTX_clear_chain_certs(SSL_CTX *ctx);
Packit Service 084de1
Packit Service 084de1
 int SSL_set0_chain(SSL *ssl, STACK_OF(X509) *sk);
Packit Service 084de1
 int SSL_set1_chain(SSL *ssl, STACK_OF(X509) *sk);
Packit Service 084de1
 int SSL_add0_chain_cert(SSL *ssl, X509 *x509);
Packit Service 084de1
 int SSL_add1_chain_cert(SSL *ssl, X509 *x509);
Packit Service 084de1
 int SSL_get0_chain_certs(SSL *ssl, STACK_OF(X509) **sk);
Packit Service 084de1
 int SSL_clear_chain_certs(SSL *ssl);
Packit Service 084de1
Packit Service 084de1
 int SSL_CTX_build_cert_chain(SSL_CTX *ctx, flags);
Packit Service 084de1
 int SSL_build_cert_chain(SSL *ssl, flags);
Packit Service 084de1
Packit Service 084de1
 int SSL_CTX_select_current_cert(SSL_CTX *ctx, X509 *x509);
Packit Service 084de1
 int SSL_select_current_cert(SSL *ssl, X509 *x509);
Packit Service 084de1
 int SSL_CTX_set_current_cert(SSL_CTX *ctx, long op);
Packit Service 084de1
 int SSL_set_current_cert(SSL *ssl, long op);
Packit Service 084de1
Packit Service 084de1
=head1 DESCRIPTION
Packit Service 084de1
Packit Service 084de1
SSL_CTX_set0_chain() and SSL_CTX_set1_chain() set the certificate chain
Packit Service 084de1
associated with the current certificate of B<ctx> to B<sk>.
Packit Service 084de1
Packit Service 084de1
SSL_CTX_add0_chain_cert() and SSL_CTX_add1_chain_cert() append the single
Packit Service 084de1
certificate B<x509> to the chain associated with the current certificate of
Packit Service 084de1
B<ctx>.
Packit Service 084de1
Packit Service 084de1
SSL_CTX_get0_chain_certs() retrieves the chain associated with the current
Packit Service 084de1
certificate of B<ctx>.
Packit Service 084de1
Packit Service 084de1
SSL_CTX_clear_chain_certs() clears any existing chain associated with the
Packit Service 084de1
current certificate of B<ctx>.  (This is implemented by calling
Packit Service 084de1
SSL_CTX_set0_chain() with B<sk> set to B<NULL>).
Packit Service 084de1
Packit Service 084de1
SSL_CTX_build_cert_chain() builds the certificate chain for B<ctx> normally
Packit Service 084de1
this uses the chain store or the verify store if the chain store is not set.
Packit Service 084de1
If the function is successful the built chain will replace any existing chain.
Packit Service 084de1
The B<flags> parameter can be set to B<SSL_BUILD_CHAIN_FLAG_UNTRUSTED> to use
Packit Service 084de1
existing chain certificates as untrusted CAs, B<SSL_BUILD_CHAIN_FLAG_NO_ROOT>
Packit Service 084de1
to omit the root CA from the built chain, B<SSL_BUILD_CHAIN_FLAG_CHECK> to
Packit Service 084de1
use all existing chain certificates only to build the chain (effectively
Packit Service 084de1
sanity checking and rearranging them if necessary), the flag
Packit Service 084de1
B<SSL_BUILD_CHAIN_FLAG_IGNORE_ERROR> ignores any errors during verification:
Packit Service 084de1
if flag B<SSL_BUILD_CHAIN_FLAG_CLEAR_ERROR> is also set verification errors
Packit Service 084de1
are cleared from the error queue.
Packit Service 084de1
Packit Service 084de1
Each of these functions operates on the I<current> end entity
Packit Service 084de1
(i.e. server or client) certificate. This is the last certificate loaded or
Packit Service 084de1
selected on the corresponding B<ctx> structure.
Packit Service 084de1
Packit Service 084de1
SSL_CTX_select_current_cert() selects B<x509> as the current end entity
Packit Service 084de1
certificate, but only if B<x509> has already been loaded into B<ctx> using a
Packit Service 084de1
function such as SSL_CTX_use_certificate().
Packit Service 084de1
Packit Service 084de1
SSL_set0_chain(), SSL_set1_chain(), SSL_add0_chain_cert(),
Packit Service 084de1
SSL_add1_chain_cert(), SSL_get0_chain_certs(), SSL_clear_chain_certs(),
Packit Service 084de1
SSL_build_cert_chain(), SSL_select_current_cert() and SSL_set_current_cert()
Packit Service 084de1
are similar except they apply to SSL structure B<ssl>.
Packit Service 084de1
Packit Service 084de1
SSL_CTX_set_current_cert() changes the current certificate to a value based
Packit Service 084de1
on the B<op> argument. Currently B<op> can be B<SSL_CERT_SET_FIRST> to use
Packit Service 084de1
the first valid certificate or B<SSL_CERT_SET_NEXT> to set the next valid
Packit Service 084de1
certificate after the current certificate. These two operations can be
Packit Service 084de1
used to iterate over all certificates in an B<SSL_CTX> structure.
Packit Service 084de1
Packit Service 084de1
SSL_set_current_cert() also supports the option B<SSL_CERT_SET_SERVER>.
Packit Service 084de1
If B<ssl> is a server and has sent a certificate to a connected client
Packit Service 084de1
this option sets that certificate to the current certificate and returns 1.
Packit Service 084de1
If the negotiated cipher suite is anonymous (and thus no certificate will
Packit Service 084de1
be sent) 2 is returned and the current certificate is unchanged. If B<ssl>
Packit Service 084de1
is not a server or a certificate has not been sent 0 is returned and
Packit Service 084de1
the current certificate is unchanged.
Packit Service 084de1
Packit Service 084de1
All these functions are implemented as macros. Those containing a B<1>
Packit Service 084de1
increment the reference count of the supplied certificate or chain so it must
Packit Service 084de1
be freed at some point after the operation. Those containing a B<0> do
Packit Service 084de1
not increment reference counts and the supplied certificate or chain
Packit Service 084de1
B<MUST NOT> be freed after the operation.
Packit Service 084de1
Packit Service 084de1
=head1 NOTES
Packit Service 084de1
Packit Service 084de1
The chains associate with an SSL_CTX structure are copied to any SSL
Packit Service 084de1
structures when SSL_new() is called. SSL structures will not be affected
Packit Service 084de1
by any chains subsequently changed in the parent SSL_CTX.
Packit Service 084de1
Packit Service 084de1
One chain can be set for each key type supported by a server. So, for example,
Packit Service 084de1
an RSA and a DSA certificate can (and often will) have different chains.
Packit Service 084de1
Packit Service 084de1
The functions SSL_CTX_build_cert_chain() and SSL_build_cert_chain() can
Packit Service 084de1
be used to check application configuration and to ensure any necessary
Packit Service 084de1
subordinate CAs are sent in the correct order. Misconfigured applications
Packit Service 084de1
sending incorrect certificate chains often cause problems with peers.
Packit Service 084de1
Packit Service 084de1
For example an application can add any set of certificates using
Packit Service 084de1
SSL_CTX_use_certificate_chain_file() then call SSL_CTX_build_cert_chain()
Packit Service 084de1
with the option B<SSL_BUILD_CHAIN_FLAG_CHECK> to check and reorder them.
Packit Service 084de1
Packit Service 084de1
Applications can issue non fatal warnings when checking chains by setting
Packit Service 084de1
the flag B<SSL_BUILD_CHAIN_FLAG_IGNORE_ERRORS> and checking the return
Packit Service 084de1
value.
Packit Service 084de1
Packit Service 084de1
Calling SSL_CTX_build_cert_chain() or SSL_build_cert_chain() is more
Packit Service 084de1
efficient than the automatic chain building as it is only performed once.
Packit Service 084de1
Automatic chain building is performed on each new session.
Packit Service 084de1
Packit Service 084de1
If any certificates are added using these functions no certificates added
Packit Service 084de1
using SSL_CTX_add_extra_chain_cert() will be used.
Packit Service 084de1
Packit Service 084de1
=head1 RETURN VALUES
Packit Service 084de1
Packit Service 084de1
SSL_set_current_cert() with B<SSL_CERT_SET_SERVER> return 1 for success, 2 if
Packit Service 084de1
no server certificate is used because the cipher suites is anonymous and 0
Packit Service 084de1
for failure.
Packit Service 084de1
Packit Service 084de1
SSL_CTX_build_cert_chain() and SSL_build_cert_chain() return 1 for success
Packit Service 084de1
and 0 for failure. If the flag B<SSL_BUILD_CHAIN_FLAG_IGNORE_ERROR> and
Packit Service 084de1
a verification error occurs then 2 is returned.
Packit Service 084de1
Packit Service 084de1
All other functions return 1 for success and 0 for failure.
Packit Service 084de1
Packit Service 084de1
=head1 SEE ALSO
Packit Service 084de1
Packit Service 084de1
L<SSL_CTX_add_extra_chain_cert(3)>
Packit Service 084de1
Packit Service 084de1
=head1 HISTORY
Packit Service 084de1
Packit Service 084de1
These functions were added in OpenSSL 1.0.2.
Packit Service 084de1
Packit Service 084de1
=head1 COPYRIGHT
Packit Service 084de1
Packit Service 084de1
Copyright 2013-2016 The OpenSSL Project Authors. All Rights Reserved.
Packit Service 084de1
Packit Service 084de1
Licensed under the OpenSSL license (the "License").  You may not use
Packit Service 084de1
this file except in compliance with the License.  You can obtain a copy
Packit Service 084de1
in the file LICENSE in the source distribution or at
Packit Service 084de1
L<https://www.openssl.org/source/license.html>.
Packit Service 084de1
Packit Service 084de1
=cut