X509V3_get_d2i.3ossl 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. .\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42)
  2. .\"
  3. .\" Standard preamble:
  4. .\" ========================================================================
  5. .de Sp \" Vertical space (when we can't use .PP)
  6. .if t .sp .5v
  7. .if n .sp
  8. ..
  9. .de Vb \" Begin verbatim text
  10. .ft CW
  11. .nf
  12. .ne \\$1
  13. ..
  14. .de Ve \" End verbatim text
  15. .ft R
  16. .fi
  17. ..
  18. .\" Set up some character translations and predefined strings. \*(-- will
  19. .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
  20. .\" double quote, and \*(R" will give a right double quote. \*(C+ will
  21. .\" give a nicer C++. Capital omega is used to do unbreakable dashes and
  22. .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
  23. .\" nothing in troff, for use with C<>.
  24. .tr \(*W-
  25. .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
  26. .ie n \{\
  27. . ds -- \(*W-
  28. . ds PI pi
  29. . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
  30. . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
  31. . ds L" ""
  32. . ds R" ""
  33. . ds C` ""
  34. . ds C' ""
  35. 'br\}
  36. .el\{\
  37. . ds -- \|\(em\|
  38. . ds PI \(*p
  39. . ds L" ``
  40. . ds R" ''
  41. . ds C`
  42. . ds C'
  43. 'br\}
  44. .\"
  45. .\" Escape single quotes in literal strings from groff's Unicode transform.
  46. .ie \n(.g .ds Aq \(aq
  47. .el .ds Aq '
  48. .\"
  49. .\" If the F register is >0, we'll generate index entries on stderr for
  50. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  51. .\" entries marked with X<> in POD. Of course, you'll have to process the
  52. .\" output yourself in some meaningful fashion.
  53. .\"
  54. .\" Avoid warning from groff about undefined register 'F'.
  55. .de IX
  56. ..
  57. .nr rF 0
  58. .if \n(.g .if rF .nr rF 1
  59. .if (\n(rF:(\n(.g==0)) \{\
  60. . if \nF \{\
  61. . de IX
  62. . tm Index:\\$1\t\\n%\t"\\$2"
  63. ..
  64. . if !\nF==2 \{\
  65. . nr % 0
  66. . nr F 2
  67. . \}
  68. . \}
  69. .\}
  70. .rr rF
  71. .\"
  72. .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
  73. .\" Fear. Run. Save yourself. No user-serviceable parts.
  74. . \" fudge factors for nroff and troff
  75. .if n \{\
  76. . ds #H 0
  77. . ds #V .8m
  78. . ds #F .3m
  79. . ds #[ \f1
  80. . ds #] \fP
  81. .\}
  82. .if t \{\
  83. . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
  84. . ds #V .6m
  85. . ds #F 0
  86. . ds #[ \&
  87. . ds #] \&
  88. .\}
  89. . \" simple accents for nroff and troff
  90. .if n \{\
  91. . ds ' \&
  92. . ds ` \&
  93. . ds ^ \&
  94. . ds , \&
  95. . ds ~ ~
  96. . ds /
  97. .\}
  98. .if t \{\
  99. . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
  100. . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
  101. . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
  102. . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
  103. . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
  104. . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
  105. .\}
  106. . \" troff and (daisy-wheel) nroff accents
  107. .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
  108. .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
  109. .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
  110. .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
  111. .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
  112. .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
  113. .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
  114. .ds ae a\h'-(\w'a'u*4/10)'e
  115. .ds Ae A\h'-(\w'A'u*4/10)'E
  116. . \" corrections for vroff
  117. .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
  118. .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
  119. . \" for low resolution devices (crt and lpr)
  120. .if \n(.H>23 .if \n(.V>19 \
  121. \{\
  122. . ds : e
  123. . ds 8 ss
  124. . ds o a
  125. . ds d- d\h'-1'\(ga
  126. . ds D- D\h'-1'\(hy
  127. . ds th \o'bp'
  128. . ds Th \o'LP'
  129. . ds ae ae
  130. . ds Ae AE
  131. .\}
  132. .rm #[ #] #H #V #F C
  133. .\" ========================================================================
  134. .\"
  135. .IX Title "X509V3_GET_D2I 3ossl"
  136. .TH X509V3_GET_D2I 3ossl "2024-09-03" "3.3.2" "OpenSSL"
  137. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  138. .\" way too many mistakes in technical documents.
  139. .if n .ad l
  140. .nh
  141. .SH "NAME"
  142. X509V3_get_d2i, X509V3_add1_i2d, X509V3_EXT_d2i, X509V3_EXT_i2d,
  143. X509_get_ext_d2i, X509_add1_ext_i2d,
  144. X509_CRL_get_ext_d2i, X509_CRL_add1_ext_i2d,
  145. X509_REVOKED_get_ext_d2i, X509_REVOKED_add1_ext_i2d,
  146. X509_get0_extensions, X509_CRL_get0_extensions,
  147. X509_REVOKED_get0_extensions \- X509 extension decode and encode functions
  148. .SH "SYNOPSIS"
  149. .IX Header "SYNOPSIS"
  150. .Vb 1
  151. \& #include <openssl/x509v3.h>
  152. \&
  153. \& void *X509V3_get_d2i(const STACK_OF(X509_EXTENSION) *x, int nid, int *crit,
  154. \& int *idx);
  155. \& int X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value,
  156. \& int crit, unsigned long flags);
  157. \&
  158. \& void *X509V3_EXT_d2i(X509_EXTENSION *ext);
  159. \& X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc);
  160. \&
  161. \& void *X509_get_ext_d2i(const X509 *x, int nid, int *crit, int *idx);
  162. \& int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit,
  163. \& unsigned long flags);
  164. \&
  165. \& void *X509_CRL_get_ext_d2i(const X509_CRL *crl, int nid, int *crit, int *idx);
  166. \& int X509_CRL_add1_ext_i2d(X509_CRL *crl, int nid, void *value, int crit,
  167. \& unsigned long flags);
  168. \&
  169. \& void *X509_REVOKED_get_ext_d2i(const X509_REVOKED *r, int nid, int *crit, int *idx);
  170. \& int X509_REVOKED_add1_ext_i2d(X509_REVOKED *r, int nid, void *value, int crit,
  171. \& unsigned long flags);
  172. \&
  173. \& const STACK_OF(X509_EXTENSION) *X509_get0_extensions(const X509 *x);
  174. \& const STACK_OF(X509_EXTENSION) *X509_CRL_get0_extensions(const X509_CRL *crl);
  175. \& const STACK_OF(X509_EXTENSION) *X509_REVOKED_get0_extensions(const X509_REVOKED *r);
  176. .Ve
  177. .SH "DESCRIPTION"
  178. .IX Header "DESCRIPTION"
  179. \&\fBX509V3_get_d2i()\fR looks for an extension with \s-1OID\s0 \fInid\fR in the extensions
  180. \&\fIx\fR and, if found, decodes it. If \fIidx\fR is \s-1NULL\s0 then only one
  181. occurrence of an extension is permissible, otherwise the first extension after
  182. index \fI*idx\fR is returned and \fI*idx\fR updated to the location of the extension.
  183. If \fIcrit\fR is not \s-1NULL\s0 then \fI*crit\fR is set to a status value: \-2 if the
  184. extension occurs multiple times (this is only returned if \fIidx\fR is \s-1NULL\s0),
  185. \&\-1 if the extension could not be found, 0 if the extension is found and is
  186. not critical and 1 if critical. A pointer to an extension specific structure
  187. or \s-1NULL\s0 is returned.
  188. .PP
  189. \&\fBX509V3_add1_i2d()\fR adds extension \fIvalue\fR to \s-1STACK\s0 \fI*x\fR (allocating a new
  190. \&\s-1STACK\s0 if necessary) using \s-1OID\s0 \fInid\fR and criticality \fIcrit\fR according
  191. to \fIflags\fR.
  192. .PP
  193. \&\fBX509V3_EXT_d2i()\fR attempts to decode the \s-1ASN.1\s0 data contained in extension
  194. \&\fIext\fR and returns a pointer to an extension specific structure or \s-1NULL\s0
  195. if the extension could not be decoded (invalid syntax or not supported).
  196. .PP
  197. \&\fBX509V3_EXT_i2d()\fR encodes the extension specific structure \fIext_struc\fR
  198. with \s-1OID\s0 \fIext_nid\fR and criticality \fIcrit\fR.
  199. .PP
  200. \&\fBX509_get_ext_d2i()\fR and \fBX509_add1_ext_i2d()\fR operate on the extensions of
  201. certificate \fIx\fR. They are otherwise identical to \fBX509V3_get_d2i()\fR and
  202. \&\fBX509V3_add1_i2d()\fR.
  203. .PP
  204. \&\fBX509_CRL_get_ext_d2i()\fR and \fBX509_CRL_add1_ext_i2d()\fR operate on the extensions
  205. of \s-1CRL\s0 \fIcrl\fR. They are otherwise identical to \fBX509V3_get_d2i()\fR and
  206. \&\fBX509V3_add1_i2d()\fR.
  207. .PP
  208. \&\fBX509_REVOKED_get_ext_d2i()\fR and \fBX509_REVOKED_add1_ext_i2d()\fR operate on the
  209. extensions of \fBX509_REVOKED\fR structure \fIr\fR (i.e for \s-1CRL\s0 entry extensions).
  210. They are otherwise identical to \fBX509V3_get_d2i()\fR and \fBX509V3_add1_i2d()\fR.
  211. .PP
  212. \&\fBX509_get0_extensions()\fR, \fBX509_CRL_get0_extensions()\fR and
  213. \&\fBX509_REVOKED_get0_extensions()\fR return a \s-1STACK\s0 of all the extensions
  214. of a certificate, a \s-1CRL\s0 or a \s-1CRL\s0 entry respectively.
  215. .SH "NOTES"
  216. .IX Header "NOTES"
  217. In almost all cases an extension can occur at most once and multiple
  218. occurrences is an error. Therefore, the \fIidx\fR parameter is usually \s-1NULL.\s0
  219. .PP
  220. The \fIflags\fR parameter may be one of the following values.
  221. .PP
  222. \&\fBX509V3_ADD_DEFAULT\fR appends a new extension only if the extension does
  223. not exist. An error is returned if the extension exists.
  224. .PP
  225. \&\fBX509V3_ADD_APPEND\fR appends a new extension, ignoring whether the extension
  226. exists.
  227. .PP
  228. \&\fBX509V3_ADD_REPLACE\fR replaces an existing extension. If the extension does
  229. not exist, appends a new extension.
  230. .PP
  231. \&\fBX509V3_ADD_REPLACE_EXISTING\fR replaces an existing extension. If the
  232. extension does not exist, returns an error.
  233. .PP
  234. \&\fBX509V3_ADD_KEEP_EXISTING\fR appends a new extension only if the extension does
  235. not exist. An error is \fBnot\fR returned if the extension exists.
  236. .PP
  237. \&\fBX509V3_ADD_DELETE\fR deletes and frees an existing extension. If the extension
  238. does not exist, returns an error. No new extension is added.
  239. .PP
  240. If \fBX509V3_ADD_SILENT\fR is bitwise ORed with \fIflags\fR: any error returned
  241. will not be added to the error queue.
  242. .PP
  243. The function \fBX509V3_get_d2i()\fR and its variants
  244. will return \s-1NULL\s0 if the extension is not
  245. found, occurs multiple times or cannot be decoded. It is possible to
  246. determine the precise reason by checking the value of \fI*crit\fR.
  247. The returned pointer must be explicitly freed.
  248. .PP
  249. The function \fBX509V3_add1_i2d()\fR and its variants allocate \fBX509_EXTENSION\fR
  250. objects on \s-1STACK\s0 \fI*x\fR depending on \fIflags\fR. The \fBX509_EXTENSION\fR objects
  251. must be explicitly freed using \fBX509_EXTENSION_free()\fR.
  252. .SH "SUPPORTED EXTENSIONS"
  253. .IX Header "SUPPORTED EXTENSIONS"
  254. The following sections contain a list of all supported extensions
  255. including their name and \s-1NID.\s0
  256. .SS "\s-1PKIX\s0 Certificate Extensions"
  257. .IX Subsection "PKIX Certificate Extensions"
  258. The following certificate extensions are defined in \s-1PKIX\s0 standards such as
  259. \&\s-1RFC5280.\s0
  260. .PP
  261. .Vb 3
  262. \& Basic Constraints NID_basic_constraints
  263. \& Key Usage NID_key_usage
  264. \& Extended Key Usage NID_ext_key_usage
  265. \&
  266. \& Subject Key Identifier NID_subject_key_identifier
  267. \& Authority Key Identifier NID_authority_key_identifier
  268. \&
  269. \& Private Key Usage Period NID_private_key_usage_period
  270. \&
  271. \& Subject Alternative Name NID_subject_alt_name
  272. \& Issuer Alternative Name NID_issuer_alt_name
  273. \&
  274. \& Authority Information Access NID_info_access
  275. \& Subject Information Access NID_sinfo_access
  276. \&
  277. \& Name Constraints NID_name_constraints
  278. \&
  279. \& Certificate Policies NID_certificate_policies
  280. \& Policy Mappings NID_policy_mappings
  281. \& Policy Constraints NID_policy_constraints
  282. \& Inhibit Any Policy NID_inhibit_any_policy
  283. \&
  284. \& TLS Feature NID_tlsfeature
  285. .Ve
  286. .SS "Netscape Certificate Extensions"
  287. .IX Subsection "Netscape Certificate Extensions"
  288. The following are (largely obsolete) Netscape certificate extensions.
  289. .PP
  290. .Vb 8
  291. \& Netscape Cert Type NID_netscape_cert_type
  292. \& Netscape Base Url NID_netscape_base_url
  293. \& Netscape Revocation Url NID_netscape_revocation_url
  294. \& Netscape CA Revocation Url NID_netscape_ca_revocation_url
  295. \& Netscape Renewal Url NID_netscape_renewal_url
  296. \& Netscape CA Policy Url NID_netscape_ca_policy_url
  297. \& Netscape SSL Server Name NID_netscape_ssl_server_name
  298. \& Netscape Comment NID_netscape_comment
  299. .Ve
  300. .SS "Miscellaneous Certificate Extensions"
  301. .IX Subsection "Miscellaneous Certificate Extensions"
  302. .Vb 2
  303. \& Strong Extranet ID NID_sxnet
  304. \& Proxy Certificate Information NID_proxyCertInfo
  305. .Ve
  306. .SS "\s-1PKIX CRL\s0 Extensions"
  307. .IX Subsection "PKIX CRL Extensions"
  308. The following are \s-1CRL\s0 extensions from \s-1PKIX\s0 standards such as \s-1RFC5280.\s0
  309. .PP
  310. .Vb 6
  311. \& CRL Number NID_crl_number
  312. \& CRL Distribution Points NID_crl_distribution_points
  313. \& Delta CRL Indicator NID_delta_crl
  314. \& Freshest CRL NID_freshest_crl
  315. \& Invalidity Date NID_invalidity_date
  316. \& Issuing Distribution Point NID_issuing_distribution_point
  317. .Ve
  318. .PP
  319. The following are \s-1CRL\s0 entry extensions from \s-1PKIX\s0 standards such as \s-1RFC5280.\s0
  320. .PP
  321. .Vb 2
  322. \& CRL Reason Code NID_crl_reason
  323. \& Certificate Issuer NID_certificate_issuer
  324. .Ve
  325. .SS "\s-1OCSP\s0 Extensions"
  326. .IX Subsection "OCSP Extensions"
  327. .Vb 7
  328. \& OCSP Nonce NID_id_pkix_OCSP_Nonce
  329. \& OCSP CRL ID NID_id_pkix_OCSP_CrlID
  330. \& Acceptable OCSP Responses NID_id_pkix_OCSP_acceptableResponses
  331. \& OCSP No Check NID_id_pkix_OCSP_noCheck
  332. \& OCSP Archive Cutoff NID_id_pkix_OCSP_archiveCutoff
  333. \& OCSP Service Locator NID_id_pkix_OCSP_serviceLocator
  334. \& Hold Instruction Code NID_hold_instruction_code
  335. .Ve
  336. .SS "Certificate Transparency Extensions"
  337. .IX Subsection "Certificate Transparency Extensions"
  338. The following extensions are used by certificate transparency, \s-1RFC6962\s0
  339. .PP
  340. .Vb 2
  341. \& CT Precertificate SCTs NID_ct_precert_scts
  342. \& CT Certificate SCTs NID_ct_cert_scts
  343. .Ve
  344. .SH "RETURN VALUES"
  345. .IX Header "RETURN VALUES"
  346. \&\fBX509V3_get_d2i()\fR, its variants, and \fBX509V3_EXT_d2i()\fR return
  347. a pointer to an extension specific structure or \s-1NULL\s0 if an error occurs.
  348. .PP
  349. \&\fBX509V3_add1_i2d()\fR and its variants return 1 if the operation is successful
  350. and 0 if it fails due to a non-fatal error (extension not found, already exists,
  351. cannot be encoded) or \-1 due to a fatal error such as a memory allocation
  352. failure.
  353. .PP
  354. \&\fBX509V3_EXT_i2d()\fR returns a pointer to an \fBX509_EXTENSION\fR structure
  355. or \s-1NULL\s0 if an error occurs.
  356. .PP
  357. \&\fBX509_get0_extensions()\fR, \fBX509_CRL_get0_extensions()\fR and
  358. \&\fBX509_REVOKED_get0_extensions()\fR return a stack of extensions. They return
  359. \&\s-1NULL\s0 if no extensions are present.
  360. .SH "SEE ALSO"
  361. .IX Header "SEE ALSO"
  362. \&\fBd2i_X509\fR\|(3),
  363. \&\fBERR_get_error\fR\|(3),
  364. \&\fBX509_CRL_get0_by_serial\fR\|(3),
  365. \&\fBX509_get0_signature\fR\|(3),
  366. \&\fBX509_get_ext_d2i\fR\|(3),
  367. \&\fBX509_get_extension_flags\fR\|(3),
  368. \&\fBX509_get_pubkey\fR\|(3),
  369. \&\fBX509_get_subject_name\fR\|(3),
  370. \&\fBX509_get_version\fR\|(3),
  371. \&\fBX509_NAME_add_entry_by_txt\fR\|(3),
  372. \&\fBX509_NAME_ENTRY_get_object\fR\|(3),
  373. \&\fBX509_NAME_get_index_by_NID\fR\|(3),
  374. \&\fBX509_NAME_print_ex\fR\|(3),
  375. \&\fBX509_new\fR\|(3),
  376. \&\fBX509_sign\fR\|(3),
  377. \&\fBX509_verify_cert\fR\|(3)
  378. .SH "COPYRIGHT"
  379. .IX Header "COPYRIGHT"
  380. Copyright 2015\-2024 The OpenSSL Project Authors. All Rights Reserved.
  381. .PP
  382. Licensed under the Apache License 2.0 (the \*(L"License\*(R"). You may not use
  383. this file except in compliance with the License. You can obtain a copy
  384. in the file \s-1LICENSE\s0 in the source distribution or at
  385. <https://www.openssl.org/source/license.html>.