X509_NAME_add_entry_by_txt.pod 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. =pod
  2. =head1 NAME
  3. X509_NAME_add_entry_by_txt, X509_NAME_add_entry_by_OBJ, X509_NAME_add_entry_by_NID,
  4. X509_NAME_add_entry, X509_NAME_delete_entry - X509_NAME modification functions
  5. =head1 SYNOPSIS
  6. #include <openssl/x509.h>
  7. int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type, const unsigned char *bytes, int len, int loc, int set);
  8. int X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int type, unsigned char *bytes, int len, int loc, int set);
  9. int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type, unsigned char *bytes, int len, int loc, int set);
  10. int X509_NAME_add_entry(X509_NAME *name,X509_NAME_ENTRY *ne, int loc, int set);
  11. X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc);
  12. =head1 DESCRIPTION
  13. X509_NAME_add_entry_by_txt(), X509_NAME_add_entry_by_OBJ() and
  14. X509_NAME_add_entry_by_NID() add a field whose name is defined
  15. by a string B<field>, an object B<obj> or a NID B<nid> respectively.
  16. The field value to be added is in B<bytes> of length B<len>. If
  17. B<len> is -1 then the field length is calculated internally using
  18. strlen(bytes).
  19. The type of field is determined by B<type> which can either be a
  20. definition of the type of B<bytes> (such as B<MBSTRING_ASC>) or a
  21. standard ASN1 type (such as B<V_ASN1_IA5STRING>). The new entry is
  22. added to a position determined by B<loc> and B<set>.
  23. X509_NAME_add_entry() adds a copy of B<X509_NAME_ENTRY> structure B<ne>
  24. to B<name>. The new entry is added to a position determined by B<loc>
  25. and B<set>. Since a copy of B<ne> is added B<ne> must be freed up after
  26. the call.
  27. X509_NAME_delete_entry() deletes an entry from B<name> at position
  28. B<loc>. The deleted entry is returned and must be freed up.
  29. =head1 NOTES
  30. The use of string types such as B<MBSTRING_ASC> or B<MBSTRING_UTF8>
  31. is strongly recommened for the B<type> parameter. This allows the
  32. internal code to correctly determine the type of the field and to
  33. apply length checks according to the relevant standards. This is
  34. done using ASN1_STRING_set_by_NID().
  35. If instead an ASN1 type is used no checks are performed and the
  36. supplied data in B<bytes> is used directly.
  37. In X509_NAME_add_entry_by_txt() the B<field> string represents
  38. the field name using OBJ_txt2obj(field, 0).
  39. The B<loc> and B<set> parameters determine where a new entry should
  40. be added. For almost all applications B<loc> can be set to -1 and B<set>
  41. to 0. This adds a new entry to the end of B<name> as a single valued
  42. RelativeDistinguishedName (RDN).
  43. B<loc> actually determines the index where the new entry is inserted:
  44. if it is -1 it is appended.
  45. B<set> determines how the new type is added. If it is zero a
  46. new RDN is created.
  47. If B<set> is -1 or 1 it is added to the previous or next RDN
  48. structure respectively. This will then be a multivalued RDN:
  49. since multivalues RDNs are very seldom used B<set> is almost
  50. always set to zero.
  51. =head1 EXAMPLES
  52. Create an B<X509_NAME> structure:
  53. "C=UK, O=Disorganized Organization, CN=Joe Bloggs"
  54. X509_NAME *nm;
  55. nm = X509_NAME_new();
  56. if (nm == NULL)
  57. /* Some error */
  58. if (!X509_NAME_add_entry_by_txt(nm, MBSTRING_ASC,
  59. "C", "UK", -1, -1, 0))
  60. /* Error */
  61. if (!X509_NAME_add_entry_by_txt(nm, MBSTRING_ASC,
  62. "O", "Disorganized Organization", -1, -1, 0))
  63. /* Error */
  64. if (!X509_NAME_add_entry_by_txt(nm, MBSTRING_ASC,
  65. "CN", "Joe Bloggs", -1, -1, 0))
  66. /* Error */
  67. =head1 RETURN VALUES
  68. X509_NAME_add_entry_by_txt(), X509_NAME_add_entry_by_OBJ(),
  69. X509_NAME_add_entry_by_NID() and X509_NAME_add_entry() return 1 for
  70. success of 0 if an error occurred.
  71. X509_NAME_delete_entry() returns either the deleted B<X509_NAME_ENTRY>
  72. structure of B<NULL> if an error occurred.
  73. =head1 BUGS
  74. B<type> can still be set to B<V_ASN1_APP_CHOOSE> to use a
  75. different algorithm to determine field types. Since this form does
  76. not understand multicharacter types, performs no length checks and
  77. can result in invalid field types its use is strongly discouraged.
  78. =head1 SEE ALSO
  79. L<ERR_get_error(3)|ERR_get_error(3)>, L<d2i_X509_NAME(3)|d2i_X509_NAME(3)>
  80. =head1 HISTORY
  81. =cut