1 .\" $OpenBSD: X509_NAME_add_entry_by_txt.3,v 1.7 2017/01/06 03:00:56 schwarze Exp $
2 .\" OpenSSL aebb9aac Jul 19 09:27:53 2016 -0400
4 .\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5 .\" Copyright (c) 2002, 2005, 2006, 2013, 2014 The OpenSSL Project.
6 .\" All rights reserved.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
15 .\" 2. Redistributions in binary form must reproduce the above copyright
16 .\" notice, this list of conditions and the following disclaimer in
17 .\" the documentation and/or other materials provided with the
20 .\" 3. All advertising materials mentioning features or use of this
21 .\" software must display the following acknowledgment:
22 .\" "This product includes software developed by the OpenSSL Project
23 .\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25 .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 .\" endorse or promote products derived from this software without
27 .\" prior written permission. For written permission, please contact
28 .\" openssl-core@openssl.org.
30 .\" 5. Products derived from this software may not be called "OpenSSL"
31 .\" nor may "OpenSSL" appear in their names without prior written
32 .\" permission of the OpenSSL Project.
34 .\" 6. Redistributions of any form whatsoever must retain the following
36 .\" "This product includes software developed by the OpenSSL Project
37 .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39 .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 .\" OF THE POSSIBILITY OF SUCH DAMAGE.
52 .Dd $Mdocdate: January 6 2017 $
53 .Dt X509_NAME_ADD_ENTRY_BY_TXT 3
56 .Nm X509_NAME_add_entry_by_txt ,
57 .Nm X509_NAME_add_entry_by_OBJ ,
58 .Nm X509_NAME_add_entry_by_NID ,
59 .Nm X509_NAME_add_entry ,
60 .Nm X509_NAME_delete_entry
61 .Nd X509_NAME modification functions
65 .Fo X509_NAME_add_entry_by_txt
67 .Fa "const char *field"
69 .Fa "const unsigned char *bytes"
75 .Fo X509_NAME_add_entry_by_OBJ
77 .Fa "ASN1_OBJECT *obj"
79 .Fa "unsigned char *bytes"
85 .Fo X509_NAME_add_entry_by_NID
89 .Fa "unsigned char *bytes"
95 .Fo X509_NAME_add_entry
97 .Fa "X509_NAME_ENTRY *ne"
101 .Ft X509_NAME_ENTRY *
102 .Fo X509_NAME_delete_entry
103 .Fa "X509_NAME *name"
107 .Fn X509_NAME_add_entry_by_txt ,
108 .Fn X509_NAME_add_entry_by_OBJ ,
110 .Fn X509_NAME_add_entry_by_NID
111 add a field whose name is defined by a string
118 The field value to be added is in
124 is -1 then the field length is calculated internally using
127 The type of field is determined by
129 which can either be a definition of the type of
133 or a standard ASN.1 type (such as
134 .Dv V_ASN1_IA5STRING ) .
135 The new entry is added to a position determined by
140 .Fn X509_NAME_add_entry
147 The new entry is added to a position determined by
155 must be freed up after the call.
157 .Fn X509_NAME_delete_entry
158 deletes an entry from
162 The deleted entry is returned and must be freed up.
164 The use of string types such as
168 is strongly recommended for the
171 This allows the internal code to correctly determine the type of the
172 field and to apply length checks according to the relevant standards.
174 If instead an ASN.1 type is used, no checks are performed and the supplied
180 .Fn X509_NAME_add_entry_by_txt
183 string represents the field name using
184 .Fn OBJ_txt2obj field 0 .
190 parameters determine where a new entry should be added.
191 For almost all applications,
196 This adds a new entry to the end of
199 .Vt RelativeDistinguishedName
203 actually determines the index where the new entry is inserted:
204 if it is -1 it is appended.
207 determines how the new type is added.
208 If it is zero a new RDN is created.
212 is -1 or 1 it is added to the previous or next RDN structure
214 This will then be a multivalued RDN: since multivalue RDNs are very
217 is almost always set to zero.
219 .Fn X509_NAME_add_entry_by_txt ,
220 .Fn X509_NAME_add_entry_by_OBJ ,
221 .Fn X509_NAME_add_entry_by_NID ,
223 .Fn X509_NAME_add_entry
224 return 1 for success or 0 if an error occurred.
226 .Fn X509_NAME_delete_entry
227 returns either the deleted
231 if an error occurred.
236 .Bd -literal -offset indent
237 C=UK, O=Disorganized Organization, CN=Joe Bloggs
240 nm = X509_NAME_new();
243 if (!X509_NAME_add_entry_by_txt(nm, "C", MBSTRING_ASC,
246 if (!X509_NAME_add_entry_by_txt(nm, "O", MBSTRING_ASC,
247 "Disorganized Organization", -1, -1, 0))
249 if (!X509_NAME_add_entry_by_txt(nm, "CN", MBSTRING_ASC,
250 "Joe Bloggs", -1, -1, 0))
254 .Xr d2i_X509_NAME 3 ,
255 .Xr ERR_get_error 3 ,
256 .Xr X509_NAME_get_index_by_NID 3 ,
261 .Dv V_ASN1_APP_CHOOSE
262 to use a different algorithm to determine field types.
263 Since this form does not understand multicharacter types, performs
264 no length checks, and can result in invalid field types, its use
265 is strongly discouraged.