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        #include <openssl/x509.h>
12
13        int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type,
14                                       const unsigned char *bytes, int len, int loc, int set);
15
16        int X509_NAME_add_entry_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, int type,
17                                       const unsigned char *bytes, int len, int loc, int set);
18
19        int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type,
20                                       const unsigned char *bytes, int len, int loc, int set);
21
22        int X509_NAME_add_entry(X509_NAME *name, const X509_NAME_ENTRY *ne, int loc, int set);
23
24        X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc);
25

DESCRIPTION

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

NOTES

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

RETURN VALUES

74       X509_NAME_add_entry_by_txt(), X509_NAME_add_entry_by_OBJ(),
75       X509_NAME_add_entry_by_NID() and X509_NAME_add_entry() return 1 for
76       success of 0 if an error occurred.
77
78       X509_NAME_delete_entry() returns either the deleted X509_NAME_ENTRY
79       structure of NULL if an error occurred.
80

EXAMPLES

82       Create an X509_NAME structure:
83
84       "C=UK, O=Disorganized Organization, CN=Joe Bloggs"
85
86        X509_NAME *nm;
87
88        nm = X509_NAME_new();
89        if (nm == NULL)
90            /* Some error */
91        if (!X509_NAME_add_entry_by_txt(nm, "C", MBSTRING_ASC,
92                                        "UK", -1, -1, 0))
93            /* Error */
94        if (!X509_NAME_add_entry_by_txt(nm, "O", MBSTRING_ASC,
95                                        "Disorganized Organization", -1, -1, 0))
96            /* Error */
97        if (!X509_NAME_add_entry_by_txt(nm, "CN", MBSTRING_ASC,
98                                        "Joe Bloggs", -1, -1, 0))
99            /* Error */
100

BUGS

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

SEE ALSO

108       ERR_get_error(3), d2i_X509_NAME(3)
109
111       Copyright 2002-2019 The OpenSSL Project Authors. All Rights Reserved.
112
113       Licensed under the OpenSSL license (the "License").  You may not use
114       this file except in compliance with the License.  You can obtain a copy
115       in the file LICENSE in the source distribution or at
116       <https://www.openssl.org/source/license.html>.
117
118
119
1201.1.1q                            2023-02-06     X509_NAME_ADD_ENTRY_BY_TXT(3)
Impressum