X509_REQ_get_attr.3ossl 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. .\" -*- mode: troff; coding: utf-8 -*-
  2. .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
  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 "X509_REQ_GET_ATTR 3ossl"
  58. .TH X509_REQ_GET_ATTR 3ossl 2025-01-17 3.4.0 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. X509_REQ_get_attr_count,
  65. X509_REQ_get_attr_by_NID, X509_REQ_get_attr_by_OBJ, X509_REQ_get_attr,
  66. X509_REQ_delete_attr,
  67. X509_REQ_add1_attr, X509_REQ_add1_attr_by_OBJ, X509_REQ_add1_attr_by_NID,
  68. X509_REQ_add1_attr_by_txt
  69. \&\- X509_ATTRIBUTE support for signed certificate requests
  70. .SH SYNOPSIS
  71. .IX Header "SYNOPSIS"
  72. .Vb 1
  73. \& #include <openssl/x509.h>
  74. \&
  75. \& int X509_REQ_get_attr_count(const X509_REQ *req);
  76. \& int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, int lastpos);
  77. \& int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, const ASN1_OBJECT *obj,
  78. \& int lastpos);
  79. \& X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc);
  80. \& X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc);
  81. \& int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr);
  82. \& int X509_REQ_add1_attr_by_OBJ(X509_REQ *req,
  83. \& const ASN1_OBJECT *obj, int type,
  84. \& const unsigned char *bytes, int len);
  85. \& int X509_REQ_add1_attr_by_NID(X509_REQ *req,
  86. \& int nid, int type,
  87. \& const unsigned char *bytes, int len);
  88. \& int X509_REQ_add1_attr_by_txt(X509_REQ *req,
  89. \& const char *attrname, int type,
  90. \& const unsigned char *bytes, int len);
  91. .Ve
  92. .SH DESCRIPTION
  93. .IX Header "DESCRIPTION"
  94. \&\fBX509_REQ_get_attr_by_OBJ()\fR finds the location of the first matching object \fIobj\fR
  95. in the \fIreq\fR attribute list. The search starts at the position after \fIlastpos\fR.
  96. If the returned value is positive then it can be used on the next call to
  97. \&\fBX509_REQ_get_attr_by_OBJ()\fR as the value of \fIlastpos\fR in order to iterate through
  98. the remaining attributes. \fIlastpos\fR can be set to any negative value on the
  99. first call, in order to start searching from the start of the attribute list.
  100. .PP
  101. \&\fBX509_REQ_get_attr_by_NID()\fR is similar to \fBX509_REQ_get_attr_by_OBJ()\fR except that
  102. it passes the numerical identifier (NID) \fInid\fR associated with the object.
  103. See <openssl/obj_mac.h> for a list of NID_*.
  104. .PP
  105. \&\fBX509_REQ_get_attr()\fR returns the \fBX509_ATTRIBUTE\fR object at index \fIloc\fR in the
  106. \&\fIreq\fR attribute list. \fIloc\fR should be in the range from 0 to
  107. \&\fBX509_REQ_get_attr_count()\fR \- 1.
  108. .PP
  109. \&\fBX509_REQ_delete_attr()\fR removes the \fBX509_ATTRIBUTE\fR object at index \fIloc\fR in
  110. the \fIreq\fR objects list of attributes. An error occurs if \fIreq\fR is NULL.
  111. .PP
  112. \&\fBX509_REQ_add1_attr()\fR pushes a copy of the passed in \fBX509_ATTRIBUTE\fR \fRattr>
  113. to the \fIreq\fR object's attribute list. An error will occur if either the
  114. attribute list is NULL or the attribute already exists.
  115. .PP
  116. \&\fBX509_REQ_add1_attr_by_OBJ()\fR creates a new \fBX509_ATTRIBUTE\fR using
  117. \&\fBX509_ATTRIBUTE_set1_object()\fR and \fBX509_ATTRIBUTE_set1_data()\fR to assign a new
  118. \&\fIobj\fR with type \fItype\fR and data \fIbytes\fR of length \fIlen\fR and then pushes it
  119. to the \fIreq\fR object's attribute list. \fIreq\fR must be non NULL or an error
  120. will occur. If \fIobj\fR already exists in the attribute list then an error occurs.
  121. .PP
  122. \&\fBX509_REQ_add1_attr_by_NID()\fR is similar to \fBX509_REQ_add1_attr_by_OBJ()\fR except
  123. that it passes the numerical identifier (NID) \fInid\fR associated with the object.
  124. See <openssl/obj_mac.h> for a list of NID_*.
  125. .PP
  126. \&\fBX509_REQ_add1_attr_by_txt()\fR is similar to \fBX509_REQ_add1_attr_by_OBJ()\fR except
  127. that it passes a name \fIattrname\fR associated with the object.
  128. See <openssl/obj_mac.h> for a list of SN_* names.
  129. .PP
  130. Refer to \fBX509_ATTRIBUTE\fR\|(3) for information related to attributes.
  131. .SH "RETURN VALUES"
  132. .IX Header "RETURN VALUES"
  133. \&\fBX509_REQ_get_attr_count()\fR returns the number of attributes in the \fIreq\fR object
  134. attribute list or \-1 if the attribute list is NULL.
  135. .PP
  136. \&\fBX509_REQ_get_attr_by_OBJ()\fR returns \-1 if either the \fIreq\fR object's attribute
  137. list is empty OR \fIobj\fR is not found, otherwise it returns the location of the
  138. \&\fIobj\fR in the attribute list.
  139. .PP
  140. \&\fBX509_REQ_get_attr_by_NID()\fR is similar to \fBX509_REQ_get_attr_by_OBJ()\fR, except that
  141. it returns \-2 if the \fInid\fR is not known by OpenSSL.
  142. .PP
  143. \&\fBX509_REQ_get_attr()\fR returns either an \fBX509_ATTRIBUTE\fR or NULL on error.
  144. .PP
  145. \&\fBX509_REQ_delete_attr()\fR returns either the removed \fBX509_ATTRIBUTE\fR or NULL if
  146. there is a error.
  147. .PP
  148. \&\fBX509_REQ_add1_attr()\fR, \fBX509_REQ_add1_attr_by_OBJ()\fR, \fBX509_REQ_add1_attr_by_NID()\fR
  149. and \fBX509_REQ_add1_attr_by_txt()\fR return 1 on success or 0 on error.
  150. .SH NOTES
  151. .IX Header "NOTES"
  152. Any functions that modify the attributes (add or delete) internally set a flag
  153. to indicate the ASN.1 encoding has been modified.
  154. .SH "SEE ALSO"
  155. .IX Header "SEE ALSO"
  156. \&\fBX509_ATTRIBUTE\fR\|(3)
  157. .SH COPYRIGHT
  158. .IX Header "COPYRIGHT"
  159. Copyright 2023\-2024 The OpenSSL Project Authors. All Rights Reserved.
  160. .PP
  161. Licensed under the Apache License 2.0 (the "License"). You may not use
  162. this file except in compliance with the License. You can obtain a copy
  163. in the file LICENSE in the source distribution or at
  164. <https://www.openssl.org/source/license.html>.