1SSL_CTX_ADD1_CHAIN_CERT(3ossl)      OpenSSL     SSL_CTX_ADD1_CHAIN_CERT(3ossl)
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.  Details of the
67       chain building process are described in "Certification Path Building"
68       in openssl-verification-options(1).
69
70       Each of these functions operates on the current end entity (i.e. server
71       or client) certificate. This is the last certificate loaded or selected
72       on the corresponding ctx structure.
73
74       SSL_CTX_select_current_cert() selects x509 as the current end entity
75       certificate, but only if x509 has already been loaded into ctx using a
76       function such as SSL_CTX_use_certificate().
77
78       SSL_set0_chain(), SSL_set1_chain(), SSL_add0_chain_cert(),
79       SSL_add1_chain_cert(), SSL_get0_chain_certs(), SSL_clear_chain_certs(),
80       SSL_build_cert_chain(), SSL_select_current_cert() and
81       SSL_set_current_cert() are similar except they apply to SSL structure
82       ssl.
83
84       SSL_CTX_set_current_cert() changes the current certificate to a value
85       based on the op argument. Currently op can be SSL_CERT_SET_FIRST to use
86       the first valid certificate or SSL_CERT_SET_NEXT to set the next valid
87       certificate after the current certificate. These two operations can be
88       used to iterate over all certificates in an SSL_CTX structure.
89
90       SSL_set_current_cert() also supports the option SSL_CERT_SET_SERVER.
91       If ssl is a server and has sent a certificate to a connected client
92       this option sets that certificate to the current certificate and
93       returns 1.  If the negotiated cipher suite is anonymous (and thus no
94       certificate will be sent) 2 is returned and the current certificate is
95       unchanged. If ssl is not a server or a certificate has not been sent 0
96       is returned and the current certificate is unchanged.
97
98       All these functions are implemented as macros. Those containing a 1
99       increment the reference count of the supplied certificate or chain so
100       it must be freed at some point after the operation. Those containing a
101       0 do not increment reference counts and the supplied certificate or
102       chain MUST NOT be freed after the operation.
103

NOTES

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

RETURN VALUES

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

SEE ALSO

148       ssl(7), SSL_CTX_add_extra_chain_cert(3)
149

HISTORY

151       These functions were added in OpenSSL 1.0.2.
152
154       Copyright 2013-2021 The OpenSSL Project Authors. All Rights Reserved.
155
156       Licensed under the Apache License 2.0 (the "License").  You may not use
157       this file except in compliance with the License.  You can obtain a copy
158       in the file LICENSE in the source distribution or at
159       <https://www.openssl.org/source/license.html>.
160
161
162
1633.0.5                             2022-11-01    SSL_CTX_ADD1_CHAIN_CERT(3ossl)
Impressum