1SSL_CTX_ADD1_CHAIN_CERT(3)          OpenSSL         SSL_CTX_ADD1_CHAIN_CERT(3)
2
3
4

NAME

6       SSL_CTX_set0_chain, SSL_CTX_set1_chain, SSL_CTX_add0_chain_cert,
7       SSL_CTX_add1_chain_cert, SSL_CTX_get0_chain_certs,
8       SSL_CTX_clear_chain_certs, SSL_set0_chain, SSL_set1_chain,
9       SSL_add0_chain_cert, SSL_add1_chain_cert, SSL_get0_chain_certs,
10       SSL_clear_chain_certs, SSL_CTX_build_cert_chain, SSL_build_cert_chain,
11       SSL_CTX_select_current_cert, SSL_select_current_cert,
12       SSL_CTX_set_current_cert, SSL_set_current_cert - extra chain
13       certificate processing
14

SYNOPSIS

16        #include <openssl/ssl.h>
17
18        int SSL_CTX_set0_chain(SSL_CTX *ctx, STACK_OF(X509) *sk);
19        int SSL_CTX_set1_chain(SSL_CTX *ctx, STACK_OF(X509) *sk);
20        int SSL_CTX_add0_chain_cert(SSL_CTX *ctx, X509 *x509);
21        int SSL_CTX_add1_chain_cert(SSL_CTX *ctx, X509 *x509);
22        int SSL_CTX_get0_chain_certs(SSL_CTX *ctx, STACK_OF(X509) **sk);
23        int SSL_CTX_clear_chain_certs(SSL_CTX *ctx);
24
25        int SSL_set0_chain(SSL *ssl, STACK_OF(X509) *sk);
26        int SSL_set1_chain(SSL *ssl, STACK_OF(X509) *sk);
27        int SSL_add0_chain_cert(SSL *ssl, X509 *x509);
28        int SSL_add1_chain_cert(SSL *ssl, X509 *x509);
29        int SSL_get0_chain_certs(SSL *ssl, STACK_OF(X509) **sk);
30        int SSL_clear_chain_certs(SSL *ssl);
31
32        int SSL_CTX_build_cert_chain(SSL_CTX *ctx, flags);
33        int SSL_build_cert_chain(SSL *ssl, flags);
34
35        int SSL_CTX_select_current_cert(SSL_CTX *ctx, X509 *x509);
36        int SSL_select_current_cert(SSL *ssl, X509 *x509);
37        int SSL_CTX_set_current_cert(SSL_CTX *ctx, long op);
38        int SSL_set_current_cert(SSL *ssl, long op);
39

DESCRIPTION

