Debian Codegraph @

upstream/debian-unstable/man3/X509_NAME_add_entry_by_txt.3ssl

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\" ========================================================================
56 .\"
57 .IX Title "X509_NAME_ADD_ENTRY_BY_TXT 3SSL"
58 .TH X509_NAME_ADD_ENTRY_BY_TXT 3SSL 2026-04-07 3.6.2 OpenSSL
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 X509_NAME_add_entry_by_txt, X509_NAME_add_entry_by_OBJ, X509_NAME_add_entry_by_NID,
65 X509_NAME_add_entry, X509_NAME_delete_entry \- X509_NAME modification functions
66 .SH SYNOPSIS
67 .IX Header "SYNOPSIS"
68 .Vb 1
69 \& #include <openssl/x509.h>
70 \&
71 \& int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type,
72 \& const unsigned char *bytes, int len, int loc, int set);
73 \&
74 \& int X509_NAME_add_entry_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, int type,
75 \& const unsigned char *bytes, int len, int loc, int set);
76 \&
77 \& int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type,
78 \& const unsigned char *bytes, int len, int loc, int set);
79 \&
80 \& int X509_NAME_add_entry(X509_NAME *name, const X509_NAME_ENTRY *ne, int loc, int set);
81 \&
82 \& X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc);
83 .Ve
84 .SH DESCRIPTION
85 .IX Header "DESCRIPTION"
86 \&\fBX509_NAME_add_entry_by_txt()\fR, \fBX509_NAME_add_entry_by_OBJ()\fR and
87 \&\fBX509_NAME_add_entry_by_NID()\fR add a field whose name is defined
88 by a string \fBfield\fR, an object \fBobj\fR or a NID \fBnid\fR respectively.
89 The field value to be added is in \fBbytes\fR of length \fBlen\fR. If
90 \&\fBlen\fR is \-1 then the field length is calculated internally using
91 strlen(bytes).
92 .PP
93 The type of field is determined by \fBtype\fR which can either be a
94 definition of the type of \fBbytes\fR (such as \fBMBSTRING_ASC\fR) or a
95 standard ASN1 type (such as \fBV_ASN1_IA5STRING\fR). The new entry is
96 added to a position determined by \fBloc\fR and \fBset\fR.
97 .PP
98 \&\fBX509_NAME_add_entry()\fR adds a copy of \fBX509_NAME_ENTRY\fR structure \fBne\fR
99 to \fBname\fR. The new entry is added to a position determined by \fBloc\fR
100 and \fBset\fR. Since a copy of \fBne\fR is added \fBne\fR must be freed up after
101 the call.
102 .PP
103 \&\fBX509_NAME_delete_entry()\fR deletes an entry from \fBname\fR at position
104 \&\fBloc\fR. The deleted entry is returned and must be freed up.
105 .SH NOTES
106 .IX Header "NOTES"
107 The use of string types such as \fBMBSTRING_ASC\fR or \fBMBSTRING_UTF8\fR
108 is strongly recommended for the \fBtype\fR parameter. This allows the
109 internal code to correctly determine the type of the field and to
110 apply length checks according to the relevant standards. This is
111 done using \fBASN1_STRING_set_by_NID()\fR.
112 .PP
113 If instead an ASN1 type is used no checks are performed and the
114 supplied data in \fBbytes\fR is used directly.
115 .PP
116 In \fBX509_NAME_add_entry_by_txt()\fR the \fBfield\fR string represents
117 the field name using OBJ_txt2obj(field, 0).
118 .PP
119 The \fBloc\fR and \fBset\fR parameters determine where a new entry should
120 be added. For almost all applications \fBloc\fR can be set to \-1 and \fBset\fR
121 to 0. This adds a new entry to the end of \fBname\fR as a single valued
122 RelativeDistinguishedName (RDN).
123 .PP
124 \&\fBloc\fR actually determines the index where the new entry is inserted:
125 if it is \-1 it is appended.
126 .PP
127 \&\fBset\fR determines how the new type is added.
128 If it is zero a new RDN is created.
129 .PP
130 If \fBset\fR is \-1 or 1 it is added as a new set member
131 to the previous or next RDN structure, respectively.
132 This will then become part of a multi-valued RDN (containing a set of AVAs).
133 Since multi-valued RDNs are very rarely used \fBset\fR typically will be zero.
134 .SH "RETURN VALUES"
135 .IX Header "RETURN VALUES"
136 \&\fBX509_NAME_add_entry_by_txt()\fR, \fBX509_NAME_add_entry_by_OBJ()\fR,
137 \&\fBX509_NAME_add_entry_by_NID()\fR and \fBX509_NAME_add_entry()\fR return 1 for
138 success of 0 if an error occurred.
139 .PP
140 \&\fBX509_NAME_delete_entry()\fR returns either the deleted \fBX509_NAME_ENTRY\fR
141 structure or \fBNULL\fR if an error occurred.
142 .SH EXAMPLES
143 .IX Header "EXAMPLES"
144 Create an \fBX509_NAME\fR structure:
145 .PP
146 "C=UK, O=Disorganized Organization, CN=Joe Bloggs"
147 .PP
148 .Vb 1
149 \& X509_NAME *nm;
150 \&
151 \& nm = X509_NAME_new();
152 \& if (nm == NULL)
153 \& /* Some error */
154 \& if (!X509_NAME_add_entry_by_txt(nm, "C", MBSTRING_ASC,
155 \& "UK", \-1, \-1, 0))
156 \& /* Error */
157 \& if (!X509_NAME_add_entry_by_txt(nm, "O", MBSTRING_ASC,
158 \& "Disorganized Organization", \-1, \-1, 0))
159 \& /* Error */
160 \& if (!X509_NAME_add_entry_by_txt(nm, "CN", MBSTRING_ASC,
161 \& "Joe Bloggs", \-1, \-1, 0))
162 \& /* Error */
163 .Ve
164 .SH BUGS
165 .IX Header "BUGS"
166 \&\fBtype\fR can still be set to \fBV_ASN1_APP_CHOOSE\fR to use a
167 different algorithm to determine field types. Since this form does
168 not understand multicharacter types, performs no length checks and
169 can result in invalid field types its use is strongly discouraged.
170 .SH "SEE ALSO"
171 .IX Header "SEE ALSO"
172 \&\fBERR_get_error\fR\|(3), \fBd2i_X509_NAME\fR\|(3)
173 .SH COPYRIGHT
174 .IX Header "COPYRIGHT"
175 Copyright 2002\-2020 The OpenSSL Project Authors. All Rights Reserved.
176 .PP
177 Licensed under the Apache License 2.0 (the "License"). You may not use
178 this file except in compliance with the License. You can obtain a copy
179 in the file LICENSE in the source distribution or at
180 <https://www.openssl.org/source/license.html>.