1X509_NAME_get_index_by_NID(3)       OpenSSL      X509_NAME_get_index_by_NID(3)
2
3
4

NAME

6       X509_NAME_get_index_by_NID, X509_NAME_get_index_by_OBJ,
7       X509_NAME_get_entry, X509_NAME_entry_count, X509_NAME_get_text_by_NID,
8       X509_NAME_get_text_by_OBJ - X509_NAME lookup and enumeration functions
9

SYNOPSIS

11       int X509_NAME_get_index_by_NID(X509_NAME *name,int nid,int lastpos);
12       int X509_NAME_get_index_by_OBJ(X509_NAME *name,ASN1_OBJECT *obj, int
13       lastpos);
14
15       int X509_NAME_entry_count(X509_NAME *name); X509_NAME_ENTRY
16       *X509_NAME_get_entry(X509_NAME *name, int loc);
17
18       int X509_NAME_get_text_by_NID(X509_NAME *name, int nid, char *buf,int
19       len); int X509_NAME_get_text_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj,
20       char *buf,int len);
21

DESCRIPTION

23       These functions allow an X509_NAME structure to be examined. The
24       X509_NAME structure is the same as the Name type defined in RFC2459
25       (and elsewhere) and used for example in certificate subject and issuer
26       names.
27
28       X509_NAME_get_index_by_NID() and X509_NAME_get_index_by_OBJ() retrieve
29       the next index matching nid or obj after lastpos. lastpos should ini‐
30       tially be set to -1. If there are no more entries -1 is returned.
31
32       X509_NAME_entry_count() returns the total number of entries in name.
33
34       X509_NAME_get_entry() retrieves the X509_NAME_ENTRY from name corre‐
35       sponding to index loc. Acceptable values for loc run from 0 to
36       (X509_NAME_entry_count(name) - 1). The value returned is an internal
37       pointer which must not be freed.
38
39       X509_NAME_get_text_by_NID(), X509_NAME_get_text_by_OBJ() retrieve the
40       "text" from the first entry in name which matches nid or obj, if no
41       such entry exists -1 is returned. At most len bytes will be written and
42       the text written to buf will be null terminated. The length of the out‐
43       put string written is returned excluding the terminating null. If buf
44       is <NULL> then the amount of space needed in buf (excluding the final
45       null) is returned.
46

NOTES

48       X509_NAME_get_text_by_NID() and X509_NAME_get_text_by_OBJ() are legacy
49       functions which have various limitations which make them of minimal use
50       in practice. They can only find the first matching entry and will copy
51       the contents of the field verbatim: this can be highly confusing if the
52       target is a muticharacter string type like a BMPString or a UTF8String.
53
54       For a more general solution X509_NAME_get_index_by_NID() or
55       X509_NAME_get_index_by_OBJ() should be used followed by
56       X509_NAME_get_entry() on any matching indices and then the various
57       X509_NAME_ENTRY utility functions on the result.
58

EXAMPLES

60       Process all entries:
61
62        int i;
63        X509_NAME_ENTRY *e;
64
65        for (i = 0; i < X509_NAME_entry_count(nm); i++)
66               {
67               e = X509_NAME_get_entry(nm, i);
68               /* Do something with e */
69               }
70
71       Process all commonName entries:
72
73        int loc;
74        X509_NAME_ENTRY *e;
75
76        loc = -1;
77        for (;;)
78               {
79               lastpos = X509_NAME_get_index_by_NID(nm, NID_commonName, lastpos);
80               if (lastpos == -1)
81                       break;
82               e = X509_NAME_get_entry(nm, lastpos);
83               /* Do something with e */
84               }
85

RETURN VALUES

87       X509_NAME_get_index_by_NID() and X509_NAME_get_index_by_OBJ() return
88       the index of the next matching entry or -1 if not found.
89
90       X509_NAME_entry_count() returns the total number of entries.
91
92       X509_NAME_get_entry() returns an X509_NAME pointer to the requested
93       entry or NULL if the index is invalid.
94

SEE ALSO

96       ERR_get_error(3), d2i_X509_NAME(3)
97

HISTORY

99       TBA
100
101
102
1030.9.8b                            2002-11-12     X509_NAME_get_index_by_NID(3)
Impressum