summaryrefslogtreecommitdiff
path: root/lib/libcrypto/man/X509_VERIFY_PARAM_set_flags.3
blob: b459e758632d9cfe0e31ba0fb879a823fe65642b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
.\" $OpenBSD: X509_VERIFY_PARAM_set_flags.3,v 1.6 2018/02/11 03:33:21 schwarze Exp $
.\" full merge up to: OpenSSL d33def66 Feb 9 14:17:13 2016 -0500
.\" selective merge up to: OpenSSL 48e5119a Jan 19 10:49:22 2018 +0100
.\"
.\" This file was written by Dr. Stephen Henson <steve@openssl.org>
.\" and Viktor Dukhovni <viktor@dukhovni.org>.
.\" Copyright (c) 2009, 2013, 2014, 2015, 2016, 2017 The OpenSSL Project.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\"
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\"
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in
.\"    the documentation and/or other materials provided with the
.\"    distribution.
.\"
.\" 3. All advertising materials mentioning features or use of this
.\"    software must display the following acknowledgment:
.\"    "This product includes software developed by the OpenSSL Project
.\"    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
.\"
.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
.\"    endorse or promote products derived from this software without
.\"    prior written permission. For written permission, please contact
.\"    openssl-core@openssl.org.
.\"
.\" 5. Products derived from this software may not be called "OpenSSL"
.\"    nor may "OpenSSL" appear in their names without prior written
.\"    permission of the OpenSSL Project.
.\"
.\" 6. Redistributions of any form whatsoever must retain the following
.\"    acknowledgment:
.\"    "This product includes software developed by the OpenSSL Project
.\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
.\" OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd $Mdocdate: February 11 2018 $
.Dt X509_VERIFY_PARAM_SET_FLAGS 3
.Os
.Sh NAME
.Nm X509_VERIFY_PARAM_set_flags ,
.Nm X509_VERIFY_PARAM_clear_flags ,
.Nm X509_VERIFY_PARAM_get_flags ,
.Nm X509_VERIFY_PARAM_set_purpose ,
.Nm X509_VERIFY_PARAM_set_trust ,
.Nm X509_VERIFY_PARAM_set_time ,
.Nm X509_VERIFY_PARAM_add0_policy ,
.Nm X509_VERIFY_PARAM_set1_policies ,
.Nm X509_VERIFY_PARAM_set_depth ,
.Nm X509_VERIFY_PARAM_get_depth ,
.Nm X509_VERIFY_PARAM_set1_host ,
.Nm X509_VERIFY_PARAM_add1_host ,
.Nm X509_VERIFY_PARAM_set_hostflags ,
.Nm X509_VERIFY_PARAM_get0_peername ,
.Nm X509_VERIFY_PARAM_set1_email ,
.Nm X509_VERIFY_PARAM_set1_ip ,
.Nm X509_VERIFY_PARAM_set1_ip_asc
.Nd X509 verification parameters
.Sh SYNOPSIS
.In openssl/x509_vfy.h
.Ft int
.Fo X509_VERIFY_PARAM_set_flags
.Fa "X509_VERIFY_PARAM *param"
.Fa "unsigned long flags"
.Fc
.Ft int
.Fo X509_VERIFY_PARAM_clear_flags
.Fa "X509_VERIFY_PARAM *param"
.Fa "unsigned long flags"
.Fc
.Ft unsigned long
.Fo X509_VERIFY_PARAM_get_flags
.Fa "X509_VERIFY_PARAM *param"
.Fc
.Ft int
.Fo X509_VERIFY_PARAM_set_purpose
.Fa "X509_VERIFY_PARAM *param"
.Fa "int purpose"
.Fc
.Ft int
.Fo X509_VERIFY_PARAM_set_trust
.Fa "X509_VERIFY_PARAM *param"
.Fa "int trust"
.Fc
.Ft void
.Fo X509_VERIFY_PARAM_set_time
.Fa "X509_VERIFY_PARAM *param"
.Fa "time_t t"
.Fc
.Ft int
.Fo X509_VERIFY_PARAM_add0_policy
.Fa "X509_VERIFY_PARAM *param"
.Fa "ASN1_OBJECT *policy"
.Fc
.Ft int
.Fo X509_VERIFY_PARAM_set1_policies
.Fa "X509_VERIFY_PARAM *param"
.Fa "STACK_OF(ASN1_OBJECT) *policies"
.Fc
.Ft void
.Fo X509_VERIFY_PARAM_set_depth
.Fa "X509_VERIFY_PARAM *param"
.Fa "int depth"
.Fc
.Ft int
.Fo X509_VERIFY_PARAM_get_depth
.Fa "const X509_VERIFY_PARAM *param"
.Fc
.Ft int
.Fo X509_VERIFY_PARAM_set1_host
.Fa "X509_VERIFY_PARAM *param"
.Fa "const char *name"
.Fa "size_t namelen"
.Fc
.Ft int
.Fo X509_VERIFY_PARAM_add1_host
.Fa "X509_VERIFY_PARAM *param"
.Fa "const char *name"
.Fa "size_t namelen"
.Fc
.Ft void
.Fo X509_VERIFY_PARAM_set_hostflags
.Fa "X509_VERIFY_PARAM *param"
.Fa "unsigned int flags"
.Fc
.Ft char *
.Fo X509_VERIFY_PARAM_get0_peername
.Fa "X509_VERIFY_PARAM *param"
.Fc
.Ft int
.Fo X509_VERIFY_PARAM_set1_email
.Fa "X509_VERIFY_PARAM *param"
.Fa "const char *email"
.Fa "size_t emaillen"
.Fc
.Ft int
.Fo X509_VERIFY_PARAM_set1_ip
.Fa "X509_VERIFY_PARAM *param"
.Fa "const unsigned char *ip"
.Fa "size_t iplen"
.Fc
.Ft int
.Fo X509_VERIFY_PARAM_set1_ip_asc
.Fa "X509_VERIFY_PARAM *param"
.Fa "const char *ipasc"
.Fc
.Sh DESCRIPTION
These functions manipulate the
.Vt X509_VERIFY_PARAM
structure associated with a certificate verification operation.
.Pp
The
.Fn X509_VERIFY_PARAM_set_flags
function sets the flags in
.Fa param
by OR'ing it with
.Fa flags .
See the
.Sx VERIFICATION FLAGS
section for a complete description of values the
.Fa flags
parameter can take.
.Pp
.Fn X509_VERIFY_PARAM_get_flags
returns the flags in
.Fa param .
.Pp
.Fn X509_VERIFY_PARAM_clear_flags
clears the flags
.Fa flags
in
.Fa param .
.Pp
.Fn X509_VERIFY_PARAM_set_purpose
sets the verification purpose in
.Fa param
to
.Fa purpose .
This determines the acceptable purpose of the certificate chain, for
example SSL client or SSL server.
.Pp
.Fn X509_VERIFY_PARAM_set_trust
sets the trust setting in
.Fa param
to
.Fa trust .
.Pp
.Fn X509_VERIFY_PARAM_set_time
sets the verification time in
.Fa param
to
.Fa t .
Normally the current time is used.
.Pp
.Fn X509_VERIFY_PARAM_add0_policy
enables policy checking (it is disabled by default) and adds
.Fa policy
to the acceptable policy set.
.Pp
.Fn X509_VERIFY_PARAM_set1_policies
enables policy checking (it is disabled by default) and sets the
acceptable policy set to
.Fa policies .
Any existing policy set is cleared.
The
.Fa policies
parameter can be
.Dv NULL
to clear an existing policy set.
.Pp
.Fn X509_VERIFY_PARAM_set_depth
sets the maximum verification depth to
.Fa depth .
That is the maximum number of untrusted CA certificates that can appear
in a chain.
.Pp
.Fn X509_VERIFY_PARAM_set1_host
sets the expected DNS hostname to
.Fa name
clearing any previously specified host name or names.
If
.Fa name
is
.Dv NULL
or empty, the list of hostnames is cleared, and name checks are not
performed on the peer certificate.
If
.Fa name
is NUL-terminated,
.Fa namelen
may be zero, otherwise
.Fa namelen
must be set to the length of
.Fa name .
When a hostname is specified, certificate verification automatically
invokes
.Xr X509_check_host 3
with flags equal to the
.Fa flags
argument given to
.Fn X509_VERIFY_PARAM_set_hostflags
(default zero).
.Pp
.Fn X509_VERIFY_PARAM_add1_host
adds
.Fa name
as an additional reference identifier that can match the peer's
certificate.
Any previous names set via
.Fn X509_VERIFY_PARAM_set1_host
and
.Fn X509_VERIFY_PARAM_add1_host
are retained.
No change is made if
.Fa name
is
.Dv NULL
or empty.
When multiple names are configured, the peer is considered verified when
any name matches.
.Pp
.Fn X509_VERIFY_PARAM_get0_peername
returns the DNS hostname or subject CommonName from the peer certificate
that matched one of the reference identifiers.
When wildcard matching is not disabled, or when a reference identifier
specifies a parent domain (starts with ".") rather than a hostname, the
peer name may be a wildcard name or a sub-domain of the reference
identifier respectively.
The return string is allocated by the library and is no longer valid
once the associated
.Fa param
argument is freed.
Applications must not free the return value.
.Pp
.Fn X509_VERIFY_PARAM_set1_email
sets the expected RFC822 email address to
.Fa email .
If
.Fa email
is NUL-terminated,
.Fa emaillen
may be zero, otherwise
.Fa emaillen
must be set to the length of
.Fa email .
When an email address is specified, certificate verification
automatically invokes
.Xr X509_check_email 3 .
.Pp
.Fn X509_VERIFY_PARAM_set1_ip
sets the expected IP address to
.Fa ip .
The
.Fa ip
argument is in binary format, in network byte-order, and
.Fa iplen
must be set to 4 for IPv4 and 16 for IPv6.
When an IP address is specified,
certificate verification automatically invokes
.Xr X509_check_ip 3 .
.Pp
.Fn X509_VERIFY_PARAM_set1_ip_asc
sets the expected IP address to
.Fa ipasc .
The
.Fa ipasc
argument is a NUL-terminal ASCII string:
dotted decimal quad for IPv4 and colon-separated hexadecimal for IPv6.
The condensed "::" notation is supported for IPv6 addresses.
.Sh RETURN VALUES
.Fn X509_VERIFY_PARAM_set_flags ,
.Fn X509_VERIFY_PARAM_clear_flags ,
.Fn X509_VERIFY_PARAM_set_purpose ,
.Fn X509_VERIFY_PARAM_set_trust ,
.Fn X509_VERIFY_PARAM_add0_policy ,
.Fn X509_VERIFY_PARAM_set1_policies ,
.Fn X509_VERIFY_PARAM_set1_host ,
.Fn X509_VERIFY_PARAM_add1_host ,
.Fn X509_VERIFY_PARAM_set1_email ,
.Fn X509_VERIFY_PARAM_set1_ip ,
and
.Fn X509_VERIFY_PARAM_set1_ip_asc
return 1 for success or 0 for failure.
.Pp
.Fn X509_VERIFY_PARAM_get_flags
returns the current verification flags.
.Pp
.Fn X509_VERIFY_PARAM_set_time
and
.Fn X509_VERIFY_PARAM_set_depth
do not return values.
.Pp
.Fn X509_VERIFY_PARAM_get_depth
returns the current verification depth.
.Sh VERIFICATION FLAGS
The verification flags consists of zero or more of the following
flags OR'ed together.
.Pp
.Dv X509_V_FLAG_CRL_CHECK
enables CRL checking for the certificate chain leaf certificate.
An error occurs if a suitable CRL cannot be found.
.Pp
.Dv X509_V_FLAG_CRL_CHECK_ALL
enables CRL checking for the entire certificate chain.
.Pp
.Dv X509_V_FLAG_IGNORE_CRITICAL
disables critical extension checking.
By default any unhandled critical extensions in certificates or (if
checked) CRLs results in a fatal error.
If this flag is set unhandled critical extensions are ignored.
.Sy WARNING :
setting this option for anything other than debugging purposes can be a
security risk.
Finer control over which extensions are supported can be performed in
the verification callback.
.Pp
The
.Dv X509_V_FLAG_X509_STRICT
flag disables workarounds for some broken certificates and makes the
verification strictly apply X509 rules.
.Pp
.Dv X509_V_FLAG_ALLOW_PROXY_CERTS
enables proxy certificate verification.
.Pp
.Dv X509_V_FLAG_POLICY_CHECK
enables certificate policy checking; by default no policy checking is
performed.
Additional information is sent to the verification callback relating to
policy checking.
.Pp
.Dv X509_V_FLAG_EXPLICIT_POLICY ,
.Dv X509_V_FLAG_INHIBIT_ANY ,
and
.Dv X509_V_FLAG_INHIBIT_MAP
set the
.Dq require explicit policy ,
.Dq inhibit any policy ,
and
.Dq inhibit policy mapping
flags, respectively, as defined in RFC 3280.
Policy checking is automatically enabled if any of these flags are set.
.Pp
If
.Dv X509_V_FLAG_NOTIFY_POLICY
is set and the policy checking is successful a special status code is
set to the verification callback.
This permits it to examine the valid policy tree and perform additional
checks or simply log it for debugging purposes.
.Pp
By default some additional features such as indirect CRLs and CRLs
signed by different keys are disabled.
If
.Dv X509_V_FLAG_EXTENDED_CRL_SUPPORT
is set they are enabled.
.Pp
If
.Dv X509_V_FLAG_USE_DELTAS
is set, delta CRLs (if present) are used to determine certificate
status.
If not set, deltas are ignored.
.Pp
.Dv X509_V_FLAG_CHECK_SS_SIGNATURE
enables checking of the root CA self signed certificate signature.
By default this check is disabled because it doesn't add any additional
security but in some cases applications might want to check the
signature anyway.
A side effect of not checking the root CA signature is that disabled or
unsupported message digests on the root CA are not treated as fatal
errors.
.Pp
The
.Dv X509_V_FLAG_CB_ISSUER_CHECK
flag enables debugging of certificate issuer checks.
It is
.Sy not
needed unless you are logging certificate verification.
If this flag is set then additional status codes will be sent to the
verification callback and it
.Sy must
be prepared to handle such cases without assuming they are hard errors.
.Pp
When
.Dv X509_V_FLAG_TRUSTED_FIRST
is set, construction of the certificate chain in
.Xr X509_verify_cert 3
will search the trust store for issuer certificates before searching the
provided untrusted certificates.
Local issuer certificates are often more likely to satisfy local
security requirements and lead to a locally trusted root.
This is especially important when some certificates in the trust store
have explicit trust settings; see the trust settings options of the
.Cm x509
command in
.Xr openssl 1 .
.Pp
The
.Dv X509_V_FLAG_NO_ALT_CHAINS
flag suppresses checking for alternative chains.
By default, unless
.Dv X509_V_FLAG_TRUSTED_FIRST
is set, when building a certificate chain, if the first certificate
chain found is not trusted, then OpenSSL will attempt to replace
untrusted certificates supplied by the peer with certificates from the
trust store to see if an alternative chain can be found that is trusted.
.Pp
The
.Dv X509_V_FLAG_PARTIAL_CHAIN
flag causes intermediate certificates in the trust store to be treated
as trust-anchors, in the same way as the self-signed root CA
certificates.
This makes it possible to trust certificates issued by an intermediate
CA without having to trust its ancestor root CA.
.Pp
The
.Dv X509_V_FLAG_NO_CHECK_TIME
flag suppresses checking the validity period of certificates and CRLs
against the current time.
If
.Fn X509_VERIFY_PARAM_set_time
is used to specify a verification time, the check is not suppressed.
.Sh EXAMPLES
Enable CRL checking when performing certificate verification during
SSL connections associated with an
.Vt SSL_CTX
structure
.Fa ctx :
.Bd -literal -offset indent
X509_VERIFY_PARAM *param;

param = X509_VERIFY_PARAM_new();
X509_VERIFY_PARAM_set_flags(param, X509_V_FLAG_CRL_CHECK);
SSL_CTX_set1_param(ctx, param);
X509_VERIFY_PARAM_free(param);
.Ed
.Sh SEE ALSO
.Xr X509_check_host 3 ,
.Xr X509_verify_cert 3
.Sh BUGS
Delta CRL checking is currently primitive.
Only a single delta can be used and (partly due to limitations of
.Vt X509_STORE )
constructed CRLs are not maintained.
.Pp
If CRLs checking is enabled, CRLs are expected to be available in
the corresponding
.Vt X509_STORE
structure.
No attempt is made to download CRLs from the CRL distribution points
extension.