2d2161ae96b7d02015e2424f4cf63d105840a0ba
[openssl.git] / doc / ssl / SSL_CTX_add1_chain_cert.pod
1 =pod
2
3 =head1 NAME
4
5 SSL_CTX_set0_chain, SSL_CTX_set1_chain, SSL_CTX_add0_chain_cert,
6 SSL_CTX_add1_chain_cert, SSL_CTX_get0_chain_certs, SSL_CTX_clear_chain_certs,
7 SSL_set0_chain, SSL_set1_chain, SSL_add0_chain_cert, SSL_add1_chain_cert,
8 SSL_get0_chain_certs, SSL_clear_chain_certs, SSL_CTX_build_cert_chain,
9 SSL_build_cert_chain, SSL_CTX_select_current_cert,
10 SSL_select_current_cert - extra chain certificate processing
11
12 =head1 SYNOPSIS
13
14  #include <openssl/ssl.h>
15
16  int SSL_CTX_set0_chain(SSL_CTX *ctx, STACK_OF(X509) *sk);
17  int SSL_CTX_set1_chain(SSL_CTX *ctx, STACK_OF(X509) *sk);
18  int SSL_CTX_add0_chain_cert(SSL_CTX *ctx, X509 *x509);
19  int SSL_CTX_add1_chain_cert(SSL_CTX *ctx, X509 *x509);
20  int SSL_CTX_get0_chain_certs(SSL_CTX *ctx, STACK_OF(X509) **sk);
21  int SSL_CTX_clear_chain_certs(SSL_CTX *ctx);
22
23  int SSL_set0_chain(SSL *ssl, STACK_OF(X509) *sk);
24  int SSL_set1_chain(SSL *ssl, STACK_OF(X509) *sk);
25  int SSL_add0_chain_cert(SSL *ssl, X509 *x509);
26  int SSL_add1_chain_cert(SSL *ssl, X509 *x509);
27  int SSL_get0_chain_certs(SSL *ssl, STACK_OF(X509) **sk);
28  int SSL_clear_chain_certs(SSL *ssl);
29
30  int SSL_CTX_build_cert_chain(SSL_CTX *ctx, flags);
31  int SSL_build_cert_chain(SSL *ssl, flags);
32
33  int SSL_CTX_select_current_cert(SSL_CTX *ctx, X509 *x509);
34  int SSL_select_current_cert(SSL *ssl, X509 *x509);
35
36 =head1 DESCRIPTION
37
38 SSL_CTX_set0_chain() and SSL_CTX_set1_chain() set the certificate chain
39 associated with the current certificate of B<ctx> to B<sk>.
40
41 SSL_CTX_add0_chain_cert() and SSL_CTX_add1_chain_cert() append the single
42 certificate B<x509> to the chain associated with the current certificate of
43 B<ctx>.
44
45 SSL_CTX_get0_chain_certs() retrieves the chain associated with the current
46 certificate of B<ctx>.
47
48 SSL_CTX_clear_chain_certs() clears any existing chain associated with the
49 current certificate of B<ctx>.  (This is implemented by calling
50 SSL_CTX_set0_chain() with B<sk> set to B<NULL>).
51
52 SSL_CTX_build_cert_chain() builds the certificate chain for B<ctx> using the
53 chain store. Any existing chain certificates are used as untrusted CAs.
54 If the function is successful the built chain will replace any existing chain.
55 The B<flags> parameter can be set to B<SSL_BUILD_CHAIN_FLAG_NO_ROOT> to omit
56 the root CA from the built chain.
57
58 Each of these functions operates on the I<current> end entity
59 (i.e. server or client) certificate. This is the last certificate loaded or
60 selected on the corresponding B<ctx> structure.
61
62 SSL_CTX_select_current_cert() selects B<x509> as the current end entity
63 certificate, but only if B<x509> has already been loaded into B<ctx> using a
64 function such as SSL_CTX_use_certificate().
65
66 SSL_set0_chain(), SSL_set1_chain(), SSL_add0_chain_cert(),
67 SSL_add1_chain_cert(), SSL_get0_chain_certs(), SSL_clear_chain_certs(),
68 SSL_build_cert_chain() and SSL_select_current_cert() are similar except they
69 apply to SSL structure B<ssl>.
70
71 All these functions are implemented as macros. Those containing a B<1>
72 increment the reference count of the supplied certificate or chain so it must
73 be freed at some point after the operation. Those containing a B<0> do
74 not increment reference counts and the supplied certificate or chain
75 B<MUST NOT> be freed after the operation.
76
77 =head1 NOTES
78
79 The chains associate with an SSL_CTX structure are copied to any SSL
80 structures when SSL_new() is called. SSL structures will not be affected
81 by any chains subsequently changed in the parent SSL_CTX.
82
83 One chain can be set for each key type supported by a server. So, for example,
84 an RSA and a DSA certificate can (and often will) have different chains.
85
86 The functions SSL_CTX_build_cert_chain() and SSL_build_cert_chain() can
87 be used to check application configuration and to ensure any necessary
88 subordinate CAs are sent in the correct order. Misconfigured applications
89 sending incorrect certificate chains often cause problems with peers.
90
91 Calling SSL_CTX_build_cert_chain() or SSL_build_cert_chain() is more
92 efficient than the automatic chain building as it is only performed once.
93 Automatic chain building is performed on each new session.
94
95 If any certificates are added using these functions no certificates added
96 using SSL_CTX_add_extra_chain_cert() will be used.
97
98 =head1 RETURN VALUES
99
100 All these functions return 1 for success and 0 for failure.
101
102 =head1 SEE ALSO
103
104 L<SSL_CTX_add_extra_chain_cert(3)|SSL_CTX_add_extra_chain_cert(3)>
105
106 =head1 HISTORY
107
108 These functions were first added to OpenSSL 1.0.2.
109
110 =cut