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