summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man
diff options
context:
space:
mode:
authorschwarze <>2016-11-04 15:29:03 +0000
committerschwarze <>2016-11-04 15:29:03 +0000
commite23d00ab37299e14c06d5d2b599a3793e3d0575c (patch)
treef91172cf4f459119421ea45c97eb6fa4aec563bc /src/lib/libcrypto/man
parentf34ab28d6356aae4d0458dd2076438a042314790 (diff)
downloadopenbsd-e23d00ab37299e14c06d5d2b599a3793e3d0575c.tar.gz
openbsd-e23d00ab37299e14c06d5d2b599a3793e3d0575c.tar.bz2
openbsd-e23d00ab37299e14c06d5d2b599a3793e3d0575c.zip
convert X509 manuals from pod to mdoc
Diffstat (limited to 'src/lib/libcrypto/man')
-rw-r--r--src/lib/libcrypto/man/Makefile40
-rw-r--r--src/lib/libcrypto/man/X509_NAME_ENTRY_get_object.3133
-rw-r--r--src/lib/libcrypto/man/X509_NAME_add_entry_by_txt.3212
-rw-r--r--src/lib/libcrypto/man/X509_NAME_get_index_by_NID.3177
-rw-r--r--src/lib/libcrypto/man/X509_NAME_print_ex.3199
-rw-r--r--src/lib/libcrypto/man/X509_STORE_CTX_get_error.3297
-rw-r--r--src/lib/libcrypto/man/X509_STORE_CTX_get_ex_new_index.354
-rw-r--r--src/lib/libcrypto/man/X509_STORE_CTX_new.3229
-rw-r--r--src/lib/libcrypto/man/X509_STORE_CTX_set_verify_cb.3185
-rw-r--r--src/lib/libcrypto/man/X509_STORE_set_verify_cb_func.354
-rw-r--r--src/lib/libcrypto/man/X509_VERIFY_PARAM_set_flags.3271
-rw-r--r--src/lib/libcrypto/man/X509_new.349
-rw-r--r--src/lib/libcrypto/man/X509_verify_cert.354
-rw-r--r--src/lib/libcrypto/man/d2i_X509.3346
-rw-r--r--src/lib/libcrypto/man/d2i_X509_ALGOR.333
-rw-r--r--src/lib/libcrypto/man/d2i_X509_CRL.354
-rw-r--r--src/lib/libcrypto/man/d2i_X509_NAME.334
-rw-r--r--src/lib/libcrypto/man/d2i_X509_REQ.353
-rw-r--r--src/lib/libcrypto/man/d2i_X509_SIG.333
-rw-r--r--src/lib/libcrypto/man/x509.379
20 files changed, 2566 insertions, 20 deletions
diff --git a/src/lib/libcrypto/man/Makefile b/src/lib/libcrypto/man/Makefile
index 8bc8ffb6aa..a76a03c78a 100644
--- a/src/lib/libcrypto/man/Makefile
+++ b/src/lib/libcrypto/man/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.45 2016/11/04 10:17:17 schwarze Exp $ 1# $OpenBSD: Makefile,v 1.46 2016/11/04 15:29:03 schwarze Exp $
2 2
3.include <bsd.own.mk> # for NOMAN 3.include <bsd.own.mk> # for NOMAN
4 4
@@ -153,49 +153,49 @@ MAN= \
153 SMIME_read_PKCS7.3 \ 153 SMIME_read_PKCS7.3 \
154 SMIME_write_PKCS7.3 \ 154 SMIME_write_PKCS7.3 \
155 UI_new.3 \ 155 UI_new.3 \
156 X509_NAME_ENTRY_get_object.3 \
157 X509_NAME_add_entry_by_txt.3 \
158 X509_NAME_get_index_by_NID.3 \
159 X509_NAME_print_ex.3 \
160 X509_STORE_CTX_get_error.3 \
161 X509_STORE_CTX_get_ex_new_index.3 \
162 X509_STORE_CTX_new.3 \
163 X509_STORE_CTX_set_verify_cb.3 \
164 X509_STORE_set_verify_cb_func.3 \
165 X509_VERIFY_PARAM_set_flags.3 \
166 X509_new.3 \
167 X509_verify_cert.3 \
156 bn_dump.3 \ 168 bn_dump.3 \
157 crypto.3 \ 169 crypto.3 \
158 d2i_ASN1_OBJECT.3 \ 170 d2i_ASN1_OBJECT.3 \
159 d2i_PKCS8PrivateKey_bio.3 \ 171 d2i_PKCS8PrivateKey_bio.3 \
160 d2i_RSAPublicKey.3 \ 172 d2i_RSAPublicKey.3 \
173 d2i_X509.3 \
174 d2i_X509_ALGOR.3 \
175 d2i_X509_CRL.3 \
176 d2i_X509_NAME.3 \
177 d2i_X509_REQ.3 \
178 d2i_X509_SIG.3 \
161 des_read_pw.3 \ 179 des_read_pw.3 \
162 evp.3 \ 180 evp.3 \
163 i2d_PKCS7_bio_stream.3 \ 181 i2d_PKCS7_bio_stream.3 \
164 lh_new.3 \ 182 lh_new.3 \
165 rsa.3 \ 183 rsa.3 \
184 x509.3
166 185
167GENMAN= \ 186GENMAN= \
168 RC4.3 \ 187 RC4.3 \
169 RIPEMD160.3 \ 188 RIPEMD160.3 \
170 SHA1.3 \ 189 SHA1.3 \
171 X509_NAME_ENTRY_get_object.3 \
172 X509_NAME_add_entry_by_txt.3 \
173 X509_NAME_get_index_by_NID.3 \
174 X509_NAME_print_ex.3 \
175 X509_STORE_CTX_get_error.3 \
176 X509_STORE_CTX_get_ex_new_index.3 \
177 X509_STORE_CTX_new.3 \
178 X509_STORE_CTX_set_verify_cb.3 \
179 X509_STORE_set_verify_cb_func.3 \
180 X509_VERIFY_PARAM_set_flags.3 \
181 X509_new.3 \
182 X509_verify_cert.3 \
183 bn.3 \ 190 bn.3 \
184 d2i_DHparams.3 \ 191 d2i_DHparams.3 \
185 d2i_DSAPublicKey.3 \ 192 d2i_DSAPublicKey.3 \
186 d2i_ECPKParameters.3 \ 193 d2i_ECPKParameters.3 \
187 d2i_X509.3 \
188 d2i_X509_ALGOR.3 \
189 d2i_X509_CRL.3 \
190 d2i_X509_NAME.3 \
191 d2i_X509_REQ.3 \
192 d2i_X509_SIG.3 \
193 dh.3 \ 194 dh.3 \
194 dsa.3 \ 195 dsa.3 \
195 ec.3 \ 196 ec.3 \
196 engine.3 \ 197 engine.3 \
197 lh_stats.3 \ 198 lh_stats.3 \
198 x509.3 \
199 199
200MAN+= ${GENMAN} 200MAN+= ${GENMAN}
201 201
diff --git a/src/lib/libcrypto/man/X509_NAME_ENTRY_get_object.3 b/src/lib/libcrypto/man/X509_NAME_ENTRY_get_object.3
new file mode 100644
index 0000000000..97978ea542
--- /dev/null
+++ b/src/lib/libcrypto/man/X509_NAME_ENTRY_get_object.3
@@ -0,0 +1,133 @@
1.Dd $Mdocdate: November 4 2016 $
2.Dt X509_NAME_ENTRY_GET_OBJECT 3
3.Os
4.Sh NAME
5.Nm X509_NAME_ENTRY_get_object ,
6.Nm X509_NAME_ENTRY_get_data ,
7.Nm X509_NAME_ENTRY_set_object ,
8.Nm X509_NAME_ENTRY_set_data ,
9.Nm X509_NAME_ENTRY_create_by_txt ,
10.Nm X509_NAME_ENTRY_create_by_NID ,
11.Nm X509_NAME_ENTRY_create_by_OBJ
12.Nd X509_NAME_ENTRY utility functions
13.Sh SYNOPSIS
14.In openssl/x509.h
15.Ft ASN1_OBJECT *
16.Fo X509_NAME_ENTRY_get_object
17.Fa "X509_NAME_ENTRY *ne"
18.Fc
19.Ft ASN1_STRING *
20.Fo X509_NAME_ENTRY_get_data
21.Fa "X509_NAME_ENTRY *ne"
22.Fc
23.Ft int
24.Fo X509_NAME_ENTRY_set_object
25.Fa "X509_NAME_ENTRY *ne"
26.Fa "ASN1_OBJECT *obj"
27.Fc
28.Ft int
29.Fo X509_NAME_ENTRY_set_data
30.Fa "X509_NAME_ENTRY *ne"
31.Fa "int type"
32.Fa "const unsigned char *bytes"
33.Fa "int len"
34.Fc
35.Ft X509_NAME_ENTRY *
36.Fo X509_NAME_ENTRY_create_by_txt
37.Fa "X509_NAME_ENTRY **ne"
38.Fa "const char *field"
39.Fa "int type"
40.Fa "const unsigned char *bytes"
41.Fa "int len"
42.Fc
43.Ft X509_NAME_ENTRY *
44.Fo X509_NAME_ENTRY_create_by_NID
45.Fa "X509_NAME_ENTRY **ne"
46.Fa "int nid"
47.Fa "int type"
48.Fa "unsigned char *bytes"
49.Fa "int len"
50.Fc
51.Ft X509_NAME_ENTRY *
52.Fo X509_NAME_ENTRY_create_by_OBJ
53.Fa "X509_NAME_ENTRY **ne"
54.Fa "ASN1_OBJECT *obj"
55.Fa "int type"
56.Fa "const unsigned char *bytes"
57.Fa "int len"
58.Fc
59.Sh DESCRIPTION
60.Fn X509_NAME_ENTRY_get_object
61retrieves the field name of
62.Fa ne
63in an
64.Vt ASN1_OBJECT
65structure.
66.Pp
67.Fn X509_NAME_ENTRY_get_data
68retrieves the field value of
69.Fa ne
70in an
71.Vt ASN1_STRING
72structure.
73.Pp
74.Fn X509_NAME_ENTRY_set_object
75sets the field name of
76.Fa ne
77to
78.Fa obj .
79.Pp
80.Fn X509_NAME_ENTRY_set_data
81sets the field value of
82.Fa ne
83to string type
84.Fa type
85and the value determined by
86.Fa bytes
87and
88.Fa len .
89.Pp
90.Fn X509_NAME_ENTRY_create_by_txt ,
91.Fn X509_NAME_ENTRY_create_by_NID ,
92and
93.Fn X509_NAME_ENTRY_create_by_OBJ
94create and return an
95.Vt X509_NAME_ENTRY
96structure.
97.Pp
98.Fn X509_NAME_ENTRY_get_object
99and
100.Fn X509_NAME_ENTRY_get_data
101can be used to examine an
102.Vt X509_NAME_ENTRY
103function as returned by
104.Xr X509_NAME_get_entry 3
105for example.
106.Pp
107.Fn X509_NAME_ENTRY_create_by_txt ,
108.Fn X509_NAME_ENTRY_create_by_OBJ ,
109.Fn X509_NAME_ENTRY_create_by_NID ,
110and
111.Fn X509_NAME_ENTRY_set_data
112are seldom used in practice because
113.Vt X509_NAME_ENTRY
114structures are almost always part of
115.Vt X509_NAME
116structures and the corresponding X509_NAME functions are typically
117used to create and add new entries in a single operation.
118.Pp
119The arguments of these functions support similar options to the
120similarly named ones of the corresponding X509_NAME functions such as
121.Xr X509_NAME_add_entry_by_txt 3 .
122So for example
123.Fa type
124can be set to
125.Dv MBSTRING_ASC ,
126but in the case of
127.Fn X509_NAME_ENTRY_set_data
128the field name must be set first so the relevant field information
129can be looked up internally.
130.Sh SEE ALSO
131.Xr d2i_X509_NAME 3 ,
132.Xr ERR_get_error 3 ,
133.Xr OBJ_nid2obj 3
diff --git a/src/lib/libcrypto/man/X509_NAME_add_entry_by_txt.3 b/src/lib/libcrypto/man/X509_NAME_add_entry_by_txt.3
new file mode 100644
index 0000000000..c77763cc68
--- /dev/null
+++ b/src/lib/libcrypto/man/X509_NAME_add_entry_by_txt.3
@@ -0,0 +1,212 @@
1.Dd $Mdocdate: November 4 2016 $
2.Dt X509_NAME_ADD_ENTRY_BY_TXT 3
3.Os
4.Sh NAME
5.Nm X509_NAME_add_entry_by_txt ,
6.Nm X509_NAME_add_entry_by_OBJ ,
7.Nm X509_NAME_add_entry_by_NID ,
8.Nm X509_NAME_add_entry ,
9.Nm X509_NAME_delete_entry
10.Nd X509_NAME modification functions
11.Sh SYNOPSIS
12.In openssl/x509.h
13.Ft int
14.Fo X509_NAME_add_entry_by_txt
15.Fa "X509_NAME *name"
16.Fa "const char *field"
17.Fa "int type"
18.Fa "const unsigned char *bytes"
19.Fa "int len"
20.Fa "int loc"
21.Fa "int set"
22.Fc
23.Ft int
24.Fo X509_NAME_add_entry_by_OBJ
25.Fa "X509_NAME *name"
26.Fa "ASN1_OBJECT *obj"
27.Fa "int type"
28.Fa "unsigned char *bytes"
29.Fa "int len"
30.Fa "int loc"
31.Fa "int set"
32.Fc
33.Ft int
34.Fo X509_NAME_add_entry_by_NID
35.Fa "X509_NAME *name"
36.Fa "int nid"
37.Fa "int type"
38.Fa "unsigned char *bytes"
39.Fa "int len"
40.Fa "int loc"
41.Fa "int set"
42.Fc
43.Ft int
44.Fo X509_NAME_add_entry
45.Fa "X509_NAME *name"
46.Fa "X509_NAME_ENTRY *ne"
47.Fa "int loc"
48.Fa "int set"
49.Fc
50.Ft X509_NAME_ENTRY *
51.Fo X509_NAME_delete_entry
52.Fa "X509_NAME *name"
53.Fa "int loc"
54.Fc
55.Sh DESCRIPTION
56.Fn X509_NAME_add_entry_by_txt ,
57.Fn X509_NAME_add_entry_by_OBJ ,
58and
59.Fn X509_NAME_add_entry_by_NID
60add a field whose name is defined by a string
61.Fa field ,
62an object
63.Fa obj
64or a NID
65.Fa nid ,
66respectively.
67The field value to be added is in
68.Fa bytes
69of length
70.Fa len .
71If
72.Fa len
73is -1 then the field length is calculated internally using
74.Fn strlen bytes .
75.Pp
76The type of field is determined by
77.Fa type
78which can either be a definition of the type of
79.Fa bytes
80(such as
81.Dv MBSTRING_ASC )
82or a standard ASN1 type (such as
83.Dv V_ASN1_IA5STRING ) .
84The new entry is added to a position determined by
85.Fa loc
86and
87.Fa set .
88.Pp
89.Fn X509_NAME_add_entry
90adds a copy of a
91.Vt X509_NAME_ENTRY
92structure
93.Fa ne
94to
95.Fa name .
96The new entry is added to a position determined by
97.Fa loc
98and
99.Fa set .
100Since a copy of
101.Fa ne
102is added,
103.Fa ne
104must be freed up after the call.
105.Pp
106.Fn X509_NAME_delete_entry
107deletes an entry from
108.Fa name
109at position
110.Fa loc .
111The deleted entry is returned and must be freed up.
112.Pp
113The use of string types such as
114.Dv MBSTRING_ASC
115or
116.Dv MBSTRING_UTF8
117is strongly recommended for the
118.Fa type
119parameter.
120This allows the internal code to correctly determine the type of the
121field and to apply length checks according to the relevant standards.
122This is done using
123.Xr ASN1_STRING_set_by_NID 3 .
124.Pp
125If instead an ASN1 type is used, no checks are performed and the supplied
126data in
127.Fa bytes
128is used directly.
129.Pp
130In
131.Fn X509_NAME_add_entry_by_txt
132the
133.Fa field
134string represents the field name using
135.Fn OBJ_txt2obj field 0 .
136.Pp
137The
138.Fa loc
139and
140.Fa set
141parameters determine where a new entry should be added.
142For almost all applications,
143.Fa loc
144can be set to -1 and
145.Fa set
146to 0.
147This adds a new entry to the end of
148.Fa name
149as a single valued RelativeDistinguishedName (RDN).
150.Pp
151.Fa loc
152actually determines the index where the new entry is inserted:
153if it is -1 it is appended.
154.Pp
155.Fa set
156determines how the new type is added.
157If it is zero a new RDN is created.
158.Pp
159If
160.Fa set
161is -1 or 1 it is added to the previous or next RDN structure
162respectively.
163This will then be a multivalued RDN: since multivalues RDNs are very
164seldom used,
165.Fa set
166is almost always set to zero.
167.Sh RETURN VALUES
168.Fn X509_NAME_add_entry_by_txt ,
169.Fn X509_NAME_add_entry_by_OBJ ,
170.Fn X509_NAME_add_entry_by_NID ,
171and
172.Fn X509_NAME_add_entry
173return 1 for success or 0 if an error occurred.
174.Pp
175.Fn X509_NAME_delete_entry
176returns either the deleted
177.Vt X509_NAME_ENTRY
178structure or
179.Dv NULL
180if an error occurred.
181.Sh EXAMPLES
182Create an
183.Vt X509_NAME
184structure:
185.Pp
186.D1 C=UK, O=Disorganized Organization, CN=Joe Bloggs
187.Bd -literal
188X509_NAME *nm;
189nm = X509_NAME_new();
190if (nm == NULL)
191 /* Some error */
192if (!X509_NAME_add_entry_by_txt(nm, MBSTRING_ASC,
193 "C", "UK", -1, -1, 0))
194 /* Error */
195if (!X509_NAME_add_entry_by_txt(nm, MBSTRING_ASC,
196 "O", "Disorganized Organization", -1, -1, 0))
197 /* Error */
198if (!X509_NAME_add_entry_by_txt(nm, MBSTRING_ASC,
199 "CN", "Joe Bloggs", -1, -1, 0))
200 /* Error */
201.Ed
202.Sh SEE ALSO
203.Xr d2i_X509_NAME 3 ,
204.Xr ERR_get_error 3
205.Sh BUGS
206.Fa type
207can still be set to
208.Dv V_ASN1_APP_CHOOSE
209to use a different algorithm to determine field types.
210Since this form does not understand multicharacter types, performs
211no length checks, and can result in invalid field types, its use
212is strongly discouraged.
diff --git a/src/lib/libcrypto/man/X509_NAME_get_index_by_NID.3 b/src/lib/libcrypto/man/X509_NAME_get_index_by_NID.3
new file mode 100644
index 0000000000..4710fd1ec2
--- /dev/null
+++ b/src/lib/libcrypto/man/X509_NAME_get_index_by_NID.3
@@ -0,0 +1,177 @@
1.Dd $Mdocdate: November 4 2016 $
2.Dt X509_NAME_GET_INDEX_BY_NID 3
3.Os
4.Sh NAME
5.Nm X509_NAME_get_index_by_NID ,
6.Nm X509_NAME_get_index_by_OBJ ,
7.Nm X509_NAME_get_entry ,
8.Nm X509_NAME_entry_count ,
9.Nm X509_NAME_get_text_by_NID ,
10.Nm X509_NAME_get_text_by_OBJ
11.Nd X509_NAME lookup and enumeration functions
12.Sh SYNOPSIS
13.In openssl/x509.h
14.Ft int
15.Fo X509_NAME_get_index_by_NID
16.Fa "X509_NAME *name"
17.Fa "int nid"
18.Fa "int lastpos"
19.Fc
20.Ft int
21.Fo X509_NAME_get_index_by_OBJ
22.Fa "X509_NAME *name"
23.Fa "ASN1_OBJECT *obj"
24.Fa "int lastpos"
25.Fc
26.Ft int
27.Fo X509_NAME_entry_count
28.Fa "X509_NAME *name"
29.Fc
30.Ft X509_NAME_ENTRY *
31.Fo X509_NAME_get_entry
32.Fa "X509_NAME *name"
33.Fa "int loc"
34.Fc
35.Ft int
36.Fo X509_NAME_get_text_by_NID
37.Fa "X509_NAME *name"
38.Fa "int nid"
39.Fa "char *buf"
40.Fa "int len"
41.Fc
42.Ft int
43.Fo X509_NAME_get_text_by_OBJ
44.Fa "X509_NAME *name"
45.Fa "ASN1_OBJECT *obj"
46.Fa "char *buf"
47.Fa "int len"
48.Fc
49.Sh DESCRIPTION
50These functions allow an
51.Vt X509_NAME
52structure to be examined.
53The
54.Vt X509_NAME
55structure is the same as the
56.Sy Name
57type defined in RFC2459 (and elsewhere) and used for example in
58certificate subject and issuer names.
59.Pp
60.Fn X509_NAME_get_index_by_NID
61and
62.Fn X509_NAME_get_index_by_OBJ
63retrieve the next index matching
64.Fa nid
65or
66.Fa obj
67after
68.Fa lastpos .
69.Fa lastpos
70should initially be set to -1.
71If there are no more entries, -1 is returned.
72.Pp
73.Fn X509_NAME_entry_count
74returns the total number of entries in
75.Fa name .
76.Pp
77.Fn X509_NAME_get_entry
78retrieves the
79.Vt X509_NAME_ENTRY
80from
81.Fa name
82corresponding to index
83.Fa loc .
84Acceptable values for
85.Fa loc
86run from 0 to
87.Fn X509_NAME_entry_count name
88- 1.
89The value returned is an internal pointer which must not be freed.
90.Pp
91.Fn X509_NAME_get_text_by_NID
92and
93.Fn X509_NAME_get_text_by_OBJ
94retrieve the "text" from the first entry in
95.Fa name
96which matches
97.Fa nid
98or
99.Fa obj .
100If no such entry exists, -1 is returned.
101At most
102.Fa len
103bytes will be written and the text written to
104.Fa buf
105will be NUL terminated.
106The length of the output string written is returned excluding the
107terminating NUL.
108If
109.Fa buf
110is
111.Dv NULL
112then the amount of space needed in
113.Fa buf
114(excluding the final NUL) is returned.
115.Sh RETURN VALUES
116.Fn X509_NAME_get_index_by_NID
117and
118.Fn X509_NAME_get_index_by_OBJ
119return the index of the next matching entry or -1 if not found.
120.Pp
121.Fn X509_NAME_entry_count
122returns the total number of entries.
123.Pp
124.Fn X509_NAME_get_entry
125returns an
126.Vt X509_NAME
127pointer to the requested entry or
128.Dv NULL
129if the index is invalid.
130.Sh EXAMPLES
131Process all entries:
132.Bd -literal
133int i;
134X509_NAME_ENTRY *e;
135
136for (i = 0; i < X509_NAME_entry_count(nm); i++) {
137 e = X509_NAME_get_entry(nm, i);
138 /* Do something with e */
139}
140.Ed
141.Pp
142Process all commonName entries:
143.Bd -literal
144int loc;
145X509_NAME_ENTRY *e;
146
147loc = -1;
148for (;;) {
149 lastpos = X509_NAME_get_index_by_NID(nm, NID_commonName, lastpos);
150 if (lastpos == -1)
151 break;
152 e = X509_NAME_get_entry(nm, lastpos);
153 /* Do something with e */
154}
155.Ed
156.Sh SEE ALSO
157.Xr d2i_X509_NAME 3 ,
158.Xr ERR_get_error 3
159.Sh CAVEATS
160.Fn X509_NAME_get_text_by_NID
161and
162.Fn X509_NAME_get_text_by_OBJ
163are legacy functions which have various limitations which make them of
164minimal use in practice.
165They can only find the first matching entry and will copy the contents
166of the field verbatim: this can be highly confusing if the target is a
167multicharacter string type like a BMPString or a UTF8String.
168.Pp
169For a more general solution,
170.Fn X509_NAME_get_index_by_NID
171or
172.Fn X509_NAME_get_index_by_OBJ
173should be used, followed by
174.Fn X509_NAME_get_entry
175on any matching indices and then the various
176.Vt X509_NAME_ENTRY
177utility functions on the result.
diff --git a/src/lib/libcrypto/man/X509_NAME_print_ex.3 b/src/lib/libcrypto/man/X509_NAME_print_ex.3
new file mode 100644
index 0000000000..ca5fc61e18
--- /dev/null
+++ b/src/lib/libcrypto/man/X509_NAME_print_ex.3
@@ -0,0 +1,199 @@
1.Dd $Mdocdate: November 4 2016 $
2.Dt X509_NAME_PRINT_EX 3
3.Os
4.Sh NAME
5.Nm X509_NAME_print_ex ,
6.Nm X509_NAME_print_ex_fp ,
7.Nm X509_NAME_print ,
8.Nm X509_NAME_oneline
9.Nd X509_NAME printing routines
10.Sh SYNOPSIS
11.In openssl/x509.h
12.Ft int
13.Fo X509_NAME_print_ex
14.Fa "BIO *out"
15.Fa "X509_NAME *nm"
16.Fa "int indent"
17.Fa "unsigned long flags"
18.Fc
19.Ft int
20.Fo X509_NAME_print_ex_fp
21.Fa "FILE *fp"
22.Fa "X509_NAME *nm"
23.Fa "int indent"
24.Fa "unsigned long flags"
25.Fc
26.Ft char *
27.Fo X509_NAME_oneline
28.Fa "X509_NAME *a"
29.Fa "char *buf"
30.Fa "int size"
31.Fc
32.Ft int
33.Fo X509_NAME_print
34.Fa "BIO *bp"
35.Fa "X509_NAME *name"
36.Fa "int obase"
37.Fc
38.Sh DESCRIPTION
39.Fn X509_NAME_print_ex
40prints a human readable version of
41.Fa nm
42to
43.Vt BIO
44.Fa out .
45Each line (for multiline formats) is indented by
46.Fa indent
47spaces.
48The output format can be extensively customised by use of the
49.Fa flags
50parameter.
51.Pp
52.Fn X509_NAME_print_ex_fp
53is identical to
54.Fn X509_NAME_print_ex
55except the output is written to the
56.Vt FILE
57pointer
58.Fa fp .
59.Pp
60.Fn X509_NAME_oneline
61prints an ASCII version of
62.Fa a
63to
64.Fa buf .
65At most
66.Fa size
67bytes will be written.
68If
69.Fa buf
70is
71.Dv NULL ,
72then a buffer is dynamically allocated and returned, otherwise
73.Fa buf
74is returned.
75.Pp
76.Fn X509_NAME_print
77prints out
78.Fa name
79to
80.Fa bp
81indenting each line by
82.Fa obase
83characters.
84Multiple lines are used if the output (including indent) exceeds 80
85characters.
86.Pp
87The functions
88.Fn X509_NAME_oneline
89and
90.Fn X509_NAME_print
91are legacy functions which produce a non standard output form.
92They don't handle multi character fields and have various quirks
93and inconsistencies.
94Their use is strongly discouraged in new applications.
95.Pp
96Although there are a large number of possible flags, for most purposes
97.Dv XN_FLAG_ONELINE ,
98.Dv XN_FLAG_MULTILINE ,
99or
100.Dv XN_FLAG_RFC2253
101will suffice.
102As noted on the
103.Xr ASN1_STRING_print_ex 3
104manual page, for UTF-8 terminals the
105.Dv ASN1_STRFLGS_ESC_MSB
106should be unset: so for example
107.Dv XN_FLAG_ONELINE No & Pf ~ Dv ASN1_STRFLGS_ESC_MSB
108would be used.
109.Pp
110The complete set of the flags supported by
111.Dv X509_NAME_print_ex
112is listed below.
113.Pp
114Several options can be OR'ed together.
115.Pp
116The options
117.Dv XN_FLAG_SEP_COMMA_PLUS ,
118.Dv XN_FLAG_SEP_CPLUS_SPC ,
119.Dv XN_FLAG_SEP_SPLUS_SPC ,
120and
121.Dv XN_FLAG_SEP_MULTILINE
122determine the field separators to use.
123Two distinct separators are used between distinct
124RelativeDistinguishedName components and separate values in the same RDN
125for a multi-valued RDN.
126Multi-valued RDNs are currently very rare so the second separator
127will hardly ever be used.
128.Pp
129.Dv XN_FLAG_SEP_COMMA_PLUS
130uses comma and plus as separators.
131.Dv XN_FLAG_SEP_CPLUS_SPC
132uses comma and plus with spaces:
133this is more readable that plain comma and plus.
134.Dv XN_FLAG_SEP_SPLUS_SPC
135uses spaced semicolon and plus.
136.Dv XN_FLAG_SEP_MULTILINE
137uses spaced newline and plus respectively.
138.Pp
139If
140.Dv XN_FLAG_DN_REV
141is set, the whole DN is printed in reversed order.
142.Pp
143The fields
144.Dv XN_FLAG_FN_SN ,
145.Dv XN_FLAG_FN_LN ,
146.Dv XN_FLAG_FN_OID ,
147and
148.Dv XN_FLAG_FN_NONE
149determine how a field name is displayed.
150It will use the short name (e.g. CN) the long name (e.g. commonName)
151always use OID numerical form (normally OIDs are only used if the
152field name is not recognised) and no field name respectively.
153.Pp
154If
155.Dv XN_FLAG_SPC_EQ
156is set, then spaces will be placed around the
157.Ql =
158character separating field names and values.
159.Pp
160If
161.Dv XN_FLAG_DUMP_UNKNOWN_FIELDS
162is set, then the encoding of unknown fields is printed instead of the
163values.
164.Pp
165If
166.Dv XN_FLAG_FN_ALIGN
167is set, then field names are padded to 20 characters:
168this is only of use for multiline format.
169.Pp
170Additionally, all the options supported by
171.Xr ASN1_STRING_print_ex 3
172can be used to control how each field value is displayed.
173.Pp
174In addition a number options can be set for commonly used formats.
175.Pp
176.Dv XN_FLAG_RFC2253
177sets options which produce an output compatible with RFC2253.
178It is equivalent to
179.Dv ASN1_STRFLGS_RFC2253 | XN_FLAG_SEP_COMMA_PLUS | XN_FLAG_DN_REV |
180.Dv XN_FLAG_FN_SN | XN_FLAG_DUMP_UNKNOWN_FIELDS .
181.Pp
182.Dv XN_FLAG_ONELINE
183is a more readable one line format which is the same as:
184.Dv ASN1_STRFLGS_RFC2253 | ASN1_STRFLGS_ESC_QUOTE | XN_FLAG_SEP_CPLUS_SPC |
185.Dv XN_FLAG_SPC_EQ | XN_FLAG_FN_SN .
186.Pp
187.Dv XN_FLAG_MULTILINE
188is a multiline format which is the same as:
189.Dv ASN1_STRFLGS_ESC_CTRL | ASN1_STRFLGS_ESC_MSB | XN_FLAG_SEP_MULTILINE |
190.Dv XN_FLAG_SPC_EQ | XN_FLAG_FN_LN | XN_FLAG_FN_ALIGN .
191.Pp
192.Dv XN_FLAG_COMPAT
193uses a format identical to
194.Fn X509_NAME_print :
195in fact it calls
196.Fn X509_NAME_print
197internally.
198.Sh SEE ALSO
199.Xr ASN1_STRING_print_ex 3
diff --git a/src/lib/libcrypto/man/X509_STORE_CTX_get_error.3 b/src/lib/libcrypto/man/X509_STORE_CTX_get_error.3
new file mode 100644
index 0000000000..f31e438cde
--- /dev/null
+++ b/src/lib/libcrypto/man/X509_STORE_CTX_get_error.3
@@ -0,0 +1,297 @@
1.Dd $Mdocdate: November 4 2016 $
2.Dt X509_STORE_CTX_GET_ERROR 3
3.Os
4.Sh NAME
5.Nm X509_STORE_CTX_get_error ,
6.Nm X509_STORE_CTX_set_error ,
7.Nm X509_STORE_CTX_get_error_depth ,
8.Nm X509_STORE_CTX_get_current_cert ,
9.Nm X509_STORE_CTX_get1_chain ,
10.Nm X509_verify_cert_error_string
11.Nd get or set certificate verification status information
12.Sh SYNOPSIS
13.In openssl/x509.h
14.In openssl/x509_vfy.h
15.Ft int
16.Fo X509_STORE_CTX_get_error
17.Fa "X509_STORE_CTX *ctx"
18.Fc
19.Ft void
20.Fo X509_STORE_CTX_set_error
21.Fa "X509_STORE_CTX *ctx"
22.Fa "int s"
23.Fc
24.Ft int
25.Fo X509_STORE_CTX_get_error_depth
26.Fa "X509_STORE_CTX *ctx"
27.Fc
28.Ft X509 *
29.Fo X509_STORE_CTX_get_current_cert
30.Fa "X509_STORE_CTX *ctx"
31.Fc
32.Ft STACK_OF(X509) *
33.Fo X509_STORE_CTX_get1_chain
34.Fa "X509_STORE_CTX *ctx"
35.Fc
36.Ft const char *
37.Fo X509_verify_cert_error_string
38.Fa "long n"
39.Fc
40.Sh DESCRIPTION
41These functions are typically called after
42.Xr X509_verify_cert 3
43has indicated an error or in a verification callback to determine the
44nature of an error.
45.Pp
46.Fn X509_STORE_CTX_get_error
47returns the error code of
48.Fa ctx .
49See the
50.Sy ERROR CODES
51section for a full description of all error codes.
52.Pp
53.Fn X509_STORE_CTX_set_error
54sets the error code of
55.Fa ctx
56to
57.Fa s .
58For example it might be used in a verification callback to set an error
59based on additional checks.
60.Pp
61.Fn X509_STORE_CTX_get_error_depth
62returns the depth of the error.
63This is a non-negative integer representing where in the certificate
64chain the error occurred.
65If it is zero, it occurred in the end entity certificate, one if it is
66the certificate which signed the end entity certificate, and so on.
67.Pp
68.Fn X509_STORE_CTX_get_current_cert
69returns the certificate in
70.Fa ctx
71which caused the error or
72.Dv NULL
73if no certificate is relevant.
74.Pp
75.Fn X509_STORE_CTX_get1_chain
76returns a complete validate chain if a previous call to
77.Xr X509_verify_cert 3
78is successful.
79If the call to
80.Xr X509_verify_cert 3
81is
82.Sy not
83successful, the returned chain may be incomplete or invalid.
84The returned chain persists after the
85.Fa ctx
86structure is freed.
87When it is no longer needed, it should be free up using
88.Fn sk_X509_pop_free chain X509_free .
89.Pp
90.Fn X509_verify_cert_error_string
91returns a human readable error string for verification error
92.Fa n .
93.Pp
94The above functions should be used instead of directly referencing the
95fields in the
96.Sy X509_VERIFY_CTX
97structure.
98.Pp
99In versions of OpenSSL before 1.0, the current certificate returned by
100.Fn X509_STORE_CTX_get_current_cert
101was never
102.Dv NULL .
103Applications should check the return value before printing out any
104debugging information relating to the current certificate.
105.Pp
106If an unrecognised error code is passed to
107.Fn X509_verify_cert_error_string ,
108the numerical value of the unknown code is returned in a static buffer.
109This is not thread safe but will never happen unless an invalid code is
110passed.
111.Sh RETURN VALUES
112.Fn X509_STORE_CTX_get_error
113returns
114.Dv X509_V_OK
115or an error code.
116.Pp
117.Fn X509_STORE_CTX_get_error_depth
118returns a non-negative error depth.
119.Pp
120.Fn X509_STORE_CTX_get_current_cert
121returns the certificate which caused the error or
122.Dv NULL
123if no certificate is relevant to the error.
124.Pp
125.Fn X509_verify_cert_error_string
126returns a human readable error string for verification error
127.Fa n .
128.Sh ERROR CODES
129A list of error codes and messages is shown below.
130Some of the error codes are defined but currently never returned:
131these are described as "unused".
132.Bl -tag -width Ds
133.It Dv X509_V_OK : No ok
134The operation was successful.
135.It Dv X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT : \
136 No unable to get issuer certificate
137The issuer certificate could not be found: this occurs if the issuer
138certificate of an untrusted certificate cannot be found.
139.It Dv X509_V_ERR_UNABLE_TO_GET_CRL : No unable to get certificate CRL
140The CRL of a certificate could not be found.
141.It Dv X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE : \
142 No unable to decrypt certificate's signature
143The certificate signature could not be decrypted.
144This means that the actual signature value could not be determined
145rather than it not matching the expected value, this is only meaningful
146for RSA keys.
147.It Dv X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE : \
148 No unable to decrypt CRL's signature
149The CRL signature could not be decrypted: this means that the actual
150signature value could not be determined rather than it not matching the
151expected value.
152Unused.
153.It Dv X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY : \
154 No unable to decode issuer public key
155The public key in the certificate SubjectPublicKeyInfo could not be read.
156.It Dv X509_V_ERR_CERT_SIGNATURE_FAILURE : No certificate signature failure
157The signature of the certificate is invalid.
158.It Dv X509_V_ERR_CRL_SIGNATURE_FAILURE : No CRL signature failure
159The signature of the certificate is invalid.
160.It Dv X509_V_ERR_CERT_NOT_YET_VALID : No certificate is not yet valid
161The certificate is not yet valid: the notBefore date is after the
162current time.
163.It Dv X509_V_ERR_CERT_HAS_EXPIRED : No certificate has expired
164The certificate has expired: that is the notAfter date is before the
165current time.
166.It Dv X509_V_ERR_CRL_NOT_YET_VALID : No CRL is not yet valid
167The CRL is not yet valid.
168.It Dv X509_V_ERR_CRL_HAS_EXPIRED : No CRL has expired
169The CRL has expired.
170.It Dv X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD : \
171 No format error in certificate's notBefore field
172The certificate notBefore field contains an invalid time.
173.It Dv X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD : \
174 No format error in certificate's notAfter field
175The certificate notAfter field contains an invalid time.
176.It Dv X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD : \
177 No format error in CRL's lastUpdate field
178The CRL lastUpdate field contains an invalid time.
179.It Dv X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD : \
180 No format error in CRL's nextUpdate field
181The CRL nextUpdate field contains an invalid time.
182.It Dv X509_V_ERR_OUT_OF_MEM : No out of memory
183An error occurred trying to allocate memory.
184This should never happen.
185.It Dv X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT : No self signed certificate
186The passed certificate is self signed and the same certificate cannot be
187found in the list of trusted certificates.
188.It Dv X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN : \
189 No self signed certificate in certificate chain
190The certificate chain could be built up using the untrusted certificates
191but the root could not be found locally.
192.It Dv X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY : \
193 No unable to get local issuer certificate
194The issuer certificate of a locally looked up certificate could not be found.
195This normally means the list of trusted certificates is not complete.
196.It Dv X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE : \
197 No unable to verify the first certificate
198No signatures could be verified because the chain contains only one
199certificate and it is not self signed.
200.It Dv X509_V_ERR_CERT_CHAIN_TOO_LONG : No certificate chain too long
201The certificate chain length is greater than the supplied maximum depth.
202Unused.
203.It Dv X509_V_ERR_CERT_REVOKED : No certificate revoked
204The certificate has been revoked.
205.It Dv X509_V_ERR_INVALID_CA : No invalid CA certificate
206A CA certificate is invalid.
207Either it is not a CA or its extensions are not consistent with the
208supplied purpose.
209.It Dv X509_V_ERR_PATH_LENGTH_EXCEEDED : No path length constraint exceeded
210The basicConstraints pathlength parameter has been exceeded.
211.It Dv X509_V_ERR_INVALID_PURPOSE : No unsupported certificate purpose
212The supplied certificate cannot be used for the specified purpose.
213.It Dv X509_V_ERR_CERT_UNTRUSTED : No certificate not trusted
214The root CA is not marked as trusted for the specified purpose.
215.It Dv X509_V_ERR_CERT_REJECTED : No certificate rejected
216The root CA is marked to reject the specified purpose.
217.It Dv X509_V_ERR_SUBJECT_ISSUER_MISMATCH : No subject issuer mismatch
218The current candidate issuer certificate was rejected because its
219subject name did not match the issuer name of the current certificate.
220This is only set if issuer check debugging is enabled it is used for
221status notification and is
222.Sy not
223in itself an error.
224.It Dv X509_V_ERR_AKID_SKID_MISMATCH : \
225 No authority and subject key identifier mismatch
226The current candidate issuer certificate was rejected because its
227subject key identifier was present and did not match the authority key
228identifier current certificate.
229This is only set if issuer check debugging is enabled it is used for
230status notification and is
231.Sy not
232in itself an error.
233.It Dv X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH : \
234 Noauthority and issuer serial number mismatch
235The current candidate issuer certificate was rejected because its issuer
236name and serial number was present and did not match the authority key
237identifier of the current certificate.
238This is only set if issuer check debugging is enabled it is used for
239status notification and is
240.Sy not
241in itself an error.
242.It Dv X509_V_ERR_KEYUSAGE_NO_CERTSIGN : \
243 No key usage does not include certificate signing
244The current candidate issuer certificate was rejected because its
245keyUsage extension does not permit certificate signing.
246This is only set if issuer check debugging is enabled it is used for
247status notification and is
248.Sy not
249in itself an error.
250.It Dv X509_V_ERR_INVALID_EXTENSION : \
251 No invalid or inconsistent certificate extension
252A certificate extension had an invalid value (for example an incorrect
253encoding) or some value inconsistent with other extensions.
254.It Dv X509_V_ERR_INVALID_POLICY_EXTENSION : \
255 No invalid or inconsistent certificate policy extension
256A certificate policies extension had an invalid value (for example an
257incorrect encoding) or some value inconsistent with other extensions.
258This error only occurs if policy processing is enabled.
259.It Dv X509_V_ERR_NO_EXPLICIT_POLICY : No no explicit policy
260The verification flags were set to require and explicit policy but none
261was present.
262.It Dv X509_V_ERR_DIFFERENT_CRL_SCOPE : No different CRL scope
263The only CRLs that could be found did not match the scope of the
264certificate.
265.It Dv X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE : \
266 No unsupported extension feature
267Some feature of a certificate extension is not supported.
268Unused.
269.It Dv X509_V_ERR_PERMITTED_VIOLATION : No permitted subtree violation
270A name constraint violation occurred in the permitted subtrees.
271.It Dv X509_V_ERR_EXCLUDED_VIOLATION : No excluded subtree violation
272A name constraint violation occurred in the excluded subtrees.
273.It Dv X509_V_ERR_SUBTREE_MINMAX : \
274 No name constraints minimum and maximum not supported
275A certificate name constraints extension included a minimum or maximum
276field: this is not supported.
277.It Dv X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE : \
278 No unsupported name constraint type
279An unsupported name constraint type was encountered.
280OpenSSL currently only supports directory name, DNS name, email and URI
281types.
282.It Dv X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX : \
283 No unsupported or invalid name constraint syntax
284The format of the name constraint is not recognised: for example an
285email address format of a form not mentioned in RFC3280.
286This could be caused by a garbage extension or some new feature not
287currently supported.
288.It Dv X509_V_ERR_CRL_PATH_VALIDATION_ERROR : No CRL path validation error
289An error occurred when attempting to verify the CRL path.
290This error can only happen if extended CRL checking is enabled.
291.It Dv X509_V_ERR_APPLICATION_VERIFICATION : \
292 No application verification failure
293An application specific error.
294This will never be returned unless explicitly set by an application.
295.El
296.Sh SEE ALSO
297.Xr X509_verify_cert 3
diff --git a/src/lib/libcrypto/man/X509_STORE_CTX_get_ex_new_index.3 b/src/lib/libcrypto/man/X509_STORE_CTX_get_ex_new_index.3
new file mode 100644
index 0000000000..511933d4a1
--- /dev/null
+++ b/src/lib/libcrypto/man/X509_STORE_CTX_get_ex_new_index.3
@@ -0,0 +1,54 @@
1.Dd $Mdocdate: November 4 2016 $
2.Dt X509_STORE_CTX_GET_EX_NEW_INDEX 3
3.Os
4.Sh NAME
5.Nm X509_STORE_CTX_get_ex_new_index ,
6.Nm X509_STORE_CTX_set_ex_data ,
7.Nm X509_STORE_CTX_get_ex_data
8.Nd add application specific data to X509_STORE_CTX structures
9.Sh SYNOPSIS
10.In openssl/x509_vfy.h
11.Ft int
12.Fo X509_STORE_CTX_get_ex_new_index
13.Fa "long argl"
14.Fa "void *argp"
15.Fa "CRYPTO_EX_new *new_func"
16.Fa "CRYPTO_EX_dup *dup_func"
17.Fa "CRYPTO_EX_free *free_func"
18.Fc
19.Ft int
20.Fo X509_STORE_CTX_set_ex_data
21.Fa "X509_STORE_CTX *d"
22.Fa "int idx"
23.Fa "void *arg"
24.Fc
25.Ft void *
26.Fo X509_STORE_CTX_get_ex_data
27.Fa "X509_STORE_CTX *d"
28.Fa "int idx"
29.Fc
30.Sh DESCRIPTION
31These functions handle application specific data in
32.Vt X509_STORE_CTX
33structures.
34Their usage is identical to that of
35.Xr RSA_get_ex_new_index 3 ,
36.Xr RSA_set_ex_data 3 ,
37and
38.Xr RSA_get_ex_data 3 .
39.Pp
40This mechanism is used internally by the
41.Xr ssl 3
42library to store the
43.Vt SSL
44structure associated with a verification operation in an
45.Vt X509_STORE_CTX
46structure.
47.Sh SEE ALSO
48.Xr RSA_get_ex_new_index 3
49.Sh HISTORY
50.Fn X509_STORE_CTX_get_ex_new_index ,
51.Fn X509_STORE_CTX_set_ex_data ,
52and
53.Fn X509_STORE_CTX_get_ex_data
54are available since OpenSSL 0.9.5.
diff --git a/src/lib/libcrypto/man/X509_STORE_CTX_new.3 b/src/lib/libcrypto/man/X509_STORE_CTX_new.3
new file mode 100644
index 0000000000..6a4b9e3e53
--- /dev/null
+++ b/src/lib/libcrypto/man/X509_STORE_CTX_new.3
@@ -0,0 +1,229 @@
1.Dd $Mdocdate: November 4 2016 $
2.Dt X509_STORE_CTX_NEW 3
3.Os
4.Sh NAME
5.Nm X509_STORE_CTX_new ,
6.Nm X509_STORE_CTX_cleanup ,
7.Nm X509_STORE_CTX_free ,
8.Nm X509_STORE_CTX_init ,
9.Nm X509_STORE_CTX_trusted_stack ,
10.Nm X509_STORE_CTX_set_cert ,
11.Nm X509_STORE_CTX_set_chain ,
12.Nm X509_STORE_CTX_set0_crls ,
13.Nm X509_STORE_CTX_get0_param ,
14.Nm X509_STORE_CTX_set0_param ,
15.Nm X509_STORE_CTX_set_default
16.Nd X509_STORE_CTX initialisation
17.Sh SYNOPSIS
18.In openssl/x509_vfy.h
19.Ft X509_STORE_CTX *
20.Fn X509_STORE_CTX_new void
21.Ft void
22.Fo X509_STORE_CTX_cleanup
23.Fa "X509_STORE_CTX *ctx"
24.Fc
25.Ft void
26.Fo X509_STORE_CTX_free
27.Fa "X509_STORE_CTX *ctx"
28.Fc
29.Ft int
30.Fo X509_STORE_CTX_init
31.Fa "X509_STORE_CTX *ctx"
32.Fa "X509_STORE *store"
33.Fa "X509 *x509"
34.Fa "STACK_OF(X509) *chain"
35.Fc
36.Ft void
37.Fo X509_STORE_CTX_trusted_stack
38.Fa "X509_STORE_CTX *ctx"
39.Fa "STACK_OF(X509) *sk"
40.Fc
41.Ft void
42.Fo X509_STORE_CTX_set_cert
43.Fa "X509_STORE_CTX *ctx"
44.Fa "X509 *x"
45.Fc
46.Ft void
47.Fo X509_STORE_CTX_set_chain
48.Fa "X509_STORE_CTX *ctx"
49.Fa "STACK_OF(X509) *sk"
50.Fc
51.Ft void
52.Fo X509_STORE_CTX_set0_crls
53.Fa "X509_STORE_CTX *ctx"
54.Fa "STACK_OF(X509_CRL) *sk"
55.Fc
56.Ft X509_VERIFY_PARAM *
57.Fo X509_STORE_CTX_get0_param
58.Fa "X509_STORE_CTX *ctx"
59.Fc
60.Ft void
61.Fo X509_STORE_CTX_set0_param
62.Fa "X509_STORE_CTX *ctx"
63.Fa "X509_VERIFY_PARAM *param"
64.Fc
65.Ft int
66.Fo X509_STORE_CTX_set_default
67.Fa "X509_STORE_CTX *ctx"
68.Fa "const char *name"
69.Fc
70.Sh DESCRIPTION
71These functions initialise an
72.Vt X509_STORE_CTX
73structure for subsequent use by
74.Xr X509_verify_cert 3 .
75.Pp
76.Fn X509_STORE_CTX_new
77returns a newly initialised
78.Vt X509_STORE_CTX
79structure.
80.Pp
81.Fn X509_STORE_CTX_cleanup
82internally cleans up an
83.Vt X509_STORE_CTX
84structure.
85The context can then be reused with an new call to
86.Fn X509_STORE_CTX_init .
87.Pp
88.Fn X509_STORE_CTX_free
89completely frees up
90.Fa ctx .
91After this call
92.Fa ctx
93is no longer valid.
94.Pp
95.Fn X509_STORE_CTX_init
96sets up
97.Fa ctx
98for a subsequent verification operation.
99The trusted certificate store is set to
100.Fa store ,
101the end entity certificate to be verified is set to
102.Fa x509
103and a set of additional certificates (which will be untrusted but may be
104used to build the chain) in
105.Fa chain .
106Any or all of the
107.Fa store ,
108.Fa x509 ,
109and
110.Fa chain
111parameters can be
112.Dv NULL .
113.Pp
114.Fn X509_STORE_CTX_trusted_stack
115sets the set of trusted certificates of
116.Fa ctx
117to
118.Fa sk .
119This is an alternative way of specifying trusted certificates instead of
120using an
121.Vt X509_STORE .
122.Pp
123.Fn X509_STORE_CTX_set_cert
124sets the certificate to be verified in
125.Fa ctx
126to
127.Fa x .
128.Pp
129.Fn X509_STORE_CTX_set_chain
130sets the additional certificate chain used by
131.Fa ctx
132to
133.Fa sk .
134.Pp
135.Fn X509_STORE_CTX_set0_crls
136sets a set of CRLs to use to aid certificate verification to
137.Fa sk .
138These CRLs will only be used if CRL verification is enabled in the
139associated
140.Vt X509_VERIFY_PARAM
141structure.
142This might be used where additional "useful" CRLs are supplied as part
143of a protocol, for example in a PKCS#7 structure.
144.Pp
145X509_VERIFY_PARAM
146.Fn X509_STORE_CTX_get0_param
147retrieves an internal pointer to the verification parameters associated
148with
149.Fa ctx .
150.Pp
151.Fn X509_STORE_CTX_set0_param
152sets the internal verification parameter pointer to
153.Fa param .
154After this call
155.Fa param
156should not be used.
157.Pp
158.Fn X509_STORE_CTX_set_default
159looks up and sets the default verification method to
160.Fa name .
161This uses the function
162.Xr X509_VERIFY_PARAM_lookup 3
163to find an appropriate set of parameters from
164.Fa name .
165.Pp
166The certificates and CRLs in a store are used internally and should
167.Sy not
168be freed up until after the associated
169.Vt X509_STORE_CTX
170is freed.
171Legacy applications might implicitly use an
172.Vt X509_STORE_CTX
173like this:
174.Bd -literal -offset indent
175X509_STORE_CTX ctx;
176X509_STORE_CTX_init(&ctx, store, cert, chain);
177.Ed
178.Pp
179This is
180.Sy not
181recommended in new applications they should instead do:
182.Bd -literal -offset indent
183X509_STORE_CTX *ctx;
184ctx = X509_STORE_CTX_new();
185if (ctx == NULL)
186 /* Bad error */
187X509_STORE_CTX_init(ctx, store, cert, chain);
188.Ed
189.Sh RETURN VALUES
190.Fn X509_STORE_CTX_new
191returns an newly allocates context or
192.Dv NULL
193if an error occurred.
194.Pp
195.Fn X509_STORE_CTX_init
196returns 1 for success or 0 if an error occurred.
197.Pp
198.Fn X509_STORE_CTX_get0_param
199returns a pointer to an
200.Vt X509_VERIFY_PARAM
201structure or
202.Dv NULL
203if an error occurred.
204.Pp
205.Fn X509_STORE_CTX_cleanup ,
206.Fn X509_STORE_CTX_free ,
207.Fn X509_STORE_CTX_trusted_stack ,
208.Fn X509_STORE_CTX_set_cert ,
209.Fn X509_STORE_CTX_set_chain ,
210.Fn X509_STORE_CTX_set0_crls ,
211and
212.Fn X509_STORE_CTX_set0_param
213do not return values.
214.Pp
215.Fn X509_STORE_CTX_set_default
216returns 1 for success or 0 if an error occurred.
217.Sh SEE ALSO
218.Xr X509_verify_cert 3 ,
219.Xr X509_VERIFY_PARAM_set_flags 3
220.Sh HISTORY
221.Fn X509_STORE_CTX_set0_crls
222was first added to OpenSSL 1.0.0.
223.Sh BUGS
224The certificates and CRLs in a context are used internally and should
225.Sy not
226be freed up until after the associated
227.Vt X509_STORE_CTX
228is freed.
229Copies should be made or reference counts increased instead.
diff --git a/src/lib/libcrypto/man/X509_STORE_CTX_set_verify_cb.3 b/src/lib/libcrypto/man/X509_STORE_CTX_set_verify_cb.3
new file mode 100644
index 0000000000..f588bd7d70
--- /dev/null
+++ b/src/lib/libcrypto/man/X509_STORE_CTX_set_verify_cb.3
@@ -0,0 +1,185 @@
1.Dd $Mdocdate: November 4 2016 $
2.Dt X509_STORE_CTX_SET_VERIFY_CB 3
3.Os
4.Sh NAME
5.Nm X509_STORE_CTX_set_verify_cb
6.Nd set verification callback
7.Sh SYNOPSIS
8.In openssl/x509_vfy.h
9.Ft void
10.Fo X509_STORE_CTX_set_verify_cb
11.Fa "X509_STORE_CTX *ctx"
12.Fa "int (*verify_cb)(int ok, X509_STORE_CTX *ctx)"
13.Fc
14.Sh DESCRIPTION
15.Fn X509_STORE_CTX_set_verify_cb
16sets the verification callback of
17.Fa ctx
18to
19.Fa verify_cb
20overwriting any existing callback.
21.Pp
22The verification callback can be used to customise the operation of
23certificate verification, either by overriding error conditions or
24logging errors for debugging purposes.
25.Pp
26However a verification callback is
27.Sy not
28essential and the default operation is often sufficient.
29.Pp
30The
31.Fa ok
32parameter to the callback indicates the value the callback should return
33to retain the default behaviour.
34If it is zero then and error condition is indicated.
35If it is 1 then no error occurred.
36If the flag
37.Dv X509_V_FLAG_NOTIFY_POLICY
38is set, then
39.Fa ok
40is set to 2 to indicate the policy checking is complete.
41.Pp
42The
43.Fa ctx
44parameter to the callback is the
45.Vt X509_STORE_CTX
46structure that is performing the verification operation.
47A callback can examine this structure and receive additional information
48about the error, for example by calling
49.Xr X509_STORE_CTX_get_current_cert 3 .
50Additional application data can be passed to the callback via the
51.Sy ex_data
52mechanism.
53.Pp
54The verification callback can be set and inherited from the parent
55structure performing the operation.
56In some cases (such as S/MIME verification) the
57.Vt X509_STORE_CTX
58structure is created and destroyed internally and the only way to set a
59custom verification callback is by inheriting it from the associated
60.Vt X509_STORE .
61.Sh RETURN VALUES
62.Fn X509_STORE_CTX_set_verify_cb
63does not return a value.
64.Sh EXAMPLES
65Default callback operation:
66.Bd -literal
67int
68verify_callback(int ok, X509_STORE_CTX *ctx)
69 {
70 return ok;
71}
72.Ed
73.Pp
74Simple example, suppose a certificate in the chain is expired and we
75wish to continue after this error:
76.Bd -literal
77int
78verify_callback(int ok, X509_STORE_CTX *ctx)
79{
80 /* Tolerate certificate expiration */
81 if (X509_STORE_CTX_get_error(ctx) == X509_V_ERR_CERT_HAS_EXPIRED)
82 return 1;
83 /* Otherwise don't override */
84 return ok;
85}
86.Ed
87.Pp
88More complex example, we don't wish to continue after
89.Sy any
90certificate has expired just one specific case:
91.Bd -literal
92int
93verify_callback(int ok, X509_STORE_CTX *ctx)
94{
95 int err = X509_STORE_CTX_get_error(ctx);
96 X509 *err_cert = X509_STORE_CTX_get_current_cert(ctx);
97
98 if (err == X509_V_ERR_CERT_HAS_EXPIRED) {
99 if (check_is_acceptable_expired_cert(err_cert)
100 return 1;
101 }
102 return ok;
103}
104.Ed
105.Pp
106Full featured logging callback.
107In this case the
108.Fa bio_err
109is assumed to be a global logging
110.Vt BIO ,
111an alternative would to store a
112.Vt BIO
113in
114.Fa ctx
115using
116.Sy ex_data .
117.Bd -literal
118int
119verify_callback(int ok, X509_STORE_CTX *ctx)
120{
121 X509 *err_cert;
122 int err,depth;
123
124 err_cert = X509_STORE_CTX_get_current_cert(ctx);
125 err = X509_STORE_CTX_get_error(ctx);
126 depth = X509_STORE_CTX_get_error_depth(ctx);
127
128 BIO_printf(bio_err,"depth=%d ",depth);
129 if (err_cert) {
130 X509_NAME_print_ex(bio_err,
131 X509_get_subject_name(err_cert), 0,
132 XN_FLAG_ONELINE);
133 BIO_puts(bio_err, "\en");
134 } else
135 BIO_puts(bio_err, "<no cert>\en");
136 if (!ok)
137 BIO_printf(bio_err, "verify error:num=%d:%s\en",
138 err, X509_verify_cert_error_string(err));
139 switch (err) {
140 case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT:
141 BIO_puts(bio_err, "issuer= ");
142 X509_NAME_print_ex(bio_err,
143 X509_get_issuer_name(err_cert), 0,
144 XN_FLAG_ONELINE);
145 BIO_puts(bio_err, "\en");
146 break;
147 case X509_V_ERR_CERT_NOT_YET_VALID:
148 case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD:
149 BIO_printf(bio_err, "notBefore=");
150 ASN1_TIME_print(bio_err,
151 X509_get_notBefore(err_cert));
152 BIO_printf(bio_err, "\en");
153 break;
154 case X509_V_ERR_CERT_HAS_EXPIRED:
155 case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD:
156 BIO_printf(bio_err, "notAfter=");
157 ASN1_TIME_print(bio_err, X509_get_notAfter(err_cert));
158 BIO_printf(bio_err, "\en");
159 break;
160 case X509_V_ERR_NO_EXPLICIT_POLICY:
161 policies_print(bio_err, ctx);
162 break;
163 }
164 if (err == X509_V_OK && ok == 2)
165 /* print out policies */
166
167 BIO_printf(bio_err,"verify return:%d\en",ok);
168 return(ok);
169}
170.Ed
171.Sh SEE ALSO
172.Xr X509_STORE_CTX_get_error 3 ,
173.Xr X509_STORE_CTX_get_ex_new_index 3 ,
174.Xr X509_STORE_set_verify_cb_func 3
175.Sh HISTORY
176.Fn X509_STORE_CTX_set_verify_cb
177is available in all versions of SSLeay and OpenSSL.
178.Sh CAVEATS
179In general a verification callback should
180.Sy NOT
181unconditionally return 1 in all circumstances because this will allow
182verification to succeed no matter what the error.
183This effectively removes all security from the application because
184.Sy any
185certificate (including untrusted generated ones) will be accepted.
diff --git a/src/lib/libcrypto/man/X509_STORE_set_verify_cb_func.3 b/src/lib/libcrypto/man/X509_STORE_set_verify_cb_func.3
new file mode 100644
index 0000000000..5db4313047
--- /dev/null
+++ b/src/lib/libcrypto/man/X509_STORE_set_verify_cb_func.3
@@ -0,0 +1,54 @@
1.Dd $Mdocdate: November 4 2016 $
2.Dt X509_STORE_SET_VERIFY_CB_FUNC 3
3.Os
4.Sh NAME
5.Nm X509_STORE_set_verify_cb_func ,
6.Nm X509_STORE_set_verify_cb
7.Nd set verification callback
8.Sh SYNOPSIS
9.In openssl/x509_vfy.h
10.Ft void
11.Fo X509_STORE_set_verify_cb
12.Fa "X509_STORE *st"
13.Fa "int (*verify_cb)(int ok, X509_STORE_CTX *ctx)"
14.Fc
15.Ft void
16.Fo X509_STORE_set_verify_cb_func
17.Fa "X509_STORE *st"
18.Fa "int (*verify_cb)(int ok, X509_STORE_CTX *ctx)"
19.Fc
20.Sh DESCRIPTION
21.Fn X509_STORE_set_verify_cb
22sets the verification callback of
23.Sy ctx
24to
25.Sy verify_cb
26overwriting any existing callback.
27.Pp
28.Fn X509_STORE_set_verify_cb_func
29also sets the verification callback but it is implemented as a macro.
30.Pp
31The verification callback from an
32.Vt X509_STORE
33is inherited by the corresponding
34.Vt X509_STORE_CTX
35structure when it is initialized.
36This can be used to set the verification callback when the
37.Vt X509_STORE_CTX
38is otherwise inaccessible (for example during S/MIME verification).
39.Sh RETURN VALUES
40.Fn X509_STORE_set_verify_cb
41and
42.Fn X509_STORE_set_verify_cb_func
43do not return a value.
44.Sh SEE ALSO
45.Xr X509_STORE_CTX_set_verify_cb 3
46.Sh HISTORY
47.Fn X509_STORE_set_verify_cb_func
48is available in all versions of SSLeay and OpenSSL.
49.Pp
50.Fn X509_STORE_set_verify_cb
51was added to OpenSSL 1.0.0.
52.Sh BUGS
53The macro version of this function was the only one available before
54OpenSSL 1.0.0.
diff --git a/src/lib/libcrypto/man/X509_VERIFY_PARAM_set_flags.3 b/src/lib/libcrypto/man/X509_VERIFY_PARAM_set_flags.3
new file mode 100644
index 0000000000..66724ed169
--- /dev/null
+++ b/src/lib/libcrypto/man/X509_VERIFY_PARAM_set_flags.3
@@ -0,0 +1,271 @@
1.Dd $Mdocdate: November 4 2016 $
2.Dt X509_VERIFY_PARAM_SET_FLAGS 3
3.Os
4.Sh NAME
5.Nm X509_VERIFY_PARAM_set_flags ,
6.Nm X509_VERIFY_PARAM_clear_flags ,
7.Nm X509_VERIFY_PARAM_get_flags ,
8.Nm X509_VERIFY_PARAM_set_purpose ,
9.Nm X509_VERIFY_PARAM_set_trust ,
10.Nm X509_VERIFY_PARAM_set_depth ,
11.Nm X509_VERIFY_PARAM_get_depth ,
12.Nm X509_VERIFY_PARAM_set_time ,
13.Nm X509_VERIFY_PARAM_add0_policy ,
14.Nm X509_VERIFY_PARAM_set1_policies
15.Nd X509 verification parameters
16.Sh SYNOPSIS
17.In openssl/x509_vfy.h
18.Ft int
19.Fo X509_VERIFY_PARAM_set_flags
20.Fa "X509_VERIFY_PARAM *param"
21.Fa "unsigned long flags"
22.Fc
23.Ft int
24.Fo X509_VERIFY_PARAM_clear_flags
25.Fa "X509_VERIFY_PARAM *param"
26.Fa "unsigned long flags"
27.Fc
28.Ft unsigned long
29.Fo X509_VERIFY_PARAM_get_flags
30.Fa "X509_VERIFY_PARAM *param"
31.Fc
32.Ft int
33.Fo X509_VERIFY_PARAM_set_purpose
34.Fa "X509_VERIFY_PARAM *param"
35.Fa "int purpose"
36.Fc
37.Ft int
38.Fo X509_VERIFY_PARAM_set_trust
39.Fa "X509_VERIFY_PARAM *param"
40.Fa "int trust"
41.Fc
42.Ft void
43.Fo X509_VERIFY_PARAM_set_time
44.Fa "X509_VERIFY_PARAM *param"
45.Fa "time_t t"
46.Fc
47.Ft int
48.Fo X509_VERIFY_PARAM_add0_policy
49.Fa "X509_VERIFY_PARAM *param"
50.Fa "ASN1_OBJECT *policy"
51.Fc
52.Ft int
53.Fo X509_VERIFY_PARAM_set1_policies
54.Fa "X509_VERIFY_PARAM *param"
55.Fa "STACK_OF(ASN1_OBJECT) *policies"
56.Fc
57.Ft void
58.Fo X509_VERIFY_PARAM_set_depth
59.Fa "X509_VERIFY_PARAM *param"
60.Fa "int depth"
61.Fc
62.Ft int
63.Fo X509_VERIFY_PARAM_get_depth
64.Fa "const X509_VERIFY_PARAM *param"
65.Fc
66.Sh DESCRIPTION
67These functions manipulate the
68.Vt X509_VERIFY_PARAM
69structure associated with a certificate verification operation.
70.Pp
71The
72.Fn X509_VERIFY_PARAM_set_flags
73function sets the flags in
74.Fa param
75by OR'ing it with
76.Fa flags .
77See the
78.Sx VERIFICATION FLAGS
79section for a complete description of values the
80.Fa flags
81parameter can take.
82.Pp
83.Fn X509_VERIFY_PARAM_get_flags
84returns the flags in
85.Fa param .
86.Pp
87.Fn X509_VERIFY_PARAM_clear_flags
88clears the flags
89.Fa flags
90in
91.Fa param .
92.Pp
93.Fn X509_VERIFY_PARAM_set_purpose
94sets the verification purpose in
95.Fa param
96to
97.Fa purpose .
98This determines the acceptable purpose of the certificate chain, for
99example SSL client or SSL server.
100.Pp
101.Fn X509_VERIFY_PARAM_set_trust
102sets the trust setting in
103.Fa param
104to
105.Fa trust .
106.Pp
107.Fn X509_VERIFY_PARAM_set_time
108sets the verification time in
109.Fa param
110to
111.Fa t .
112Normally the current time is used.
113.Pp
114.Fn X509_VERIFY_PARAM_add0_policy
115enables policy checking (it is disabled by default) and adds
116.Fa policy
117to the acceptable policy set.
118.Pp
119.Fn X509_VERIFY_PARAM_set1_policies
120enables policy checking (it is disabled by default) and sets the
121acceptable policy set to
122.Fa policies .
123Any existing policy set is cleared.
124The
125.Fa policies
126parameter can be
127.Dv NULL
128to clear an existing policy set.
129.Pp
130.Fn X509_VERIFY_PARAM_set_depth
131sets the maximum verification depth to
132.Fa depth .
133That is the maximum number of untrusted CA certificates that can appear
134in a chain.
135.Pp
136The above functions should be used to manipulate verification parameters
137instead of legacy functions which work in specific structures such as
138.Xr X509_STORE_CTX_set_flags 3 .
139.Sh RETURN VALUES
140.Fn X509_VERIFY_PARAM_set_flags ,
141.Fn X509_VERIFY_PARAM_clear_flags ,
142.Fn X509_VERIFY_PARAM_set_purpose ,
143.Fn X509_VERIFY_PARAM_set_trust ,
144.Fn X509_VERIFY_PARAM_add0_policy ,
145and
146.Fn X509_VERIFY_PARAM_set1_policies
147return 1 for success or 0 for failure.
148.Pp
149.Fn X509_VERIFY_PARAM_get_flags
150returns the current verification flags.
151.Pp
152.Fn X509_VERIFY_PARAM_set_time
153and
154.Fn X509_VERIFY_PARAM_set_depth
155do not return values.
156.Pp
157.Fn X509_VERIFY_PARAM_get_depth
158returns the current verification depth.
159.Sh VERIFICATION FLAGS
160The verification flags consists of zero or more of the following
161flags OR'ed together.
162.Pp
163.Dv X509_V_FLAG_CRL_CHECK
164enables CRL checking for the certificate chain leaf certificate.
165An error occurs if a suitable CRL cannot be found.
166.Pp
167.Dv X509_V_FLAG_CRL_CHECK_ALL
168enables CRL checking for the entire certificate chain.
169.Pp
170.Dv X509_V_FLAG_IGNORE_CRITICAL
171disabled critical extension checking.
172By default any unhandled critical extensions in certificates or (if
173checked) CRLs results in a fatal error.
174If this flag is set unhandled critical extensions are ignored.
175.Sy WARNING :
176setting this option for anything other than debugging purposes can be a
177security risk.
178Finer control over which extensions are supported can be performed in
179the verification callback.
180.Pp
181The
182.Dv X509_V_FLAG_X509_STRICT
183flag disables workarounds for some broken certificates and makes the
184verification strictly apply X509 rules.
185.Pp
186.Dv X509_V_FLAG_ALLOW_PROXY_CERTS
187enables proxy certificate verification.
188.Pp
189.Dv X509_V_FLAG_POLICY_CHECK
190enables certificate policy checking, by default no policy checking is
191performed.
192Additional information is sent to the verification callback relating to
193policy checking.
194.Pp
195.Dv X509_V_FLAG_EXPLICIT_POLICY ,
196.Dv X509_V_FLAG_INHIBIT_ANY ,
197and
198.Dv X509_V_FLAG_INHIBIT_MAP
199set the
200.Dq require explicit policy ,
201.Dq inhibit any policy ,
202and
203.Dq inhibit policy mapping
204flags, respectively, as defined in RFC3280.
205Policy checking is automatically enabled if any of these flags are set.
206.Pp
207If
208.Dv X509_V_FLAG_NOTIFY_POLICY
209is set and the policy checking is successful a special status code is
210set to the verification callback.
211This permits it to examine the valid policy tree and perform additional
212checks or simply log it for debugging purposes.
213.Pp
214By default some additional features such as indirect CRLs and CRLs
215signed by different keys are disabled.
216If
217.Dv X509_V_FLAG_EXTENDED_CRL_SUPPORT
218is set they are enabled.
219.Pp
220If
221.Dv X509_V_FLAG_USE_DELTAS
222is set, delta CRLs (if present) are used to determine certificate
223status.
224If not set, deltas are ignored.
225.Pp
226.Dv X509_V_FLAG_CHECK_SS_SIGNATURE
227enables checking of the root CA self signed certificate signature.
228By default this check is disabled because it doesn't add any additional
229security but in some cases applications might want to check the
230signature anyway.
231A side effect of not checking the root CA signature is that disabled or
232unsupported message digests on the root CA are not treated as fatal
233errors.
234.Pp
235The
236.Dv X509_V_FLAG_CB_ISSUER_CHECK
237flag enables debugging of certificate issuer checks.
238It is
239.Sy not
240needed unless you are logging certificate verification.
241If this flag is set then additional status codes will be sent to the
242verification callback and it
243.Sy must
244be prepared to handle such cases without assuming they are hard errors.
245.Sh EXAMPLES
246Enable CRL checking when performing certificate verification during
247SSL connections associated with an
248.Vt SSL_CTX
249structure
250.Fa ctx :
251.Bd -literal
252X509_VERIFY_PARAM *param;
253param = X509_VERIFY_PARAM_new();
254X509_VERIFY_PARAM_set_flags(param, X509_V_FLAG_CRL_CHECK);
255SSL_CTX_set1_param(ctx, param);
256X509_VERIFY_PARAM_free(param);
257.Ed
258.Sh SEE ALSO
259.Xr X509_verify_cert 3
260.Sh BUGS
261Delta CRL checking is currently primitive.
262Only a single delta can be used and (partly due to limitations of
263.Vt X509_STORE )
264constructed CRLs are not maintained.
265.Pp
266If CRLs checking is enabled, CRLs are expected to be available in
267the corresponding
268.Vt X509_STORE
269structure.
270No attempt is made to download CRLs from the CRL distribution points
271extension.
diff --git a/src/lib/libcrypto/man/X509_new.3 b/src/lib/libcrypto/man/X509_new.3
new file mode 100644
index 0000000000..26c46ae3a9
--- /dev/null
+++ b/src/lib/libcrypto/man/X509_new.3
@@ -0,0 +1,49 @@
1.Dd $Mdocdate: November 4 2016 $
2.Dt X509_NEW 3
3.Os
4.Sh NAME
5.Nm X509_new ,
6.Nm X509_free
7.Nd X509 certificate ASN1 allocation functions
8.Sh SYNOPSIS
9.In openssl/x509.h
10.Ft X509 *
11.Fn X509_new void
12.Ft void
13.Fo X509_free
14.Fa "X509 *a"
15.Fc
16.Sh DESCRIPTION
17The X509 ASN1 allocation routines allocate and free an
18.Vt X509
19structure, which represents an X509 certificate.
20.Pp
21.Fn X509_new
22allocates and initializes a X509 structure.
23.Pp
24.Fn X509_free
25frees up the
26.Vt X509
27structure
28.Fa a .
29If
30.Fa a
31is a
32.Dv NULL
33pointer, no action occurs.
34.Sh RETURN VALUES
35If the allocation fails,
36.Fn X509_new
37returns
38.Dv NULL
39and sets an error code that can be obtained by
40.Xr ERR_get_error 3 .
41Otherwise it returns a pointer to the newly allocated structure.
42.Sh SEE ALSO
43.Xr d2i_X509 3 ,
44.Xr ERR_get_error 3
45.Sh HISTORY
46.Fn X509_new
47and
48.Fn X509_free
49are available in all versions of SSLeay and OpenSSL.
diff --git a/src/lib/libcrypto/man/X509_verify_cert.3 b/src/lib/libcrypto/man/X509_verify_cert.3
new file mode 100644
index 0000000000..fd3d6bebda
--- /dev/null
+++ b/src/lib/libcrypto/man/X509_verify_cert.3
@@ -0,0 +1,54 @@
1.Dd $Mdocdate: November 4 2016 $
2.Dt X509_VERIFY_CERT 3
3.Os
4.Sh NAME
5.Nm X509_verify_cert
6.Nd discover and verify X509 certificate chain
7.Sh SYNOPSIS
8.In openssl/x509.h
9.Ft int
10.Fo X509_verify_cert
11.Fa "X509_STORE_CTX *ctx"
12.Fc
13.Sh DESCRIPTION
14The
15.Fn X509_verify_cert
16function attempts to discover and validate a certificate chain based on
17parameters in
18.Fa ctx .
19.Pp
20Applications rarely call this function directly, but it is used by
21OpenSSL internally for certificate validation, in both the S/MIME and
22SSL/TLS code.
23.Sh RETURN VALUES
24If a complete chain can be built and validated this function returns 1,
25otherwise it return 0.
26.Pp
27In exceptional circumstances, it can also return a negative code,
28but only if no certificate is set in
29.Fa ctx
30due to a programming error or if a retry operation is requested
31during internal lookups, which never happens with standard lookup
32methods.
33It is however recommended that application check for <= 0 return
34value on error.
35.Pp
36If the function fails, additional error information can be obtained
37by examining
38.Fa ctx ,
39for example using
40.Xr X509_STORE_CTX_get_error 3 .
41.Sh SEE ALSO
42.Xr X509_STORE_CTX_get_error 3
43and the
44.Cm verify
45entry in
46.Xr openssl 1
47.Sh HISTORY
48.Fn X509_verify_cert
49is available in all versions of SSLeay and OpenSSL.
50.Sh BUGS
51This function uses the header
52.In openssl/x509.h
53as opposed to most chain verification functions which use
54.In openssl/x509_vfy.h .
diff --git a/src/lib/libcrypto/man/d2i_X509.3 b/src/lib/libcrypto/man/d2i_X509.3
new file mode 100644
index 0000000000..09c65afa58
--- /dev/null
+++ b/src/lib/libcrypto/man/d2i_X509.3
@@ -0,0 +1,346 @@
1.Dd $Mdocdate: November 4 2016 $
2.Dt D2I_X509 3
3.Os
4.Sh NAME
5.Nm d2i_X509 ,
6.Nm i2d_X509 ,
7.Nm d2i_X509_bio ,
8.Nm d2i_X509_fp ,
9.Nm i2d_X509_bio ,
10.Nm i2d_X509_fp
11.Nd X509 encode and decode functions
12.Sh SYNOPSIS
13.In openssl/x509.h
14.Ft X509 *
15.Fo d2i_X509
16.Fa "X509 **px"
17.Fa "const unsigned char **in"
18.Fa "int len"
19.Fc
20.Ft int
21.Fo i2d_X509
22.Fa "X509 *x"
23.Fa "unsigned char **out"
24.Fc
25.Ft X509 *
26.Fo d2i_X509_bio
27.Fa "BIO *bp"
28.Fa "X509 **x"
29.Fc
30.Ft X509 *
31.Fo d2i_X509_fp
32.Fa "FILE *fp"
33.Fa "X509 **x"
34.Fc
35.Ft int
36.Fo i2d_X509_bio
37.Fa "BIO *bp"
38.Fa "X509 *x"
39.Fc
40.Ft int
41.Fo i2d_X509_fp
42.Fa "FILE *fp"
43.Fa "X509 *x"
44.Fc
45.Sh DESCRIPTION
46The X509 encode and decode routines encode and parse an
47.Vt X509
48structure, which represents an X509 certificate.
49.Pp
50.Fn d2i_X509
51attempts to decode
52.Fa len
53bytes at
54.Pf * Fa in .
55If successful, a pointer to the
56.Vt X509
57structure is returned.
58If an error occurred,
59.Dv NULL
60is returned.
61If
62.Fa px
63is not
64.Dv NULL ,
65the returned structure is written to
66.Pf * Fa px .
67If
68.Pf * Fa px
69is not
70.Dv NULL ,
71then it is assumed that
72.Pf * Fa px
73contains a valid
74.Vt X509
75structure and an attempt is made to reuse it.
76If the call is successful,
77.Pf * Fa in
78is incremented to the byte following the parsed data.
79.Pp
80.Fn i2d_X509
81encodes the structure pointed to by
82.Fa x
83into DER format.
84If
85.Fa out
86is not
87.Dv NULL ,
88it writes the DER encoded data to the buffer at
89.Pf * Fa out
90and increments it to point after the data just written.
91If the return value is negative an error occurred, otherwise it returns
92the length of the encoded data.
93.Pp
94For OpenSSL 0.9.7 and later if
95.Pf * Fa out
96is
97.Dv NULL ,
98memory will be allocated for a buffer and the encoded data written to it.
99In this case
100.Pf * Fa out
101is not incremented and it points to the start of the data just written.
102.Pp
103.Fn d2i_X509_bio
104is similar to
105.Fn d2i_X509
106except it attempts to parse data from
107.Vt BIO
108.Fa bp .
109.Pp
110.Fn d2i_X509_fp
111is similar to
112.Fn d2i_X509
113except it attempts to parse data from the
114.Vt FILE
115pointer
116.Fa fp .
117.Pp
118.Fn i2d_X509_bio
119is similar to
120.Fn i2d_X509
121except it writes the encoding of the structure
122.Fa x
123to
124.Vt BIO
125.Fa bp
126and it returns 1 for success or 0 for failure.
127.Pp
128.Fn i2d_X509_fp
129is similar to
130.Fn i2d_X509
131except it writes the encoding of the structure
132.Fa x
133to
134.Vt BIO
135.Fa bp
136and it returns 1 for success or 0 for failure.
137.Pp
138The letters
139.Sy i
140and
141.Sy d
142in for example
143.Fn i2d_X509
144stand for "internal" (that is an internal C structure) and "DER",
145so that
146.Fn i2d_X509
147converts from internal to DER.
148.Pp
149The functions can also understand BER forms.
150.Pp
151The actual
152.Vt X509
153structure passed to
154.Fn i2d_X509
155must be a valid populated
156.Vt X509
157structure.
158It cannot simply be fed with an empty structure such as that returned by
159.Xr X509_new 3 .
160.Pp
161The encoded data is in binary form and may contain embedded zeroes.
162Therefore any
163.Vt FILE
164pointers or
165.Vt BIO Ns s
166should be opened in binary mode.
167Functions such as
168.Xr strlen 3
169will
170.Sy not
171return the correct length of the encoded structure.
172.Pp
173The ways that
174.Pf * Fa in
175and
176.Pf * Fa out
177are incremented after the operation can trap the unwary.
178See the
179.Sx CAVEATS
180section for some common errors.
181.Pp
182The reason for the auto increment behaviour is to reflect a typical
183usage of ASN1 functions: after one structure is encoded or decoded,
184another will processed after it.
185.Sh RETURN VALUES
186.Fn d2i_X509 ,
187.Fn d2i_X509_bio ,
188and
189.Fn d2i_X509_fp
190return a valid
191.Vt X509
192structure or
193.Dv NULL
194if an error occurs.
195.Pp
196.Fn i2d_X509
197returns the number of bytes successfully encoded or a negative value if
198an error occurs.
199.Pp
200.Fn i2d_X509_bio
201and
202.Fn i2d_X509_fp
203return 1 for success or 0 if an error occurs.
204.Pp
205For all functions, the error code can be obtained by
206.Xr ERR_get_error 3 .
207.Sh EXAMPLES
208Allocate and encode the DER encoding of an X509 structure:
209.Bd -literal -offset indent
210int len;
211unsigned char *buf, *p;
212
213len = i2d_X509(x, NULL);
214buf = malloc(len);
215if (buf == NULL)
216 /* error */
217p = buf;
218i2d_X509(x, &p);
219.Ed
220.Pp
221If you are using OpenSSL 0.9.7 or later then this can be simplified to:
222.Bd -literal -offset indent
223int len;
224unsigned char *buf;
225
226buf = NULL;
227len = i2d_X509(x, &buf);
228if (len < 0)
229 /* error */
230.Ed
231.Pp
232Attempt to decode a buffer:
233.Bd -literal -offset indent
234X509 *x;
235unsigned char *buf, *p;
236int len;
237
238/* Something to setup buf and len */
239p = buf;
240x = d2i_X509(NULL, &p, len);
241if (x == NULL)
242 /* Some error */
243.Ed
244.Pp
245Alternative technique:
246.Bd -literal -offset indent
247X509 *x;
248unsigned char *buf, *p;
249int len;
250
251/* Something to setup buf and len */
252p = buf;
253x = NULL;
254if(!d2i_X509(&x, &p, len))
255 /* Some error */
256.Ed
257.Sh SEE ALSO
258.Xr ERR_get_error 3
259.Sh HISTORY
260.Fn d2i_X509 ,
261.Fn i2d_X509 ,
262.Fn d2i_X509_bio ,
263.Fn d2i_X509_fp ,
264.Fn i2d_X509_bio ,
265and
266.Fn i2d_X509_fp
267are available in all versions of SSLeay and OpenSSL.
268.Sh CAVEATS
269The use of a temporary variable is mandatory.
270A common mistake is to attempt to use a buffer directly as follows:
271.Bd -literal -offset indent
272int len;
273unsigned char *buf;
274
275len = i2d_X509(x, NULL);
276buf = malloc(len);
277if (buf == NULL)
278 /* error */
279i2d_X509(x, &buf);
280/* Other stuff ... */
281free(buf);
282.Ed
283.Pp
284This code will result in
285.Fa buf
286apparently containing garbage because it was incremented after the
287call to point after the data just written.
288Also
289.Fa buf
290will no longer contain the pointer allocated by
291.Xr malloc 3
292and the subsequent call to
293.Xr free 3
294may well crash.
295.Pp
296The auto allocation feature (setting
297.Fa buf
298to
299.Dv NULL
300only works on OpenSSL 0.9.7 and later.
301Attempts to use it on earlier versions will typically cause a
302segmentation violation.
303.Pp
304Another trap to avoid is misuse of the
305.Fa px
306argument to
307.Sy d2i_X509() :
308.Bd -literal -offset indent
309X509 *x;
310
311if (!d2i_X509(&x, &p, len))
312 /* Some error */
313.Ed
314.Pp
315This will probably crash somewhere in
316.Fn d2i_X509 .
317The reason for this is that the variable
318.Fa x
319is uninitialized and an attempt will be made to interpret its (invalid)
320value as an
321.Vt X509
322structure, typically causing a segmentation violation.
323If
324.Fa x
325is set to
326.Dv NULL
327first then this will not happen.
328.Sh BUGS
329In some versions of OpenSSL the "reuse" behaviour of
330.Fn d2i_X509
331when
332.Pf * Fa px
333is valid is broken and some parts of the reused structure may persist
334if they are not present in the new one.
335As a result the use of this "reuse" behaviour is strongly discouraged.
336.Pp
337In many versions of OpenSSL,
338.Fn i2d_X509
339will not return an error if mandatory fields are not initialized
340due to a programming error.
341Then the encoded structure may contain invalid data or omit the
342fields entirely and will not be parsed by
343.Fn d2i_X509 .
344This may be fixed in future so code should not assume that
345.Fn i2d_X509
346will always succeed.
diff --git a/src/lib/libcrypto/man/d2i_X509_ALGOR.3 b/src/lib/libcrypto/man/d2i_X509_ALGOR.3
new file mode 100644
index 0000000000..e17678019b
--- /dev/null
+++ b/src/lib/libcrypto/man/d2i_X509_ALGOR.3
@@ -0,0 +1,33 @@
1.Dd $Mdocdate: November 4 2016 $
2.Dt D2I_X509_ALGOR 3
3.Os
4.Sh NAME
5.Nm d2i_X509_ALGOR ,
6.Nm i2d_X509_ALGOR
7.Nd AlgorithmIdentifier functions
8.Sh SYNOPSIS
9.In openssl/x509.h
10.Ft X509_ALGOR *
11.Fo d2i_X509_ALGOR
12.Fa "X509_ALGOR **a"
13.Fa "unsigned char **pp"
14.Fa "long length"
15.Fc
16.Ft int
17.Fo i2d_X509_ALGOR
18.Fa "X509_ALGOR *a"
19.Fa "unsigned char **pp"
20.Fc
21.Sh DESCRIPTION
22These functions decode and encode an
23.Vt X509_ALGOR
24structure which is equivalent to the
25.Sy AlgorithmIdentifier
26structure.
27.Pp
28Otherwise these behave in a way similar to
29.Xr d2i_X509 3
30and
31.Xr i2d_X509 3 .
32.Sh SEE ALSO
33.Xr d2i_X509 3
diff --git a/src/lib/libcrypto/man/d2i_X509_CRL.3 b/src/lib/libcrypto/man/d2i_X509_CRL.3
new file mode 100644
index 0000000000..e487da16d0
--- /dev/null
+++ b/src/lib/libcrypto/man/d2i_X509_CRL.3
@@ -0,0 +1,54 @@
1.Dd $Mdocdate: November 4 2016 $
2.Dt D2I_X509_CRL 3
3.Os
4.Sh NAME
5.Nm d2i_X509_CRL ,
6.Nm i2d_X509_CRL ,
7.Nm d2i_X509_CRL_bio ,
8.Nm d2i_X509_CRL_fp ,
9.Nm i2d_X509_CRL_bio ,
10.Nm i2d_X509_CRL_fp
11.Nd PKCS#10 certificate request functions
12.Sh SYNOPSIS
13.In openssl/x509.h
14.Ft X509_CRL *
15.Fo d2i_X509_CRL
16.Fa "X509_CRL **a"
17.Fa "const unsigned char **pp"
18.Fa "long length"
19.Fc
20.Ft int
21.Fo i2d_X509_CRL
22.Fa "X509_CRL *a"
23.Fa "unsigned char **pp"
24.Fc
25.Ft X509_CRL *
26.Fo d2i_X509_CRL_bio
27.Fa "BIO *bp"
28.Fa "X509_CRL **x"
29.Fc
30.Ft X509_CRL *
31.Fo d2i_X509_CRL_fp
32.Fa "FILE *fp"
33.Fa "X509_CRL **x"
34.Fc
35.Ft int
36.Fo i2d_X509_CRL_bio
37.Fa "BIO *bp"
38.Fa "X509_CRL *x"
39.Fc
40.Ft int
41.Fo i2d_X509_CRL_fp
42.Fa "FILE *fp"
43.Fa "X509_CRL *x"
44.Fc
45.Sh DESCRIPTION
46These functions decode and encode an X509 CRL (certificate revocation
47list).
48.Pp
49Otherwise the functions behave in a way similar to
50.Xr d2i_X509 3
51and
52.Xr i2d_X509 3 .
53.Sh SEE ALSO
54.Xr d2i_X509 3
diff --git a/src/lib/libcrypto/man/d2i_X509_NAME.3 b/src/lib/libcrypto/man/d2i_X509_NAME.3
new file mode 100644
index 0000000000..b145bf5b58
--- /dev/null
+++ b/src/lib/libcrypto/man/d2i_X509_NAME.3
@@ -0,0 +1,34 @@
1.Dd $Mdocdate: November 4 2016 $
2.Dt D2I_X509_NAME 3
3.Os
4.Sh NAME
5.Nm d2i_X509_NAME ,
6.Nm i2d_X509_NAME
7.Nd X509_NAME encoding functions
8.Sh SYNOPSIS
9.In openssl/x509.h
10.Ft X509_NAME *
11.Fo d2i_X509_NAME
12.Fa "X509_NAME **a"
13.Fa "unsigned char **pp"
14.Fa "long length"
15.Fc
16.Ft int
17.Fo i2d_X509_NAME
18.Fa "X509_NAME *a"
19.Fa "unsigned char **pp"
20.Fc
21.Sh DESCRIPTION
22These functions decode and encode an
23.Vt X509_NAME
24structure which is the same as the
25.Sy Name
26type defined in RFC2459 (and elsewhere) and used for example in
27certificate subject and issuer names.
28.Pp
29Otherwise the functions behave in a way similar to
30.Xr d2i_X509 3
31and
32.Xr i2d_X509 3 .
33.Sh SEE ALSO
34.Xr d2i_X509 3
diff --git a/src/lib/libcrypto/man/d2i_X509_REQ.3 b/src/lib/libcrypto/man/d2i_X509_REQ.3
new file mode 100644
index 0000000000..c69cd00fb1
--- /dev/null
+++ b/src/lib/libcrypto/man/d2i_X509_REQ.3
@@ -0,0 +1,53 @@
1.Dd $Mdocdate: November 4 2016 $
2.Dt D2I_X509_REQ 3
3.Os
4.Sh NAME
5.Nm d2i_X509_REQ ,
6.Nm i2d_X509_REQ ,
7.Nm d2i_X509_REQ_bio ,
8.Nm d2i_X509_REQ_fp ,
9.Nm i2d_X509_REQ_bio ,
10.Nm i2d_X509_REQ_fp
11.Nd PKCS#10 certificate request functions
12.Sh SYNOPSIS
13.In openssl/x509.h
14.Ft X509_REQ *
15.Fo d2i_X509_REQ
16.Fa "X509_REQ **a"
17.Fa "const unsigned char **pp"
18.Fa "long length"
19.Fc
20.Ft int
21.Fo i2d_X509_REQ
22.Fa "X509_REQ *a"
23.Fa "unsigned char **pp"
24.Fc
25.Ft X509_REQ *
26.Fo d2i_X509_REQ_bio
27.Fa "BIO *bp"
28.Fa "X509_REQ **x"
29.Fc
30.Ft X509_REQ *
31.Fo d2i_X509_REQ_fp
32.Fa "FILE *fp"
33.Fa "X509_REQ **x"
34.Fc
35.Ft int
36.Fo i2d_X509_REQ_bio
37.Fa "BIO *bp"
38.Fa "X509_REQ *x"
39.Fc
40.Ft int
41.Fo i2d_X509_REQ_fp
42.Fa "FILE *fp"
43.Fa "X509_REQ *x"
44.Fc
45.Sh DESCRIPTION
46These functions decode and encode a PKCS#10 certificate request.
47.Pp
48Otherwise these behave in a way similar to
49.Xr d2i_X509 3
50and
51.Xr i2d_X509 3 .
52.Sh SEE ALSO
53.Xr d2i_X509 3
diff --git a/src/lib/libcrypto/man/d2i_X509_SIG.3 b/src/lib/libcrypto/man/d2i_X509_SIG.3
new file mode 100644
index 0000000000..5356dd67de
--- /dev/null
+++ b/src/lib/libcrypto/man/d2i_X509_SIG.3
@@ -0,0 +1,33 @@
1.Dd $Mdocdate: November 4 2016 $
2.Dt D2I_X509_SIG 3
3.Os
4.Sh NAME
5.Nm d2i_X509_SIG ,
6.Nm i2d_X509_SIG
7.Nd DigestInfo functions
8.Sh SYNOPSIS
9.In openssl/x509.h
10.Ft X509_SIG *
11.Fo d2i_X509_SIG
12.Fa "X509_SIG **a"
13.Fa "unsigned char **pp"
14.Fa "long length"
15.Fc
16.Ft int
17.Fo i2d_X509_SIG
18.Fa "X509_SIG *a"
19.Fa "unsigned char **pp"
20.Fc
21.Sh DESCRIPTION
22These functions decode and encode an
23.Vt X509_SIG
24structure which is equivalent to the
25.Sy DigestInfo
26structure defined in PKCS#1 and PKCS#7.
27.Pp
28Otherwise these behave in a way similar to
29.Xr d2i_X509 3
30and
31.Xr i2d_X509 3 .
32.Sh SEE ALSO
33.Xr d2i_X509 3
diff --git a/src/lib/libcrypto/man/x509.3 b/src/lib/libcrypto/man/x509.3
new file mode 100644
index 0000000000..1f7b7f4128
--- /dev/null
+++ b/src/lib/libcrypto/man/x509.3
@@ -0,0 +1,79 @@
1.Dd $Mdocdate: November 4 2016 $
2.Dt X509 3
3.Os
4.Sh NAME
5.Nm x509
6.Nd X.509 certificate handling
7.Sh SYNOPSIS
8.In openssl/x509.h
9.Sh DESCRIPTION
10A X.509 certificate is a structured grouping of information about an
11individual, a device, or anything one can imagine.
12A X.509 CRL (certificate revocation list) is a tool to help determine if
13a certificate is still valid.
14The exact definition of those can be found in the X.509 document from
15ITU-T, or in RFC3280 from PKIX.
16In OpenSSL, the type
17.Vt X509
18is used to express such a certificate, and the type
19.Vt X509_CRL
20is used to express a CRL.
21.Pp
22A related structure is a certificate request, defined in PKCS#10 from
23RSA Security, Inc., also reflected in RFC2896.
24In OpenSSL, the type
25.Vt X509_REQ
26is used to express such a certificate request.
27.Pp
28To handle some complex parts of a certificate, there are the types
29.Vt X509_NAME
30to express a certificate name,
31.Vt X509_ATTRIBUTE
32to express a certificate attribute,
33.Vt X509_EXTENSION
34to express a certificate extension, and a few more.
35.Pp
36Finally, there's the supertype
37.Vt X509_INFO ,
38which can contain a CRL, a certificate, and a corresponding private key.
39.Pp
40The functions
41.Fa X509_* ,
42.Fa d2i_X509_* ,
43and
44.Fa i2d_X509_*
45handle X.509 certificates, with some exceptions shown below.
46.Pp
47.Fa X509_CRL_* ,
48.Fa d2i_X509_CRL_* ,
49and
50.Fa i2d_X509_CRL_*
51handle X.509 CRLs.
52.Pp
53.Fa X509_REQ_* ,
54.Fa d2i_X509_REQ_* ,
55and
56.Fa i2d_X509_REQ_*
57handle PKCS#10 certificate requests.
58.Pp
59.Fa X509_NAME_*
60handle certificate names.
61.Pp
62.Fa X509_ATTRIBUTE_*
63handle certificate attributes.
64.Pp
65.Fa X509_EXTENSION_*
66handle certificate extensions.
67.Sh SEE ALSO
68.Xr crypto 3 ,
69.Xr d2i_X509 3 ,
70.Xr d2i_X509_ALGOR 3 ,
71.Xr d2i_X509_CRL 3 ,
72.Xr d2i_X509_NAME 3 ,
73.Xr d2i_X509_REQ 3 ,
74.Xr d2i_X509_SIG 3 ,
75.Xr X509_NAME_add_entry_by_NID 3 ,
76.Xr X509_NAME_add_entry_by_txt 3 ,
77.Xr X509_NAME_ENTRY_get_object 3 ,
78.Xr X509_NAME_new 3 ,
79.Xr X509_NAME_print_ex 3