| 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_D2I 3SSL" |
| 58 |
.TH X509V3_GET_D2I 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_d2i, X509V3_add1_i2d, X509V3_EXT_d2i, X509V3_EXT_i2d, |
| 65 |
X509_get_ext_d2i, X509_add1_ext_i2d, |
| 66 |
X509_ACERT_get_ext_d2i, X509_ACERT_add1_ext_i2d, |
| 67 |
X509_CRL_get_ext_d2i, X509_CRL_add1_ext_i2d, |
| 68 |
X509_REVOKED_get_ext_d2i, X509_REVOKED_add1_ext_i2d, |
| 69 |
X509_get0_extensions, X509_ACERT_get0_extensions, X509_CRL_get0_extensions, |
| 70 |
X509_REVOKED_get0_extensions \- X509 extension decode and encode functions |
| 71 |
.SH SYNOPSIS |
| 72 |
.IX Header "SYNOPSIS" |
| 73 |
.Vb 1 |
| 74 |
\& #include <openssl/x509v3.h> |
| 75 |
\& |
| 76 |
\& void *X509V3_get_d2i(const STACK_OF(X509_EXTENSION) *x, int nid, int *crit, |
| 77 |
\& int *idx); |
| 78 |
\& int X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value, |
| 79 |
\& int crit, unsigned long flags); |
| 80 |
\& |
| 81 |
\& void *X509V3_EXT_d2i(X509_EXTENSION *ext); |
| 82 |
\& X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc); |
| 83 |
\& |
| 84 |
\& void *X509_get_ext_d2i(const X509 *x, int nid, int *crit, int *idx); |
| 85 |
\& int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit, |
| 86 |
\& unsigned long flags); |
| 87 |
\& |
| 88 |
\& void *X509_ACERT_get_ext_d2i(const X509_ACERT *x, int nid, int *crit, int *idx); |
| 89 |
\& int X509_ACERT_add1_ext_i2d(X509_ACERT *x, int nid, void *value, int crit, |
| 90 |
\& unsigned long flags); |
| 91 |
\& |
| 92 |
\& void *X509_CRL_get_ext_d2i(const X509_CRL *crl, int nid, int *crit, int *idx); |
| 93 |
\& int X509_CRL_add1_ext_i2d(X509_CRL *crl, int nid, void *value, int crit, |
| 94 |
\& unsigned long flags); |
| 95 |
\& |
| 96 |
\& void *X509_REVOKED_get_ext_d2i(const X509_REVOKED *r, int nid, int *crit, int *idx); |
| 97 |
\& int X509_REVOKED_add1_ext_i2d(X509_REVOKED *r, int nid, void *value, int crit, |
| 98 |
\& unsigned long flags); |
| 99 |
\& |
| 100 |
\& const STACK_OF(X509_EXTENSION) *X509_get0_extensions(const X509 *x); |
| 101 |
\& const STACK_OF(X509_EXTENSION) *X509_ACERT_get0_extensions(const X509 *x); |
| 102 |
\& const STACK_OF(X509_EXTENSION) *X509_CRL_get0_extensions(const X509_CRL *crl); |
| 103 |
\& const STACK_OF(X509_EXTENSION) *X509_REVOKED_get0_extensions(const X509_REVOKED *r); |
| 104 |
.Ve |
| 105 |
.SH DESCRIPTION |
| 106 |
.IX Header "DESCRIPTION" |
| 107 |
\&\fBX509V3_get_d2i()\fR looks for an extension with OID \fInid\fR in the extensions |
| 108 |
\&\fIx\fR and, if found, decodes it. If \fIidx\fR is NULL then only one |
| 109 |
occurrence of an extension is permissible, otherwise the first extension after |
| 110 |
index \fI*idx\fR is returned and \fI*idx\fR updated to the location of the extension. |
| 111 |
If \fIcrit\fR is not NULL then \fI*crit\fR is set to a status value: \-2 if the |
| 112 |
extension occurs multiple times (this is only returned if \fIidx\fR is NULL), |
| 113 |
\&\-1 if the extension could not be found, 0 if the extension is found and is |
| 114 |
not critical and 1 if critical. A pointer to an extension specific structure |
| 115 |
or NULL is returned. |
| 116 |
.PP |
| 117 |
\&\fBX509V3_add1_i2d()\fR adds extension \fIvalue\fR to STACK \fI*x\fR (allocating a new |
| 118 |
STACK if necessary) using OID \fInid\fR and criticality \fIcrit\fR according |
| 119 |
to \fIflags\fR. |
| 120 |
.PP |
| 121 |
\&\fBX509V3_EXT_d2i()\fR attempts to decode the ASN.1 data contained in extension |
| 122 |
\&\fIext\fR and returns a pointer to an extension specific structure or NULL |
| 123 |
if the extension could not be decoded (invalid syntax or not supported). |
| 124 |
.PP |
| 125 |
\&\fBX509V3_EXT_i2d()\fR encodes the extension specific structure \fIext_struc\fR |
| 126 |
with OID \fIext_nid\fR and criticality \fIcrit\fR. |
| 127 |
.PP |
| 128 |
\&\fBX509_get_ext_d2i()\fR and \fBX509_add1_ext_i2d()\fR operate on the extensions of |
| 129 |
certificate \fIx\fR. They are otherwise identical to \fBX509V3_get_d2i()\fR and |
| 130 |
\&\fBX509V3_add1_i2d()\fR. |
| 131 |
.PP |
| 132 |
\&\fBX509_ACERT_get_ext_d2i()\fR and \fBX509_ACERT_add1_ext_i2d()\fR operate on the extensions |
| 133 |
of \fBX509_ACERT\fR structure \fIx\fR. They are otherwise identical to \fBX509V3_get_d2i()\fR |
| 134 |
and \fBX509V3_add1_i2d()\fR. |
| 135 |
.PP |
| 136 |
\&\fBX509_CRL_get_ext_d2i()\fR and \fBX509_CRL_add1_ext_i2d()\fR operate on the extensions |
| 137 |
of CRL \fIcrl\fR. They are otherwise identical to \fBX509V3_get_d2i()\fR and |
| 138 |
\&\fBX509V3_add1_i2d()\fR. |
| 139 |
.PP |
| 140 |
\&\fBX509_REVOKED_get_ext_d2i()\fR and \fBX509_REVOKED_add1_ext_i2d()\fR operate on the |
| 141 |
extensions of \fBX509_REVOKED\fR structure \fIr\fR (i.e for CRL entry extensions). |
| 142 |
They are otherwise identical to \fBX509V3_get_d2i()\fR and \fBX509V3_add1_i2d()\fR. |
| 143 |
.PP |
| 144 |
\&\fBX509_get0_extensions()\fR, \fBX509_ACERT_get0_extensions()\fR, |
| 145 |
\&\fBX509_CRL_get0_extensions()\fR and \fBX509_REVOKED_get0_extensions()\fR return a |
| 146 |
STACK of all the extensions of a certificate, an attribute certificate, |
| 147 |
a CRL or a CRL entry respectively. |
| 148 |
.SH NOTES |
| 149 |
.IX Header "NOTES" |
| 150 |
In almost all cases an extension can occur at most once and multiple |
| 151 |
occurrences is an error. Therefore, the \fIidx\fR parameter is usually NULL. |
| 152 |
.PP |
| 153 |
The \fIflags\fR parameter may be one of the following values. |
| 154 |
.PP |
| 155 |
\&\fBX509V3_ADD_DEFAULT\fR appends a new extension only if the extension does |
| 156 |
not exist. An error is returned if the extension exists. |
| 157 |
.PP |
| 158 |
\&\fBX509V3_ADD_APPEND\fR appends a new extension, ignoring whether the extension |
| 159 |
exists. |
| 160 |
.PP |
| 161 |
\&\fBX509V3_ADD_REPLACE\fR replaces an existing extension. If the extension does |
| 162 |
not exist, appends a new extension. |
| 163 |
.PP |
| 164 |
\&\fBX509V3_ADD_REPLACE_EXISTING\fR replaces an existing extension. If the |
| 165 |
extension does not exist, returns an error. |
| 166 |
.PP |
| 167 |
\&\fBX509V3_ADD_KEEP_EXISTING\fR appends a new extension only if the extension does |
| 168 |
not exist. An error is \fBnot\fR returned if the extension exists. |
| 169 |
.PP |
| 170 |
\&\fBX509V3_ADD_DELETE\fR deletes and frees an existing extension. If the extension |
| 171 |
does not exist, returns an error. No new extension is added. |
| 172 |
.PP |
| 173 |
If \fBX509V3_ADD_SILENT\fR is bitwise ORed with \fIflags\fR: any error returned |
| 174 |
will not be added to the error queue. |
| 175 |
.PP |
| 176 |
The function \fBX509V3_get_d2i()\fR and its variants |
| 177 |
will return NULL if the extension is not |
| 178 |
found, occurs multiple times or cannot be decoded. It is possible to |
| 179 |
determine the precise reason by checking the value of \fI*crit\fR. |
| 180 |
The returned pointer must be explicitly freed. |
| 181 |
.PP |
| 182 |
The function \fBX509V3_add1_i2d()\fR and its variants allocate \fBX509_EXTENSION\fR |
| 183 |
objects on STACK \fI*x\fR depending on \fIflags\fR. The \fBX509_EXTENSION\fR objects |
| 184 |
must be explicitly freed using \fBX509_EXTENSION_free()\fR. |
| 185 |
.SH "SUPPORTED EXTENSIONS" |
| 186 |
.IX Header "SUPPORTED EXTENSIONS" |
| 187 |
The following sections contain a list of all supported extensions |
| 188 |
including their name and NID. |
| 189 |
.SS "PKIX Certificate Extensions" |
| 190 |
.IX Subsection "PKIX Certificate Extensions" |
| 191 |
The following certificate extensions are defined in PKIX standards such as |
| 192 |
RFC5280. |
| 193 |
.PP |
| 194 |
.Vb 3 |
| 195 |
\& Basic Constraints NID_basic_constraints |
| 196 |
\& Key Usage NID_key_usage |
| 197 |
\& Extended Key Usage NID_ext_key_usage |
| 198 |
\& |
| 199 |
\& Subject Key Identifier NID_subject_key_identifier |
| 200 |
\& Authority Key Identifier NID_authority_key_identifier |
| 201 |
\& |
| 202 |
\& Private Key Usage Period NID_private_key_usage_period |
| 203 |
\& |
| 204 |
\& Subject Alternative Name NID_subject_alt_name |
| 205 |
\& Issuer Alternative Name NID_issuer_alt_name |
| 206 |
\& |
| 207 |
\& Authority Information Access NID_info_access |
| 208 |
\& Subject Information Access NID_sinfo_access |
| 209 |
\& |
| 210 |
\& Name Constraints NID_name_constraints |
| 211 |
\& |
| 212 |
\& Certificate Policies NID_certificate_policies |
| 213 |
\& Policy Mappings NID_policy_mappings |
| 214 |
\& Policy Constraints NID_policy_constraints |
| 215 |
\& Inhibit Any Policy NID_inhibit_any_policy |
| 216 |
\& |
| 217 |
\& TLS Feature NID_tlsfeature |
| 218 |
.Ve |
| 219 |
.SS "Netscape Certificate Extensions" |
| 220 |
.IX Subsection "Netscape Certificate Extensions" |
| 221 |
The following are (largely obsolete) Netscape certificate extensions. |
| 222 |
.PP |
| 223 |
.Vb 8 |
| 224 |
\& Netscape Cert Type NID_netscape_cert_type |
| 225 |
\& Netscape Base Url NID_netscape_base_url |
| 226 |
\& Netscape Revocation Url NID_netscape_revocation_url |
| 227 |
\& Netscape CA Revocation Url NID_netscape_ca_revocation_url |
| 228 |
\& Netscape Renewal Url NID_netscape_renewal_url |
| 229 |
\& Netscape CA Policy Url NID_netscape_ca_policy_url |
| 230 |
\& Netscape SSL Server Name NID_netscape_ssl_server_name |
| 231 |
\& Netscape Comment NID_netscape_comment |
| 232 |
.Ve |
| 233 |
.SS "Miscellaneous Certificate Extensions" |
| 234 |
.IX Subsection "Miscellaneous Certificate Extensions" |
| 235 |
.Vb 2 |
| 236 |
\& Strong Extranet ID NID_sxnet |
| 237 |
\& Proxy Certificate Information NID_proxyCertInfo |
| 238 |
.Ve |
| 239 |
.SS "PKIX CRL Extensions" |
| 240 |
.IX Subsection "PKIX CRL Extensions" |
| 241 |
The following are CRL extensions from PKIX standards such as RFC5280. |
| 242 |
.PP |
| 243 |
.Vb 6 |
| 244 |
\& CRL Number NID_crl_number |
| 245 |
\& CRL Distribution Points NID_crl_distribution_points |
| 246 |
\& Delta CRL Indicator NID_delta_crl |
| 247 |
\& Freshest CRL NID_freshest_crl |
| 248 |
\& Invalidity Date NID_invalidity_date |
| 249 |
\& Issuing Distribution Point NID_issuing_distribution_point |
| 250 |
.Ve |
| 251 |
.PP |
| 252 |
The following are CRL entry extensions from PKIX standards such as RFC5280. |
| 253 |
.PP |
| 254 |
.Vb 2 |
| 255 |
\& CRL Reason Code NID_crl_reason |
| 256 |
\& Certificate Issuer NID_certificate_issuer |
| 257 |
.Ve |
| 258 |
.SS "OCSP Extensions" |
| 259 |
.IX Subsection "OCSP Extensions" |
| 260 |
.Vb 7 |
| 261 |
\& OCSP Nonce NID_id_pkix_OCSP_Nonce |
| 262 |
\& OCSP CRL ID NID_id_pkix_OCSP_CrlID |
| 263 |
\& Acceptable OCSP Responses NID_id_pkix_OCSP_acceptableResponses |
| 264 |
\& OCSP No Check NID_id_pkix_OCSP_noCheck |
| 265 |
\& OCSP Archive Cutoff NID_id_pkix_OCSP_archiveCutoff |
| 266 |
\& OCSP Service Locator NID_id_pkix_OCSP_serviceLocator |
| 267 |
\& Hold Instruction Code NID_hold_instruction_code |
| 268 |
.Ve |
| 269 |
.SS "Certificate Transparency Extensions" |
| 270 |
.IX Subsection "Certificate Transparency Extensions" |
| 271 |
The following extensions are used by certificate transparency, RFC6962 |
| 272 |
.PP |
| 273 |
.Vb 2 |
| 274 |
\& CT Precertificate SCTs NID_ct_precert_scts |
| 275 |
\& CT Certificate SCTs NID_ct_cert_scts |
| 276 |
.Ve |
| 277 |
.SH "RETURN VALUES" |
| 278 |
.IX Header "RETURN VALUES" |
| 279 |
\&\fBX509V3_get_d2i()\fR, its variants, and \fBX509V3_EXT_d2i()\fR return |
| 280 |
a pointer to an extension specific structure or NULL if an error occurs. |
| 281 |
.PP |
| 282 |
\&\fBX509V3_add1_i2d()\fR and its variants return 1 if the operation is successful |
| 283 |
and 0 if it fails due to a non-fatal error (extension not found, already exists, |
| 284 |
cannot be encoded) or \-1 due to a fatal error such as a memory allocation |
| 285 |
failure. |
| 286 |
.PP |
| 287 |
\&\fBX509V3_EXT_i2d()\fR returns a pointer to an \fBX509_EXTENSION\fR structure |
| 288 |
or NULL if an error occurs. |
| 289 |
.PP |
| 290 |
\&\fBX509_get0_extensions()\fR, \fBX509_CRL_get0_extensions()\fR and |
| 291 |
\&\fBX509_REVOKED_get0_extensions()\fR return a stack of extensions. They return |
| 292 |
NULL if no extensions are present. |
| 293 |
.SH "SEE ALSO" |
| 294 |
.IX Header "SEE ALSO" |
| 295 |
\&\fBd2i_X509\fR\|(3), |
| 296 |
\&\fBERR_get_error\fR\|(3), |
| 297 |
\&\fBX509_CRL_get0_by_serial\fR\|(3), |
| 298 |
\&\fBX509_get0_signature\fR\|(3), |
| 299 |
\&\fBX509_get_ext_d2i\fR\|(3), |
| 300 |
\&\fBX509_get_extension_flags\fR\|(3), |
| 301 |
\&\fBX509_get_pubkey\fR\|(3), |
| 302 |
\&\fBX509_get_subject_name\fR\|(3), |
| 303 |
\&\fBX509_get_version\fR\|(3), |
| 304 |
\&\fBX509_NAME_add_entry_by_txt\fR\|(3), |
| 305 |
\&\fBX509_NAME_ENTRY_get_object\fR\|(3), |
| 306 |
\&\fBX509_NAME_get_index_by_NID\fR\|(3), |
| 307 |
\&\fBX509_NAME_print_ex\fR\|(3), |
| 308 |
\&\fBX509_new\fR\|(3), |
| 309 |
\&\fBX509_sign\fR\|(3), |
| 310 |
\&\fBX509_verify_cert\fR\|(3) |
| 311 |
.SH HISTORY |
| 312 |
.IX Header "HISTORY" |
| 313 |
\&\fBX509_ACERT_get_ext_d2i()\fR, \fBX509_ACERT_add1_ext_i2d()\fR, |
| 314 |
\&\fBX509_ACERT_get0_extensions()\fR were added in OpenSSL 3.4. |
| 315 |
.SH COPYRIGHT |
| 316 |
.IX Header "COPYRIGHT" |
| 317 |
Copyright 2015\-2024 The OpenSSL Project Authors. All Rights Reserved. |
| 318 |
.PP |
| 319 |
Licensed under the Apache License 2.0 (the "License"). You may not use |
| 320 |
this file except in compliance with the License. You can obtain a copy |
| 321 |
in the file LICENSE in the source distribution or at |
| 322 |
<https://www.openssl.org/source/license.html>. |