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