X509_ADD_CERT(3ossl)
π X509_ADD_CERT β the certificate-list-adding girlies (3ossl)
Okay so bestie, welcome to 3ossl (that's the manual section, keep up β¨). This is the page for X509_add_cert and X509_add_certs β the two functions that shove certificates into a STACK_OF(X509) list. It's giving "put the cert in the bag" energy and honestly? Iconic. π
β¨ SYNOPSIS β¨
#include <openssl/x509.h>
int X509_add_cert(STACK_OF(X509) *sk, X509 *cert, int flags);
int X509_add_certs(STACK_OF(X509) *sk, STACK_OF(X509) *certs, int flags);
πΈ DESCRIPTION πΈ
So X509_add_cert() adds one certificate, cert, to the given list sk. And listen β it is an error for the cert argument to be NULL. Like, genuinely an error. Not a vibe. Do not do that. π
X509_add_certs() adds a whole list of certificates, certs, to the given list sk. The certs argument may be NULL, which just means "no effect" β nothing happens, we move on, slay. This function does not modify the certs list itself, but if the X509_ADD_FLAG_UP_REF flag (more on her below π) is set, then the reference counters of those of its members that got added to sk are increased.
Both these functions have a flags parameter, and she's the one controlling the details of the operation. Main character energy fr fr. π₯
- The value
X509_ADD_FLAG_DEFAULT, which equals0, means no special semantics. Just the plain vanilla behaviour, no notes. - If
X509_ADD_FLAG_UP_REFis set then the reference counts of those certificates that were added successfully are increased. - If
X509_ADD_FLAG_PREPENDis set then the certificates are prepended tosk. By default they are appended tosk. And in both cases the original order of the added certificates is preserved β we are not out here scrambling anyone's order, periodt. π - If
X509_ADD_FLAG_NO_DUPis set then certificates already contained inskare ignored, and that "already contained" check is determined usingX509_cmp(3). - If
X509_ADD_FLAG_NO_SSis set then certificates that are marked self-signed are ignored, and that determination is made usingX509_self_signed(3).
π RETURN VALUES π
Both functions return 1 for success and 0 for failure. Binary queen. Two moods, no in-between.
β οΈ NOTES β οΈ
If X509_add_certs() is used with the flags X509_ADD_FLAG_NO_DUP or X509_ADD_FLAG_NO_SS, it is advisable to also use X509_ADD_FLAG_UP_REF, because otherwise, likely not for all members of the certs list is the ownership transferred to the list of certificates sk. (Read that sentence twice, bestie, it matters. π)
Care should also be taken in case thecertsargument equalssk. Like, same list, same object, careful vibes only. π«Ά
π¦ SEE ALSO π¦
X509_cmp(3) Β· X509_self_signed(3)
π HISTORY π
The functions X509_add_cert() and X509_add_certs() were added in OpenSSL 3.0. So they're not ancient, they're just established. Iykyk. β¨
π COPYRIGHT π
Copyright 2019-2025 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
Signed, sealed, delivered: this was 3.5.0, dated 2026-09-25, and your girl is logging off β go add some certs, bestie, you're gonna eat π
ππΈ
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms