X509_REQ_get_attr.pod 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. =pod
  2. =head1 NAME
  3. X509_REQ_get_attr_count,
  4. X509_REQ_get_attr_by_NID, X509_REQ_get_attr_by_OBJ, X509_REQ_get_attr,
  5. X509_REQ_delete_attr,
  6. X509_REQ_add1_attr, X509_REQ_add1_attr_by_OBJ, X509_REQ_add1_attr_by_NID,
  7. X509_REQ_add1_attr_by_txt
  8. - B<X509_ATTRIBUTE> support for signed certificate requests
  9. =head1 SYNOPSIS
  10. #include <openssl/x509.h>
  11. int X509_REQ_get_attr_count(const X509_REQ *req);
  12. int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, int lastpos);
  13. int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, const ASN1_OBJECT *obj,
  14. int lastpos);
  15. X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc);
  16. X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc);
  17. int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr);
  18. int X509_REQ_add1_attr_by_OBJ(X509_REQ *req,
  19. const ASN1_OBJECT *obj, int type,
  20. const unsigned char *bytes, int len);
  21. int X509_REQ_add1_attr_by_NID(X509_REQ *req,
  22. int nid, int type,
  23. const unsigned char *bytes, int len);
  24. int X509_REQ_add1_attr_by_txt(X509_REQ *req,
  25. const char *attrname, int type,
  26. const unsigned char *bytes, int len);
  27. =head1 DESCRIPTION
  28. X509_REQ_get_attr_by_OBJ() finds the location of the first matching object I<obj>
  29. in the I<req> attribute list. The search starts at the position after I<lastpos>.
  30. If the returned value is positive then it can be used on the next call to
  31. X509_REQ_get_attr_by_OBJ() as the value of I<lastpos> in order to iterate through
  32. the remaining attributes. I<lastpos> can be set to any negative value on the
  33. first call, in order to start searching from the start of the attribute list.
  34. X509_REQ_get_attr_by_NID() is similar to X509_REQ_get_attr_by_OBJ() except that
  35. it passes the numerical identifier (NID) I<nid> associated with the object.
  36. See <openssl/obj_mac.h> for a list of NID_*.
  37. X509_REQ_get_attr() returns the B<X509_ATTRIBUTE> object at index I<loc> in the
  38. I<req> attribute list. I<loc> should be in the range from 0 to
  39. X509_REQ_get_attr_count() - 1.
  40. X509_REQ_delete_attr() removes the B<X509_ATTRIBUTE> object at index I<loc> in
  41. the I<req> objects list of attributes. An error occurs if I<req> is NULL.
  42. X509_REQ_add1_attr() pushes a copy of the passed in B<X509_ATTRIBUTE> I<>attr>
  43. to the I<req> object's attribute list. An error will occur if either the
  44. attribute list is NULL or the attribute already exists.
  45. X509_REQ_add1_attr_by_OBJ() creates a new B<X509_ATTRIBUTE> using
  46. X509_ATTRIBUTE_set1_object() and X509_ATTRIBUTE_set1_data() to assign a new
  47. I<obj> with type I<type> and data I<bytes> of length I<len> and then pushes it
  48. to the I<req> object's attribute list. I<req> must be non NULL or an error
  49. will occur. If I<obj> already exists in the attribute list then an error occurs.
  50. X509_REQ_add1_attr_by_NID() is similar to X509_REQ_add1_attr_by_OBJ() except
  51. that it passes the numerical identifier (NID) I<nid> associated with the object.
  52. See <openssl/obj_mac.h> for a list of NID_*.
  53. X509_REQ_add1_attr_by_txt() is similar to X509_REQ_add1_attr_by_OBJ() except
  54. that it passes a name I<attrname> associated with the object.
  55. See <openssl/obj_mac.h> for a list of SN_* names.
  56. Refer to L<X509_ATTRIBUTE(3)> for information related to attributes.
  57. =head1 RETURN VALUES
  58. X509_REQ_get_attr_count() returns the number of attributes in the I<req> object
  59. attribute list or -1 if the attribute list is NULL.
  60. X509_REQ_get_attr_by_OBJ() returns -1 if either the I<req> object's attribute
  61. list is empty OR I<obj> is not found, otherwise it returns the location of the
  62. I<obj> in the attribute list.
  63. X509_REQ_get_attr_by_NID() is similar to X509_REQ_get_attr_by_OBJ(), except that
  64. it returns -2 if the I<nid> is not known by OpenSSL.
  65. X509_REQ_get_attr() returns either an B<X509_ATTRIBUTE> or NULL on error.
  66. X509_REQ_delete_attr() returns either the removed B<X509_ATTRIBUTE> or NULL if
  67. there is a error.
  68. X509_REQ_add1_attr(), X509_REQ_add1_attr_by_OBJ(), X509_REQ_add1_attr_by_NID()
  69. and X509_REQ_add1_attr_by_txt() return 1 on success or 0 on error.
  70. =head1 NOTES
  71. Any functions that modify the attributes (add or delete) internally set a flag
  72. to indicate the ASN.1 encoding has been modified.
  73. =head1 SEE ALSO
  74. L<X509_ATTRIBUTE(3)>
  75. =head1 COPYRIGHT
  76. Copyright 2023-2024 The OpenSSL Project Authors. All Rights Reserved.
  77. Licensed under the Apache License 2.0 (the "License"). You may not use
  78. this file except in compliance with the License. You can obtain a copy
  79. in the file LICENSE in the source distribution or at
  80. L<https://www.openssl.org/source/license.html>.
  81. =cut