| 1 |
.\" -*- mode: troff; coding: utf-8 -*- |
| 2 |
.\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45) |
| 3 |
.\" |
| 4 |
.\" Standard preamble: |
| 5 |
.\" ======================================================================== |
| 6 |
.de Sp \" Vertical space (when we can't use .PP) |
| 7 |
.if t .sp .5v |
| 8 |
.if n .sp |
| 9 |
.. |
| 10 |
.de Vb \" Begin verbatim text |
| 11 |
.ft CW |
| 12 |
.nf |
| 13 |
.ne \\$1 |
| 14 |
.. |
| 15 |
.de Ve \" End verbatim text |
| 16 |
.ft R |
| 17 |
.fi |
| 18 |
.. |
| 19 |
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. |
| 20 |
.ie n \{\ |
| 21 |
. ds C` "" |
| 22 |
. ds C' "" |
| 23 |
'br\} |
| 24 |
.el\{\ |
| 25 |
. ds C` |
| 26 |
. ds C' |
| 27 |
'br\} |
| 28 |
.\" |
| 29 |
.\" Escape single quotes in literal strings from groff's Unicode transform. |
| 30 |
.ie \n(.g .ds Aq \(aq |
| 31 |
.el .ds Aq ' |
| 32 |
.\" |
| 33 |
.\" If the F register is >0, we'll generate index entries on stderr for |
| 34 |
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index |
| 35 |
.\" entries marked with X<> in POD. Of course, you'll have to process the |
| 36 |
.\" output yourself in some meaningful fashion. |
| 37 |
.\" |
| 38 |
.\" Avoid warning from groff about undefined register 'F'. |
| 39 |
.de IX |
| 40 |
.. |
| 41 |
.nr rF 0 |
| 42 |
.if \n(.g .if rF .nr rF 1 |
| 43 |
.if (\n(rF:(\n(.g==0)) \{\ |
| 44 |
. if \nF \{\ |
| 45 |
. de IX |
| 46 |
. tm Index:\\$1\t\\n%\t"\\$2" |
| 47 |
.. |
| 48 |
. if !\nF==2 \{\ |
| 49 |
. nr % 0 |
| 50 |
. nr F 2 |
| 51 |
. \} |
| 52 |
. \} |
| 53 |
.\} |
| 54 |
.rr rF |
| 55 |
.\" ======================================================================== |
| 56 |
.\" |
| 57 |
.IX Title "X509V3_GET_EXT_BY_NID 3SSL" |
| 58 |
.TH X509V3_GET_EXT_BY_NID 3SSL 2026-04-07 3.6.2 OpenSSL |
| 59 |
.\" For nroff, turn off justification. Always turn off hyphenation; it makes |
| 60 |
.\" way too many mistakes in technical documents. |
| 61 |
.if n .ad l |
| 62 |
.nh |
| 63 |
.SH NAME |
| 64 |
X509v3_get_ext_count, X509v3_get_ext, X509v3_get_ext_by_NID, |
| 65 |
X509v3_get_ext_by_OBJ, X509v3_get_ext_by_critical, X509v3_delete_ext, |
| 66 |
X509v3_add_ext, X509v3_add_extensions, X509_get_ext_count, X509_get_ext, |
| 67 |
X509_get_ext_by_NID, X509_get_ext_by_OBJ, X509_get_ext_by_critical, |
| 68 |
X509_delete_ext, X509_add_ext, X509_CRL_get_ext_count, X509_CRL_get_ext, |
| 69 |
X509_CRL_get_ext_by_NID, X509_CRL_get_ext_by_OBJ, X509_CRL_get_ext_by_critical, |
| 70 |
X509_CRL_delete_ext, X509_CRL_add_ext, X509_REVOKED_get_ext_count, |
| 71 |
X509_REVOKED_get_ext, X509_REVOKED_get_ext_by_NID, X509_REVOKED_get_ext_by_OBJ, |
| 72 |
X509_REVOKED_get_ext_by_critical, X509_REVOKED_delete_ext, |
| 73 |
X509_REVOKED_add_ext \- extension stack utility functions |
| 74 |
.SH SYNOPSIS |
| 75 |
.IX Header "SYNOPSIS" |
| 76 |
.Vb 1 |
| 77 |
\& #include <openssl/x509.h> |
| 78 |
\& |
| 79 |
\& int X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x); |
| 80 |
\& X509_EXTENSION *X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc); |
| 81 |
\& |
| 82 |
\& int X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x, |
| 83 |
\& int nid, int lastpos); |
| 84 |
\& int X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *x, |
| 85 |
\& const ASN1_OBJECT *obj, int lastpos); |
| 86 |
\& int X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *x, |
| 87 |
\& int crit, int lastpos); |
| 88 |
\& X509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc); |
| 89 |
\& STACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x, |
| 90 |
\& X509_EXTENSION *ex, int loc); |
| 91 |
\& STACK_OF(X509_EXTENSION) |
| 92 |
\& *X509v3_add_extensions(STACK_OF(X509_EXTENSION) **target, |
| 93 |
\& const STACK_OF(X509_EXTENSION) *exts); |
| 94 |
\& |
| 95 |
\& int X509_get_ext_count(const X509 *x); |
| 96 |
\& X509_EXTENSION *X509_get_ext(const X509 *x, int loc); |
| 97 |
\& int X509_get_ext_by_NID(const X509 *x, int nid, int lastpos); |
| 98 |
\& int X509_get_ext_by_OBJ(const X509 *x, const ASN1_OBJECT *obj, int lastpos); |
| 99 |
\& int X509_get_ext_by_critical(const X509 *x, int crit, int lastpos); |
| 100 |
\& X509_EXTENSION *X509_delete_ext(X509 *x, int loc); |
| 101 |
\& int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc); |
| 102 |
\& |
| 103 |
\& int X509_CRL_get_ext_count(const X509_CRL *x); |
| 104 |
\& X509_EXTENSION *X509_CRL_get_ext(const X509_CRL *x, int loc); |
| 105 |
\& int X509_CRL_get_ext_by_NID(const X509_CRL *x, int nid, int lastpos); |
| 106 |
\& int X509_CRL_get_ext_by_OBJ(const X509_CRL *x, const ASN1_OBJECT *obj, |
| 107 |
\& int lastpos); |
| 108 |
\& int X509_CRL_get_ext_by_critical(const X509_CRL *x, int crit, int lastpos); |
| 109 |
\& X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc); |
| 110 |
\& int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc); |
| 111 |
\& |
| 112 |
\& int X509_REVOKED_get_ext_count(const X509_REVOKED *x); |
| 113 |
\& X509_EXTENSION *X509_REVOKED_get_ext(const X509_REVOKED *x, int loc); |
| 114 |
\& int X509_REVOKED_get_ext_by_NID(const X509_REVOKED *x, int nid, int lastpos); |
| 115 |
\& int X509_REVOKED_get_ext_by_OBJ(const X509_REVOKED *x, const ASN1_OBJECT *obj, |
| 116 |
\& int lastpos); |
| 117 |
\& int X509_REVOKED_get_ext_by_critical(const X509_REVOKED *x, int crit, int lastpos); |
| 118 |
\& X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc); |
| 119 |
\& int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc); |
| 120 |
.Ve |
| 121 |
.SH DESCRIPTION |
| 122 |
.IX Header "DESCRIPTION" |
| 123 |
\&\fBX509v3_get_ext_count()\fR retrieves the number of extensions in \fIx\fR. |
| 124 |
.PP |
| 125 |
\&\fBX509v3_get_ext()\fR retrieves extension \fIloc\fR from \fIx\fR. The index \fIloc\fR |
| 126 |
can take any value from 0 to X509_get_ext_count(\fIx\fR) \- 1. The returned |
| 127 |
extension is an internal pointer which \fBMUST NOT\fR be freed by the |
| 128 |
application. |
| 129 |
.PP |
| 130 |
\&\fBX509v3_get_ext_by_NID()\fR and \fBX509v3_get_ext_by_OBJ()\fR look for an extension |
| 131 |
with \fInid\fR or \fIobj\fR from extension STACK \fIx\fR. The search starts from the |
| 132 |
extension after \fIlastpos\fR or from the beginning if \fIlastpos\fR is \-1. If |
| 133 |
the extension is found, its index is returned, otherwise \-1 is returned. |
| 134 |
.PP |
| 135 |
\&\fBX509v3_get_ext_by_critical()\fR is similar to \fBX509v3_get_ext_by_NID()\fR except it |
| 136 |
looks for an extension of criticality \fIcrit\fR. A zero value for \fIcrit\fR |
| 137 |
looks for a non-critical extension. A nonzero value looks for a critical |
| 138 |
extension. |
| 139 |
.PP |
| 140 |
\&\fBX509v3_delete_ext()\fR deletes the extension with index \fIloc\fR from \fIx\fR. |
| 141 |
The deleted extension is returned and must be freed by the caller. |
| 142 |
If \fIloc\fR is an invalid index value, NULL is returned. |
| 143 |
.PP |
| 144 |
\&\fBX509v3_add_ext()\fR inserts extension \fIex\fR to STACK \fI*x\fR at position \fIloc\fR. |
| 145 |
If \fIloc\fR is \-1, the new extension is added to the end. |
| 146 |
A new STACK is allocated if \fI*x\fR is NULL. |
| 147 |
The passed extension \fIex\fR is duplicated so it must be freed after use. |
| 148 |
.PP |
| 149 |
\&\fBX509v3_add_extensions()\fR adds the list of extensions \fIexts\fR to STACK \fI*target\fR. |
| 150 |
The STACK \fI*target\fR is returned unchanged if \fIexts\fR is NULL or an empty list. |
| 151 |
Otherwise a new stack is allocated if \fI*target\fR is NULL. |
| 152 |
An extension to be added |
| 153 |
that has the same OID as a pre-existing one replaces this earlier one. |
| 154 |
.PP |
| 155 |
\&\fBX509_get_ext_count()\fR, \fBX509_get_ext()\fR, \fBX509_get_ext_by_NID()\fR, |
| 156 |
\&\fBX509_get_ext_by_OBJ()\fR, \fBX509_get_ext_by_critical()\fR, \fBX509_delete_ext()\fR |
| 157 |
and \fBX509_add_ext()\fR operate on the extensions of certificate \fIx\fR. They are |
| 158 |
otherwise identical to the X509v3 functions. |
| 159 |
.PP |
| 160 |
\&\fBX509_CRL_get_ext_count()\fR, \fBX509_CRL_get_ext()\fR, \fBX509_CRL_get_ext_by_NID()\fR, |
| 161 |
\&\fBX509_CRL_get_ext_by_OBJ()\fR, \fBX509_CRL_get_ext_by_critical()\fR, |
| 162 |
\&\fBX509_CRL_delete_ext()\fR and \fBX509_CRL_add_ext()\fR operate on the extensions of |
| 163 |
CRL \fIx\fR. They are otherwise identical to the X509v3 functions. |
| 164 |
.PP |
| 165 |
\&\fBX509_REVOKED_get_ext_count()\fR, \fBX509_REVOKED_get_ext()\fR, |
| 166 |
\&\fBX509_REVOKED_get_ext_by_NID()\fR, \fBX509_REVOKED_get_ext_by_OBJ()\fR, |
| 167 |
\&\fBX509_REVOKED_get_ext_by_critical()\fR, \fBX509_REVOKED_delete_ext()\fR and |
| 168 |
\&\fBX509_REVOKED_add_ext()\fR operate on the extensions of CRL entry \fIx\fR. |
| 169 |
They are otherwise identical to the X509v3 functions. |
| 170 |
.SH NOTES |
| 171 |
.IX Header "NOTES" |
| 172 |
These functions are used to examine stacks of extensions directly. |
| 173 |
Applications that want to parse or encode and add an extension should |
| 174 |
use the extension encode and decode functions instead, such as |
| 175 |
\&\fBX509_add1_ext_i2d()\fR and \fBX509_get_ext_d2i()\fR. |
| 176 |
.PP |
| 177 |
For \fBX509v3_get_ext_by_NID()\fR, \fBX509v3_get_ext_by_OBJ()\fR, |
| 178 |
\&\fBX509v3_get_ext_by_critical()\fR and its variants, a zero index return value |
| 179 |
is not an error since extension STACK \fIx\fR indices start from zero. |
| 180 |
These search functions start from the extension \fBafter\fR the \fIlastpos\fR parameter |
| 181 |
so it should initially be set to \-1. If it is set to zero, the initial extension |
| 182 |
will not be checked. |
| 183 |
.PP |
| 184 |
\&\fBX509v3_delete_ext()\fR and its variants are a bit counter-intuitive |
| 185 |
because these functions do not free the extension they delete. |
| 186 |
They return an \fBX509_EXTENSION\fR object which must be explicitly freed |
| 187 |
using \fBX509_EXTENSION_free()\fR. |
| 188 |
.SH "RETURN VALUES" |
| 189 |
.IX Header "RETURN VALUES" |
| 190 |
\&\fBX509v3_get_ext_count()\fR returns the extension count or 0 for failure. |
| 191 |
.PP |
| 192 |
\&\fBX509v3_get_ext()\fR, \fBX509v3_delete_ext()\fR and \fBX509_delete_ext()\fR return an |
| 193 |
\&\fBX509_EXTENSION\fR structure or NULL if an error occurs. |
| 194 |
.PP |
| 195 |
\&\fBX509v3_get_ext_by_OBJ()\fR and \fBX509v3_get_ext_by_critical()\fR return |
| 196 |
the extension index or \-1 if an error occurs. |
| 197 |
.PP |
| 198 |
\&\fBX509v3_get_ext_by_NID()\fR returns the extension index or negative values if an |
| 199 |
error occurs. |
| 200 |
.PP |
| 201 |
\&\fBX509v3_add_ext()\fR returns a STACK of extensions or NULL on error. |
| 202 |
.PP |
| 203 |
\&\fBX509v3_add_extensions()\fR returns a STACK of extensions |
| 204 |
or NULL on error or if \fI*target\fR is NULL and \fIexts\fR is NULL or an empty list. |
| 205 |
.PP |
| 206 |
\&\fBX509_add_ext()\fR returns 1 on success and 0 on error. |
| 207 |
.SH "SEE ALSO" |
| 208 |
.IX Header "SEE ALSO" |
| 209 |
\&\fBX509V3_get_d2i\fR\|(3) |
| 210 |
.SH HISTORY |
| 211 |
.IX Header "HISTORY" |
| 212 |
\&\fBX509v3_add_extensions()\fR was added in OpenSSL 3.4. |
| 213 |
.SH COPYRIGHT |
| 214 |
.IX Header "COPYRIGHT" |
| 215 |
Copyright 2015\-2024 The OpenSSL Project Authors. All Rights Reserved. |
| 216 |
.PP |
| 217 |
Licensed under the Apache License 2.0 (the "License"). You may not use |
| 218 |
this file except in compliance with the License. You can obtain a copy |
| 219 |
in the file LICENSE in the source distribution or at |
| 220 |
<https://www.openssl.org/source/license.html>. |