OpenSSL X509_NAME_add_entry_by_txt(3openssl)
NNNNAAAAMMMMEEEEX509_NAME_add_entry_by_txt, X509_NAME_add_entry_by_OBJ,
X509_NAME_add_entry_by_NID, X509_NAME_add_entry,
X509_NAME_delete_entry - X509_NAME modification functions
SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS#include
int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type, const unsigned char *bytes, int len, int loc, int set);
int X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int type, unsigned char *bytes, int len, int loc, int set);
int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type, unsigned char *bytes, int len, int loc, int set);
int X509_NAME_add_entry(X509_NAME *name,X509_NAME_ENTRY *ne, int loc, int set);
X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc);
DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNNX509_NAME_add_entry_by_txt(), X509_NAME_add_entry_by_OBJ()
and X509_NAME_add_entry_by_NID() add a field whose name is
defined by a string ffffiiiieeeelllldddd, an object oooobbbbjjjj or a NID nnnniiiidddd respectively. The field value to be added is in bbbbyyyytttteeeessss oflength lllleeeennnn. If lllleeeennnn is -1 then the field length is calculated
internally using strlen(bytes). The type of field is determined by ttttyyyyppppeeee which can either bea definition of the type of bbbbyyyytttteeeessss (such as MMMMBBBBSSSSTTTTRRRRIIIINNNNGGGG_AAAASSSSCCCC) or
a standard ASN1 type (such as VVVV_AAAASSSSNNNN1111_IIIIAAAA5555SSSSTTTTRRRRIIIINNNNGGGG). The new
entry is added to a position determined by lllloooocccc and sssseeeetttt.X509_NAME_add_entry() adds a copy of XXXX555500009999_NNNNAAAAMMMMEEEE_EEEENNNNTTTTRRRRYYYY
structure nnnneeee to nnnnaaaammmmeeee. The new entry is added to a position determined by lllloooocccc and sssseeeetttt. Since a copy of nnnneeee is added nnnneeee must be freed up after the call.X509_NAME_delete_entry() deletes an entry from nnnnaaaammmmeeee at
position lllloooocccc. The deleted entry is returned and must be freed up. NNNNOOOOTTTTEEEESSSSThe use of string types such as MMMMBBBBSSSSTTTTRRRRIIIINNNNGGGG_AAAASSSSCCCC or
MMMMBBBBSSSSTTTTRRRRIIIINNNNGGGG_UUUUTTTTFFFF8888 is strongly recommened for the ttttyyyyppppeeee parameter.
This allows the internal code to correctly determine the type of the field and to apply length checks according to the relevant standards. This is done usingASN1_STRING_set_by_NID().
If instead an ASN1 type is used no checks are performed and the supplied data in bbbbyyyytttteeeessss is used directly.27/Mar/2010 Last change: 0.9.8o 1
OpenSSL X509_NAME_add_entry_by_txt(3openssl)
In X509_NAME_add_entry_by_txt() the ffffiiiieeeelllldddd string represents
the field name using OBJ_txt2obj(field, 0).
The lllloooocccc and sssseeeetttt parameters determine where a new entry should be added. For almost all applications lllloooocccc can be setto -1 and sssseeeetttt to 0. This adds a new entry to the end of nnnnaaaammmmeeee
as a single valued RelativeDistinguishedName (RDN). lllloooocccc actually determines the index where the new entry isinserted: if it is -1 it is appended.
sssseeeetttt determines how the new type is added. If it is zero a new RDN is created.If sssseeeetttt is -1 or 1 it is added to the previous or next RDN
structure respectively. This will then be a multivalued RDN: since multivalues RDNs are very seldom used sssseeeetttt is almost always set to zero. EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSSCreate an XXXX555500009999_NNNNAAAAMMMMEEEE structure:
"C=UK, O=Disorganized Organization, CN=Joe Bloggs"X509_NAME *nm;
nm = X509_NAME_new();
if (nm == NULL) /* Some error */if (!X509_NAME_add_entry_by_txt(nm, MBSTRING_ASC,
"C", "UK", -1, -1, 0))
/* Error */if (!X509_NAME_add_entry_by_txt(nm, MBSTRING_ASC,
"O", "Disorganized Organization", -1, -1, 0))
/* Error */if (!X509_NAME_add_entry_by_txt(nm, MBSTRING_ASC,
"CN", "Joe Bloggs", -1, -1, 0))
/* Error */ RRRREEEETTTTUUUURRRRNNNN VVVVAAAALLLLUUUUEEEESSSSX509_NAME_add_entry_by_txt(), X509_NAME_add_entry_by_OBJ(),
X509_NAME_add_entry_by_NID() and X509_NAME_add_entry()
return 1 for success of 0 if an error occurred.X509_NAME_delete_entry() returns either the deleted
XXXX555500009999_NNNNAAAAMMMMEEEE_EEEENNNNTTTTRRRRYYYY structure of NNNNUUUULLLLLLLL if an error occurred.
BBBBUUUUGGGGSSSSttttyyyyppppeeee can still be set to VVVV_AAAASSSSNNNN1111_AAAAPPPPPPPP_CCCCHHHHOOOOOOOOSSSSEEEE to use a
different algorithm to determine field types. Since this form does not understand multicharacter types, performs no length checks and can result in invalid field types its use27/Mar/2010 Last change: 0.9.8o 2
OpenSSL X509_NAME_add_entry_by_txt(3openssl)
is strongly discouraged. SSSSEEEEEEEE AAAALLLLSSSSOOOOERR_get_error(3), d2i_X509_NAME(3)
HHHHIIIISSSSTTTTOOOORRRRYYYY27/Mar/2010 Last change: 0.9.8o 3