5 X509_NAME_add_entry_by_txt, X509_NAME_add_entry_by_OBJ, X509_NAME_add_entry_by_NID,
6 X509_NAME_add_entry, X509_NAME_delete_entry - X509_NAME modification functions
10 #include <openssl/x509.h>
12 int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type,
13 const unsigned char *bytes, int len, int loc, int set);
15 int X509_NAME_add_entry_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, int type,
16 const unsigned char *bytes, int len, int loc, int set);
18 int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type,
19 const unsigned char *bytes, int len, int loc, int set);
21 int X509_NAME_add_entry(X509_NAME *name, const X509_NAME_ENTRY *ne, int loc, int set);
23 X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc);
27 X509_NAME_add_entry_by_txt(), X509_NAME_add_entry_by_OBJ() and
28 X509_NAME_add_entry_by_NID() add a field whose name is defined
29 by a string B<field>, an object B<obj> or a NID B<nid> respectively.
30 The field value to be added is in B<bytes> of length B<len>. If
31 B<len> is -1 then the field length is calculated internally using
34 The type of field is determined by B<type> which can either be a
35 definition of the type of B<bytes> (such as B<MBSTRING_ASC>) or a
36 standard ASN1 type (such as B<V_ASN1_IA5STRING>). The new entry is
37 added to a position determined by B<loc> and B<set>.
39 X509_NAME_add_entry() adds a copy of B<X509_NAME_ENTRY> structure B<ne>
40 to B<name>. The new entry is added to a position determined by B<loc>
41 and B<set>. Since a copy of B<ne> is added B<ne> must be freed up after
44 X509_NAME_delete_entry() deletes an entry from B<name> at position
45 B<loc>. The deleted entry is returned and must be freed up.
49 The use of string types such as B<MBSTRING_ASC> or B<MBSTRING_UTF8>
50 is strongly recommended for the B<type> parameter. This allows the
51 internal code to correctly determine the type of the field and to
52 apply length checks according to the relevant standards. This is
53 done using ASN1_STRING_set_by_NID().
55 If instead an ASN1 type is used no checks are performed and the
56 supplied data in B<bytes> is used directly.
58 In X509_NAME_add_entry_by_txt() the B<field> string represents
59 the field name using OBJ_txt2obj(field, 0).
61 The B<loc> and B<set> parameters determine where a new entry should
62 be added. For almost all applications B<loc> can be set to -1 and B<set>
63 to 0. This adds a new entry to the end of B<name> as a single valued
64 RelativeDistinguishedName (RDN).
66 B<loc> actually determines the index where the new entry is inserted:
67 if it is -1 it is appended.
69 B<set> determines how the new type is added. If it is zero a
72 If B<set> is -1 or 1 it is added to the previous or next RDN
73 structure respectively. This will then be a multivalued RDN:
74 since multivalues RDNs are very seldom used B<set> is almost
79 X509_NAME_add_entry_by_txt(), X509_NAME_add_entry_by_OBJ(),
80 X509_NAME_add_entry_by_NID() and X509_NAME_add_entry() return 1 for
81 success of 0 if an error occurred.
83 X509_NAME_delete_entry() returns either the deleted B<X509_NAME_ENTRY>
84 structure of B<NULL> if an error occurred.
88 Create an B<X509_NAME> structure:
90 "C=UK, O=Disorganized Organization, CN=Joe Bloggs"
97 if (!X509_NAME_add_entry_by_txt(nm, "C", MBSTRING_ASC,
100 if (!X509_NAME_add_entry_by_txt(nm, "O", MBSTRING_ASC,
101 "Disorganized Organization", -1, -1, 0))
103 if (!X509_NAME_add_entry_by_txt(nm, "CN", MBSTRING_ASC,
104 "Joe Bloggs", -1, -1, 0))
109 B<type> can still be set to B<V_ASN1_APP_CHOOSE> to use a
110 different algorithm to determine field types. Since this form does
111 not understand multicharacter types, performs no length checks and
112 can result in invalid field types its use is strongly discouraged.
116 L<ERR_get_error(3)>, L<d2i_X509_NAME(3)>
120 Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
122 Licensed under the Apache License 2.0 (the "License"). You may not use
123 this file except in compliance with the License. You can obtain a copy
124 in the file LICENSE in the source distribution or at
125 L<https://www.openssl.org/source/license.html>.