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