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