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