Blame doc/man3/X509_NAME_add_entry_by_txt.pod

Packit c4476c
=pod
Packit c4476c
Packit c4476c
=head1 NAME
Packit c4476c
Packit c4476c
X509_NAME_add_entry_by_txt, X509_NAME_add_entry_by_OBJ, X509_NAME_add_entry_by_NID,
Packit c4476c
X509_NAME_add_entry, X509_NAME_delete_entry - X509_NAME modification functions
Packit c4476c
Packit c4476c
=head1 SYNOPSIS
Packit c4476c
Packit c4476c
 #include <openssl/x509.h>
Packit c4476c
Packit c4476c
 int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type,
Packit c4476c
                                const unsigned char *bytes, int len, int loc, int set);
Packit c4476c
Packit c4476c
 int X509_NAME_add_entry_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, int type,
Packit c4476c
                                const unsigned char *bytes, int len, int loc, int set);
Packit c4476c
Packit c4476c
 int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type,
Packit c4476c
                                const unsigned char *bytes, int len, int loc, int set);
Packit c4476c
Packit c4476c
 int X509_NAME_add_entry(X509_NAME *name, const X509_NAME_ENTRY *ne, int loc, int set);
Packit c4476c
Packit c4476c
 X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc);
Packit c4476c
Packit c4476c
=head1 DESCRIPTION
Packit c4476c
Packit c4476c
X509_NAME_add_entry_by_txt(), X509_NAME_add_entry_by_OBJ() and
Packit c4476c
X509_NAME_add_entry_by_NID() add a field whose name is defined
Packit c4476c
by a string B<field>, an object B<obj> or a NID B<nid> respectively.
Packit c4476c
The field value to be added is in B<bytes> of length B<len>. If
Packit c4476c
B<len> is -1 then the field length is calculated internally using
Packit c4476c
strlen(bytes).
Packit c4476c
Packit c4476c
The type of field is determined by B<type> which can either be a
Packit c4476c
definition of the type of B<bytes> (such as B<MBSTRING_ASC>) or a
Packit c4476c
standard ASN1 type (such as B<V_ASN1_IA5STRING>). The new entry is
Packit c4476c
added to a position determined by B<loc> and B<set>.
Packit c4476c
Packit c4476c
X509_NAME_add_entry() adds a copy of B<X509_NAME_ENTRY> structure B<ne>
Packit c4476c
to B<name>. The new entry is added to a position determined by B<loc>
Packit c4476c
and B<set>. Since a copy of B<ne> is added B<ne> must be freed up after
Packit c4476c
the call.
Packit c4476c
Packit c4476c
X509_NAME_delete_entry() deletes an entry from B<name> at position
Packit c4476c
B<loc>. The deleted entry is returned and must be freed up.
Packit c4476c
Packit c4476c
=head1 NOTES
Packit c4476c
Packit c4476c
The use of string types such as B<MBSTRING_ASC> or B<MBSTRING_UTF8>
Packit c4476c
is strongly recommended for the B<type> parameter. This allows the
Packit c4476c
internal code to correctly determine the type of the field and to
Packit c4476c
apply length checks according to the relevant standards. This is
Packit c4476c
done using ASN1_STRING_set_by_NID().
Packit c4476c
Packit c4476c
If instead an ASN1 type is used no checks are performed and the
Packit c4476c
supplied data in B<bytes> is used directly.
Packit c4476c
Packit c4476c
In X509_NAME_add_entry_by_txt() the B<field> string represents
Packit c4476c
the field name using OBJ_txt2obj(field, 0).
Packit c4476c
Packit c4476c
The B<loc> and B<set> parameters determine where a new entry should
Packit c4476c
be added. For almost all applications B<loc> can be set to -1 and B<set>
Packit c4476c
to 0. This adds a new entry to the end of B<name> as a single valued
Packit c4476c
RelativeDistinguishedName (RDN).
Packit c4476c
Packit c4476c
B<loc> actually determines the index where the new entry is inserted:
Packit c4476c
if it is -1 it is appended.
Packit c4476c
Packit c4476c
B<set> determines how the new type is added. If it is zero a
Packit c4476c
new RDN is created.
Packit c4476c
Packit c4476c
If B<set> is -1 or 1 it is added to the previous or next RDN
Packit c4476c
structure respectively. This will then be a multivalued RDN:
Packit c4476c
since multivalues RDNs are very seldom used B<set> is almost
Packit c4476c
always set to zero.
Packit c4476c
Packit c4476c
=head1 RETURN VALUES
Packit c4476c
Packit c4476c
X509_NAME_add_entry_by_txt(), X509_NAME_add_entry_by_OBJ(),
Packit c4476c
X509_NAME_add_entry_by_NID() and X509_NAME_add_entry() return 1 for
Packit c4476c
success of 0 if an error occurred.
Packit c4476c
Packit c4476c
X509_NAME_delete_entry() returns either the deleted B<X509_NAME_ENTRY>
Packit c4476c
structure of B<NULL> if an error occurred.
Packit c4476c
Packit c4476c
=head1 EXAMPLES
Packit c4476c
Packit c4476c
Create an B<X509_NAME> structure:
Packit c4476c
Packit c4476c
"C=UK, O=Disorganized Organization, CN=Joe Bloggs"
Packit c4476c
Packit c4476c
 X509_NAME *nm;
Packit c4476c
Packit c4476c
 nm = X509_NAME_new();
Packit c4476c
 if (nm == NULL)
Packit c4476c
     /* Some error */
Packit c4476c
 if (!X509_NAME_add_entry_by_txt(nm, "C", MBSTRING_ASC,
Packit c4476c
                                 "UK", -1, -1, 0))
Packit c4476c
     /* Error */
Packit c4476c
 if (!X509_NAME_add_entry_by_txt(nm, "O", MBSTRING_ASC,
Packit c4476c
                                 "Disorganized Organization", -1, -1, 0))
Packit c4476c
     /* Error */
Packit c4476c
 if (!X509_NAME_add_entry_by_txt(nm, "CN", MBSTRING_ASC,
Packit c4476c
                                 "Joe Bloggs", -1, -1, 0))
Packit c4476c
     /* Error */
Packit c4476c
Packit c4476c
=head1 BUGS
Packit c4476c
Packit c4476c
B<type> can still be set to B<V_ASN1_APP_CHOOSE> to use a
Packit c4476c
different algorithm to determine field types. Since this form does
Packit c4476c
not understand multicharacter types, performs no length checks and
Packit c4476c
can result in invalid field types its use is strongly discouraged.
Packit c4476c
Packit c4476c
=head1 SEE ALSO
Packit c4476c
Packit c4476c
L<ERR_get_error(3)>, L<d2i_X509_NAME(3)>
Packit c4476c
Packit c4476c
=head1 COPYRIGHT
Packit c4476c
Packit c4476c
Copyright 2002-2019 The OpenSSL Project Authors. All Rights Reserved.
Packit c4476c
Packit c4476c
Licensed under the OpenSSL license (the "License").  You may not use
Packit c4476c
this file except in compliance with the License.  You can obtain a copy
Packit c4476c
in the file LICENSE in the source distribution or at
Packit c4476c
L<https://www.openssl.org/source/license.html>.
Packit c4476c
Packit c4476c
=cut