📄 x509_name_add_entry_by_txt.pod
字号:
=pod=head1 NAMEX509_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=head1 SYNOPSISint 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);=head1 DESCRIPTIONX509_NAME_add_entry_by_txt(), X509_NAME_add_entry_by_OBJ() andX509_NAME_add_entry_by_NID() add a field whose name is definedby a string B<field>, an object B<obj> or a NID B<nid> respectively.The field value to be added is in B<bytes> of length B<len>. IfB<len> is -1 then the field length is calculated internally usingstrlen(bytes).The type of field is determined by B<type> which can either be adefinition of the type of B<bytes> (such as B<MBSTRING_ASC>) or astandard ASN1 type (such as B<V_ASN1_IA5STRING>). The new entry isadded to a position determined by B<loc> and B<set>.X509_NAME_add_entry() adds a copy of B<X509_NAME_ENTRY> structure B<ne>to B<name>. The new entry is added to a position determined by B<loc>and B<set>. Since a copy of B<ne> is added B<ne> must be freed up afterthe call.X509_NAME_delete_entry() deletes an entry from B<name> at positionB<loc>. The deleted entry is returned and must be freed up.=head1 NOTESThe use of string types such as B<MBSTRING_ASC> or B<MBSTRING_UTF8>is strongly recommened for the B<type> parameter. This allows theinternal code to correctly determine the type of the field and toapply length checks according to the relevant standards. This isdone using ASN1_STRING_set_by_NID().If instead an ASN1 type is used no checks are performed and thesupplied data in B<bytes> is used directly.In X509_NAME_add_entry_by_txt() the B<field> string representsthe field name using OBJ_txt2obj(field, 0).The B<loc> and B<set> parameters determine where a new entry shouldbe added. For almost all applications B<loc> can be set to -1 and B<set>to 0. This adds a new entry to the end of B<name> as a single valuedRelativeDistinguishedName (RDN).B<loc> actually determines the index where the new entry is inserted:if it is -1 it is appended. B<set> determines how the new type is added. If it is zero anew RDN is created.If B<set> is -1 or 1 it is added to the previous or next RDNstructure respectively. This will then be a multivalued RDN:since multivalues RDNs are very seldom used B<set> is almostalways set to zero.=head1 EXAMPLESCreate an B<X509_NAME> 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 */=head1 RETURN VALUESX509_NAME_add_entry_by_txt(), X509_NAME_add_entry_by_OBJ(),X509_NAME_add_entry_by_NID() and X509_NAME_add_entry() return 1 forsuccess of 0 if an error occurred.X509_NAME_delete_entry() returns either the deleted B<X509_NAME_ENTRY>structure of B<NULL> if an error occurred.=head1 BUGSB<type> can still be set to B<V_ASN1_APP_CHOOSE> to use adifferent algorithm to determine field types. Since this form doesnot understand multicharacter types, performs no length checks andcan result in invalid field types its use is strongly discouraged.=head1 SEE ALSOL<ERR_get_error(3)|ERR_get_error(3)>, L<d2i_X509_NAME(3)|d2i_X509_NAME(3)>=head1 HISTORY=cut
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -