1*de980744Stb.\" $OpenBSD: SSL_CTX_add_extra_chain_cert.3,v 1.8 2025/01/18 10:45:12 tb Exp $
23d842696Sschwarze.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3f1a3c524Sschwarze.\"
4dfc30437Sschwarze.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org> and
5dfc30437Sschwarze.\" Dr. Stephen Henson <steve@openssl.org>.
6dfc30437Sschwarze.\" Copyright (c) 2000, 2002, 2013, 2015 The OpenSSL Project.
7dfc30437Sschwarze.\" All rights reserved.
8f1a3c524Sschwarze.\"
9dfc30437Sschwarze.\" Redistribution and use in source and binary forms, with or without
10dfc30437Sschwarze.\" modification, are permitted provided that the following conditions
11dfc30437Sschwarze.\" are met:
12dfc30437Sschwarze.\"
13dfc30437Sschwarze.\" 1. Redistributions of source code must retain the above copyright
14dfc30437Sschwarze.\"    notice, this list of conditions and the following disclaimer.
15dfc30437Sschwarze.\"
16dfc30437Sschwarze.\" 2. Redistributions in binary form must reproduce the above copyright
17dfc30437Sschwarze.\"    notice, this list of conditions and the following disclaimer in
18dfc30437Sschwarze.\"    the documentation and/or other materials provided with the
19dfc30437Sschwarze.\"    distribution.
20dfc30437Sschwarze.\"
21dfc30437Sschwarze.\" 3. All advertising materials mentioning features or use of this
22dfc30437Sschwarze.\"    software must display the following acknowledgment:
23dfc30437Sschwarze.\"    "This product includes software developed by the OpenSSL Project
24dfc30437Sschwarze.\"    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25dfc30437Sschwarze.\"
26dfc30437Sschwarze.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27dfc30437Sschwarze.\"    endorse or promote products derived from this software without
28dfc30437Sschwarze.\"    prior written permission. For written permission, please contact
29dfc30437Sschwarze.\"    openssl-core@openssl.org.
30dfc30437Sschwarze.\"
31dfc30437Sschwarze.\" 5. Products derived from this software may not be called "OpenSSL"
32dfc30437Sschwarze.\"    nor may "OpenSSL" appear in their names without prior written
33dfc30437Sschwarze.\"    permission of the OpenSSL Project.
34dfc30437Sschwarze.\"
35dfc30437Sschwarze.\" 6. Redistributions of any form whatsoever must retain the following
36dfc30437Sschwarze.\"    acknowledgment:
37dfc30437Sschwarze.\"    "This product includes software developed by the OpenSSL Project
38dfc30437Sschwarze.\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39dfc30437Sschwarze.\"
40dfc30437Sschwarze.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41dfc30437Sschwarze.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42dfc30437Sschwarze.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43dfc30437Sschwarze.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
44dfc30437Sschwarze.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45dfc30437Sschwarze.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46dfc30437Sschwarze.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47dfc30437Sschwarze.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48dfc30437Sschwarze.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49dfc30437Sschwarze.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50dfc30437Sschwarze.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51dfc30437Sschwarze.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52dfc30437Sschwarze.\"
53*de980744Stb.Dd $Mdocdate: January 18 2025 $
54f1a3c524Sschwarze.Dt SSL_CTX_ADD_EXTRA_CHAIN_CERT 3
55f1a3c524Sschwarze.Os
56f1a3c524Sschwarze.Sh NAME
57dfc30437Sschwarze.Nm SSL_CTX_add_extra_chain_cert ,
5807382d5fSschwarze.Nm SSL_CTX_get_extra_chain_certs_only ,
593d842696Sschwarze.Nm SSL_CTX_get_extra_chain_certs ,
60dfc30437Sschwarze.Nm SSL_CTX_clear_extra_chain_certs
613d842696Sschwarze.Nd add, retrieve, and clear extra chain certificates
62f1a3c524Sschwarze.Sh SYNOPSIS
63f1a3c524Sschwarze.In openssl/ssl.h
64f1a3c524Sschwarze.Ft long
65dfc30437Sschwarze.Fn SSL_CTX_add_extra_chain_cert "SSL_CTX *ctx" "X509 *x509"
66dfc30437Sschwarze.Ft long
6707382d5fSschwarze.Fn SSL_CTX_get_extra_chain_certs_only "SSL_CTX *ctx" "STACK_OF(X509) **certs"
6807382d5fSschwarze.Ft long
693d842696Sschwarze.Fn SSL_CTX_get_extra_chain_certs "SSL_CTX *ctx" "STACK_OF(X509) **certs"
703d842696Sschwarze.Ft long
71dfc30437Sschwarze.Fn SSL_CTX_clear_extra_chain_certs "SSL_CTX *ctx"
72f1a3c524Sschwarze.Sh DESCRIPTION
73f1a3c524Sschwarze.Fn SSL_CTX_add_extra_chain_cert
74f1a3c524Sschwarzeadds the certificate
75f1a3c524Sschwarze.Fa x509
76dfc30437Sschwarzeto the extra chain certificates associated with
77dfc30437Sschwarze.Fa ctx .
78dfc30437SschwarzeSeveral certificates can be added one after another.
79dfc30437Sschwarze.Pp
8007382d5fSschwarze.Fn SSL_CTX_get_extra_chain_certs_only
813d842696Sschwarzeretrieves an internal pointer to the stack of extra chain certificates
823d842696Sschwarzeassociated with
8307382d5fSschwarze.Fa ctx ,
8407382d5fSschwarzeor set
8507382d5fSschwarze.Pf * Fa certs
8607382d5fSschwarzeto
8707382d5fSschwarze.Dv NULL
8807382d5fSschwarzeif there are none.
8907382d5fSschwarze.Pp
9007382d5fSschwarze.Fn SSL_CTX_get_extra_chain_certs
9107382d5fSschwarzedoes the same except that it retrieves an internal pointer
9207382d5fSschwarzeto the chain associated with the certificate
9307382d5fSschwarzeif there are no extra chain certificates.
943d842696Sschwarze.Pp
95dfc30437Sschwarze.Fn SSL_CTX_clear_extra_chain_certs
96dfc30437Sschwarzeclears all extra chain certificates associated with
97dfc30437Sschwarze.Fa ctx .
98dfc30437Sschwarze.Pp
99dfc30437SschwarzeThese functions are implemented as macros.
100dfc30437Sschwarze.Pp
101dfc30437SschwarzeWhen sending a certificate chain, extra chain certificates are sent
102dfc30437Sschwarzein order following the end entity certificate.
103dfc30437Sschwarze.Pp
104f1a3c524SschwarzeIf no chain is specified, the library will try to complete the chain from the
105f1a3c524Sschwarzeavailable CA certificates in the trusted CA storage, see
106f1a3c524Sschwarze.Xr SSL_CTX_load_verify_locations 3 .
107f1a3c524Sschwarze.Pp
108f1a3c524SschwarzeThe x509 certificate provided to
109f1a3c524Sschwarze.Fn SSL_CTX_add_extra_chain_cert
110f1a3c524Sschwarzewill be freed by the library when the
111f1a3c524Sschwarze.Vt SSL_CTX
112f1a3c524Sschwarzeis destroyed.
113dfc30437SschwarzeAn application should not free the
114f1a3c524Sschwarze.Fa x509
1153d842696Sschwarzeobject, nor the
1163d842696Sschwarze.Pf * Fa certs
1173d842696Sschwarzeobject retrieved by
1183d842696Sschwarze.Fn SSL_CTX_get_extra_chain_certs .
119f1a3c524Sschwarze.Sh RETURN VALUES
1203d842696SschwarzeThese functions return 1 on success or 0 for failure.
121dfc30437SschwarzeCheck out the error stack to find out the reason for failure.
122f1a3c524Sschwarze.Sh SEE ALSO
1233d842696Sschwarze.Xr ssl 3 ,
1243d842696Sschwarze.Xr SSL_CTX_add1_chain_cert 3 ,
125bb2ba699Sschwarze.Xr SSL_CTX_ctrl 3 ,
126f1a3c524Sschwarze.Xr SSL_CTX_load_verify_locations 3 ,
127f1a3c524Sschwarze.Xr SSL_CTX_set_client_cert_cb 3 ,
128f1a3c524Sschwarze.Xr SSL_CTX_use_certificate 3
129a9d87a53Sschwarze.Sh HISTORY
130a9d87a53Sschwarze.Fn SSL_CTX_add_extra_chain_cert
131a9d87a53Sschwarzefirst appeared in SSLeay 0.9.1 and has been available since
132a9d87a53Sschwarze.Ox 2.6 .
1335d66abf6Sschwarze.Pp
1343d842696Sschwarze.Fn SSL_CTX_get_extra_chain_certs
1353d842696Sschwarzeand
1365d66abf6Sschwarze.Fn SSL_CTX_clear_extra_chain_certs
1373d842696Sschwarzefirst appeared in OpenSSL 1.0.1 and have been available since
1385d66abf6Sschwarze.Ox 5.3 .
13907382d5fSschwarze.Pp
14007382d5fSschwarze.Fn SSL_CTX_get_extra_chain_certs_only
14107382d5fSschwarzefirst appeared in OpenSSL 1.0.2 and has been available since
14207382d5fSschwarze.Ox 6.7 .
143dfc30437Sschwarze.Sh CAVEATS
1443d842696SschwarzeCertificates added with
1453d842696Sschwarze.Fn SSL_CTX_add_extra_chain_cert
1463d842696Sschwarzeare ignored when certificates are also available that have been
1473d842696Sschwarzeadded using the functions documented in
1483d842696Sschwarze.Xr SSL_CTX_set1_chain 3 .
1493d842696Sschwarze.Pp
150dfc30437SschwarzeOnly one set of extra chain certificates can be specified per
151dfc30437Sschwarze.Vt SSL_CTX
1523d842696Sschwarzestructure using
1533d842696Sschwarze.Fn SSL_CTX_add_extra_chain_cert .
154dfc30437SschwarzeDifferent chains for different certificates (for example if both
155*de980744StbRSA and ECDSA certificates are specified by the same server) or
156dfc30437Sschwarzedifferent SSL structures with the same parent
157dfc30437Sschwarze.Vt SSL_CTX
1583d842696Sschwarzerequire using the functions documented in
1593d842696Sschwarze.Xr SSL_CTX_set1_chain 3
1603d842696Sschwarzeinstead.
161