xref: /freebsd-src/crypto/openssl/doc/man3/X509_add_cert.pod (revision aa7957345732816fb0ba8308798d2f79f45597f9)
1b077aed3SPierre Pronchery=pod
2b077aed3SPierre Pronchery
3b077aed3SPierre Pronchery=head1 NAME
4b077aed3SPierre Pronchery
5b077aed3SPierre ProncheryX509_add_cert,
6b077aed3SPierre ProncheryX509_add_certs -
7b077aed3SPierre ProncheryX509 certificate list addition functions
8b077aed3SPierre Pronchery
9b077aed3SPierre Pronchery=head1 SYNOPSIS
10b077aed3SPierre Pronchery
11b077aed3SPierre Pronchery #include <openssl/x509.h>
12b077aed3SPierre Pronchery
13b077aed3SPierre Pronchery int X509_add_cert(STACK_OF(X509) *sk, X509 *cert, int flags);
14b077aed3SPierre Pronchery int X509_add_certs(STACK_OF(X509) *sk, STACK_OF(X509) *certs, int flags);
15b077aed3SPierre Pronchery
16b077aed3SPierre Pronchery=head1 DESCRIPTION
17b077aed3SPierre Pronchery
18b077aed3SPierre ProncheryX509_add_cert() adds a certificate I<cert> to the given list I<sk>.
19b077aed3SPierre Pronchery
20b077aed3SPierre ProncheryX509_add_certs() adds a list of certificate I<certs> to the given list I<sk>.
21b077aed3SPierre ProncheryThe I<certs> argument may be NULL, which implies no effect.
22b077aed3SPierre ProncheryIt does not modify the list I<certs> but
23b077aed3SPierre Proncheryin case the B<X509_ADD_FLAG_UP_REF> flag (described below) is set
24b077aed3SPierre Proncherythe reference counters of those of its members added to I<sk> are increased.
25b077aed3SPierre Pronchery
26b077aed3SPierre ProncheryBoth these functions have a I<flags> parameter,
27b077aed3SPierre Proncherywhich is used to control details of the operation.
28b077aed3SPierre Pronchery
29b077aed3SPierre ProncheryThe value B<X509_ADD_FLAG_DEFAULT>, which equals 0, means no special semantics.
30b077aed3SPierre Pronchery
31b077aed3SPierre ProncheryIf B<X509_ADD_FLAG_UP_REF> is set then
32b077aed3SPierre Proncherythe reference counts of those certificates added successfully are increased.
33b077aed3SPierre Pronchery
34*aa795734SPierre ProncheryIf B<X509_ADD_FLAG_PREPEND> is set then the certificates are prepended to I<sk>.
35b077aed3SPierre ProncheryBy default they are appended to I<sk>.
36b077aed3SPierre ProncheryIn both cases the original order of the added certificates is preserved.
37b077aed3SPierre Pronchery
38b077aed3SPierre ProncheryIf B<X509_ADD_FLAG_NO_DUP> is set then certificates already contained in I<sk>,
39b077aed3SPierre Proncherywhich is determined using L<X509_cmp(3)>, are ignored.
40b077aed3SPierre Pronchery
41b077aed3SPierre ProncheryIf B<X509_ADD_FLAG_NO_SS> is set then certificates that are marked self-signed,
42b077aed3SPierre Proncherywhich is determined using L<X509_self_signed(3)>, are ignored.
43b077aed3SPierre Pronchery
44b077aed3SPierre Pronchery=head1 RETURN VALUES
45b077aed3SPierre Pronchery
46b077aed3SPierre ProncheryBoth functions return 1 for success and 0 for failure.
47b077aed3SPierre Pronchery
48b077aed3SPierre Pronchery=head1 NOTES
49b077aed3SPierre Pronchery
50b077aed3SPierre ProncheryIf X509_add_certs() is used with the flags B<X509_ADD_FLAG_NO_DUP> or
51b077aed3SPierre ProncheryB<X509_ADD_FLAG_NO_SS> it is advisable to use also B<X509_ADD_FLAG_UP_REF>
52b077aed3SPierre Proncherybecause otherwise likely not for all members of the I<certs> list
53b077aed3SPierre Proncherythe ownership is transferred to the list of certificates I<sk>.
54b077aed3SPierre Pronchery
55b077aed3SPierre ProncheryCare should also be taken in case the I<certs> argument equals I<sk>.
56b077aed3SPierre Pronchery
57b077aed3SPierre Pronchery=head1 SEE ALSO
58b077aed3SPierre Pronchery
59b077aed3SPierre ProncheryL<X509_cmp(3)>
60b077aed3SPierre ProncheryL<X509_self_signed(3)>
61b077aed3SPierre Pronchery
62b077aed3SPierre Pronchery=head1 HISTORY
63b077aed3SPierre Pronchery
64b077aed3SPierre ProncheryThe functions X509_add_cert() and X509_add_certs()
65b077aed3SPierre Proncherywere added in OpenSSL 3.0.
66b077aed3SPierre Pronchery
67b077aed3SPierre Pronchery=head1 COPYRIGHT
68b077aed3SPierre Pronchery
69*aa795734SPierre ProncheryCopyright 2019-2023 The OpenSSL Project Authors. All Rights Reserved.
70b077aed3SPierre Pronchery
71b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License").  You may not use
72b077aed3SPierre Proncherythis file except in compliance with the License.  You can obtain a copy
73b077aed3SPierre Proncheryin the file LICENSE in the source distribution or at
74b077aed3SPierre ProncheryL<https://www.openssl.org/source/license.html>.
75b077aed3SPierre Pronchery
76b077aed3SPierre Pronchery=cut
77