41       SSL_CTX_set0_chain() and SSL_CTX_set1_chain() set the certificate chain
42       associated with the current certificate of ctx to sk.
43
44       SSL_CTX_add0_chain_cert() and SSL_CTX_add1_chain_cert() append the
45       single certificate x509 to the chain associated with the current
46       certificate of ctx.
47
48       SSL_CTX_get0_chain_certs() retrieves the chain associated with the
49       current certificate of ctx.
50
51       SSL_CTX_clear_chain_certs() clears any existing chain associated with
52       the current certificate of ctx.  (This is implemented by calling
53       SSL_CTX_set0_chain() with sk set to NULL).
54
55       SSL_CTX_build_cert_chain() builds the certificate chain for ctx
56       normally this uses the chain store or the verify store if the chain
57       store is not set.  If the function is successful the built chain will
58       replace any existing chain.  The flags parameter can be set to
59       SSL_BUILD_CHAIN_FLAG_UNTRUSTED to use existing chain certificates as
60       untrusted CAs, SSL_BUILD_CHAIN_FLAG_NO_ROOT to omit the root CA from
61       the built chain, SSL_BUILD_CHAIN_FLAG_CHECK to use all existing chain
62       certificates only to build the chain (effectively sanity checking and
63       rearranging them if necessary), the flag
64       SSL_BUILD_CHAIN_FLAG_IGNORE_ERROR ignores any errors during
65       verification: if flag SSL_BUILD_CHAIN_FLAG_CLEAR_ERROR is also set
66       verification errors are cleared from the error queue.
67
68       Each of these functions operates on the current end entity (i.e. server
69       or client) certificate. This is the last certificate loaded or selected
70       on the corresponding ctx structure.
71
72       SSL_CTX_select_current_cert() selects x509 as the current end entity
73       certificate, but only if x509 has already been loaded into ctx using a
74       function such as SSL_CTX_use_certificate().
75
76       SSL_set0_chain(), SSL_set1_chain(), SSL_add0_chain_cert(),
77       SSL_add1_chain_cert(), SSL_get0_chain_certs(), SSL_clear_chain_certs(),
78       SSL_build_cert_chain(), SSL_select_current_cert() and
79       SSL_set_current_cert() are similar except they apply to SSL structure
80       ssl.
81
82       SSL_CTX_set_current_cert() changes the current certificate to a value
83       based on the op argument. Currently op can be SSL_CERT_SET_FIRST to use
84       the first valid certificate or SSL_CERT_SET_NEXT to set the next valid
85       certificate after the current certificate. These two operations can be
86       used to iterate over all certificates in an SSL_CTX structure.
87
88       SSL_set_current_cert() also supports the option SSL_CERT_SET_SERVER.
89       If ssl is a server and has sent a certificate to a connected client
90       this option sets that certificate to the current certificate and
91       returns 1.  If the negotiated cipher suite is anonymous (and thus no
92       certificate will be sent) 2 is returned and the current certificate is
93       unchanged. If ssl is not a server or a certificate has not been sent 0
94       is returned and the current certificate is unchanged.
95
96       All these functions are implemented as macros. Those containing a 1
97       increment the reference count of the supplied certificate or chain so
98       it must be freed at some point after the operation. Those containing a
99       0 do not increment reference counts and the supplied certificate or
100       chain MUST NOT be freed after the operation.
101

NOTES

103       The chains associate with an SSL_CTX structure are copied to any SSL
104       structures when SSL_new() is called. SSL structures will not be
105       affected by any chains subsequently changed in the parent SSL_CTX.
106
107       One chain can be set for each key type supported by a server. So, for
108       example, an RSA and a DSA certificate can (and often will) have
109       different chains.
110
111       The functions SSL_CTX_build_cert_chain() and SSL_build_cert_chain() can
112       be used to check application configuration and to ensure any necessary
113       subordinate CAs are sent in the correct order. Misconfigured
114       applications sending incorrect certificate chains often cause problems
115       with peers.
116
117       For example an application can add any set of certificates using
118       SSL_CTX_use_certificate_chain_file() then call
119       SSL_CTX_build_cert_chain() with the option SSL_BUILD_CHAIN_FLAG_CHECK
120       to check and reorder them.
121
122       Applications can issue non fatal warnings when checking chains by
123       setting the flag SSL_BUILD_CHAIN_FLAG_IGNORE_ERRORS and checking the
124       return value.
125
126       Calling SSL_CTX_build_cert_chain() or SSL_build_cert_chain() is more
127       efficient than the automatic chain building as it is only performed
128       once.  Automatic chain building is performed on each new session.
129
130       If any certificates are added using these functions no certificates
131       added using SSL_CTX_add_extra_chain_cert() will be used.
132

RETURN VALUES

134       SSL_set_current_cert() with SSL_CERT_SET_SERVER return 1 for success, 2
135       if no server certificate is used because the cipher suites is anonymous
136       and 0 for failure.
137
138       SSL_CTX_build_cert_chain() and SSL_build_cert_chain() return 1 for
139       success and 0 for failure. If the flag
140       SSL_BUILD_CHAIN_FLAG_IGNORE_ERROR and a verification error occurs then
141       2 is returned.
142
143       All other functions return 1 for success and 0 for failure.
144

SEE ALSO

146       SSL_CTX_add_extra_chain_cert(3)
147

HISTORY

149       These functions were added in OpenSSL 1.0.2.
150
152       Copyright 2013-2016 The OpenSSL Project Authors. All Rights Reserved.
153
154       Licensed under the OpenSSL license (the "License").  You may not use
155       this file except in compliance with the License.  You can obtain a copy
156       in the file LICENSE in the source distribution or at
157       <https://www.openssl.org/source/license.html>.
158
159
160
1611.1.1q                            2022-07-21        SSL_CTX_ADD1_CHAIN_CERT(3)
Impressum