1X509_NAME_add_entry_by_txt(3)       OpenSSL      X509_NAME_add_entry_by_txt(3)
2
3
4

NAME

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

SYNOPSIS

11       int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int
12       type, const unsigned char *bytes, int len, int loc, int set);
13
14       int X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int
15       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,
18       unsigned char *bytes, int len, int loc, int set);
19
20       int X509_NAME_add_entry(X509_NAME *name,X509_NAME_ENTRY *ne, int loc,
21       int set);
22
23       X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc);
24

DESCRIPTION

26       X509_NAME_add_entry_by_txt(), X509_NAME_add_entry_by_OBJ() and
27       X509_NAME_add_entry_by_NID() add a field whose name is defined by a
28       string field, an object obj or a NID nid respectively.  The field value
29       to be added is in bytes of length len. If len is -1 then the field
30       length is calculated internally using strlen(bytes).
31
32       The type of field is determined by type which can either be a defini‐
33       tion of the type of bytes (such as MBSTRING_ASC) or a standard ASN1
34       type (such as V_ASN1_IA5STRING). The new entry is added to a position
35       determined by loc and set.
36
37       X509_NAME_add_entry() adds a copy of X509_NAME_ENTRY structure ne to
38       name. The new entry is added to a position determined by loc and set.
39       Since a copy of ne is added ne must be freed up after the call.
40
41       X509_NAME_delete_entry() deletes an entry from name at position loc.
42       The deleted entry is returned and must be freed up.
43

NOTES

45       The use of string types such as MBSTRING_ASC or MBSTRING_UTF8 is
46       strongly recommened for the type parameter. This allows the internal
47       code to correctly determine the type of the field and to apply length
48       checks according to the relevant standards. This is done using
49       ASN1_STRING_set_by_NID().
50
51       If instead an ASN1 type is used no checks are performed and the sup‐
52       plied data in bytes is used directly.
53
54       In X509_NAME_add_entry_by_txt() the field string represents the field
55       name using OBJ_txt2obj(field, 0).
56
57       The loc and set parameters determine where a new entry should be added.
58       For almost all applications loc can be set to -1 and set to 0. This
59       adds a new entry to the end of name as a single valued RelativeDistin‐
60       guishedName (RDN).
61
62       loc actually determines the index where the new entry is inserted: if
63       it is -1 it is appended.
64
65       set determines how the new type is added. If it is zero a new RDN is
66       created.
67
68       If set is -1 or 1 it is added to the previous or next RDN structure
69       respectively. This will then be a multivalued RDN: since multivalues
70       RDNs are very seldom used set is almost always set to zero.
71

EXAMPLES

73       Create an X509_NAME structure:
74
75       "C=UK, O=Disorganized Organization, CN=Joe Bloggs"
76
77        X509_NAME *nm;
78        nm = X509_NAME_new();
79        if (nm == NULL)
80               /* Some error */
81        if (!X509_NAME_add_entry_by_txt(nm, MBSTRING_ASC,
82                               "C", "UK", -1, -1, 0))
83               /* Error */
84        if (!X509_NAME_add_entry_by_txt(nm, MBSTRING_ASC,
85                               "O", "Disorganized Organization", -1, -1, 0))
86               /* Error */
87        if (!X509_NAME_add_entry_by_txt(nm, MBSTRING_ASC,
88                               "CN", "Joe Bloggs", -1, -1, 0))
89               /* Error */
90

RETURN VALUES

92       X509_NAME_add_entry_by_txt(), X509_NAME_add_entry_by_OBJ(),
93       X509_NAME_add_entry_by_NID() and X509_NAME_add_entry() return 1 for
94       success of 0 if an error occurred.
95
96       X509_NAME_delete_entry() returns either the deleted X509_NAME_ENTRY
97       structure of NULL if an error occurred.
98

BUGS

100       type can still be set to V_ASN1_APP_CHOOSE to use a different algorithm
101       to determine field types. Since this form does not understand multi‐
102       character types, performs no length checks and can result in invalid
103       field types its use is strongly discouraged.
104

SEE ALSO

106       ERR_get_error(3), d2i_X509_NAME(3)
107

HISTORY

1090.9.8b                            2005-03-30     X509_NAME_add_entry_by_txt(3)
Impressum