1X509_NAME_ADD_ENTRY_BY_TXT(3ossl)   OpenSSL  X509_NAME_ADD_ENTRY_BY_TXT(3ossl)
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 as a new set member to the previous or
70       next RDN structure, respectively.  This will then become part of a
71       multi-valued RDN (containing a set of AVAs).  Since multi-valued RDNs
72       are very rarely used set typically will be zero.
73

RETURN VALUES

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

EXAMPLES

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

BUGS

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

SEE ALSO

109       ERR_get_error(3), d2i_X509_NAME(3)
110
112       Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved.
113
114       Licensed under the Apache License 2.0 (the "License").  You may not use
115       this file except in compliance with the License.  You can obtain a copy
116       in the file LICENSE in the source distribution or at
117       <https://www.openssl.org/source/license.html>.
118
119
120
1213.1.1                             2023-08-31 X509_NAME_ADD_ENTRY_BY_TXT(3ossl)
Impressum