if_iwm - Recognize IWM_FW_PAGING_BLOCK_CMD wide cmd response correctly.
[dragonfly.git] / lib / libssl / man / SSL_CTX_set_verify.3
1 .\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28)
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sp \" Vertical space (when we can't use .PP)
6 .if t .sp .5v
7 .if n .sp
8 ..
9 .de Vb \" Begin verbatim text
10 .ft CW
11 .nf
12 .ne \\$1
13 ..
14 .de Ve \" End verbatim text
15 .ft R
16 .fi
17 ..
18 .\" Set up some character translations and predefined strings.  \*(-- will
19 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
20 .\" double quote, and \*(R" will give a right double quote.  \*(C+ will
21 .\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
22 .\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
23 .\" nothing in troff, for use with C<>.
24 .tr \(*W-
25 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
26 .ie n \{\
27 .    ds -- \(*W-
28 .    ds PI pi
29 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
30 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
31 .    ds L" ""
32 .    ds R" ""
33 .    ds C` ""
34 .    ds C' ""
35 'br\}
36 .el\{\
37 .    ds -- \|\(em\|
38 .    ds PI \(*p
39 .    ds L" ``
40 .    ds R" ''
41 .    ds C`
42 .    ds C'
43 'br\}
44 .\"
45 .\" Escape single quotes in literal strings from groff's Unicode transform.
46 .ie \n(.g .ds Aq \(aq
47 .el       .ds Aq '
48 .\"
49 .\" If the F register is turned on, we'll generate index entries on stderr for
50 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
51 .\" entries marked with X<> in POD.  Of course, you'll have to process the
52 .\" output yourself in some meaningful fashion.
53 .\"
54 .\" Avoid warning from groff about undefined register 'F'.
55 .de IX
56 ..
57 .nr rF 0
58 .if \n(.g .if rF .nr rF 1
59 .if (\n(rF:(\n(.g==0)) \{
60 .    if \nF \{
61 .        de IX
62 .        tm Index:\\$1\t\\n%\t"\\$2"
63 ..
64 .        if !\nF==2 \{
65 .            nr % 0
66 .            nr F 2
67 .        \}
68 .    \}
69 .\}
70 .rr rF
71 .\"
72 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
73 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
74 .    \" fudge factors for nroff and troff
75 .if n \{\
76 .    ds #H 0
77 .    ds #V .8m
78 .    ds #F .3m
79 .    ds #[ \f1
80 .    ds #] \fP
81 .\}
82 .if t \{\
83 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
84 .    ds #V .6m
85 .    ds #F 0
86 .    ds #[ \&
87 .    ds #] \&
88 .\}
89 .    \" simple accents for nroff and troff
90 .if n \{\
91 .    ds ' \&
92 .    ds ` \&
93 .    ds ^ \&
94 .    ds , \&
95 .    ds ~ ~
96 .    ds /
97 .\}
98 .if t \{\
99 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
100 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
101 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
102 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
103 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
104 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
105 .\}
106 .    \" troff and (daisy-wheel) nroff accents
107 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
108 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
109 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
110 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
111 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
112 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
113 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
114 .ds ae a\h'-(\w'a'u*4/10)'e
115 .ds Ae A\h'-(\w'A'u*4/10)'E
116 .    \" corrections for vroff
117 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
118 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
119 .    \" for low resolution devices (crt and lpr)
120 .if \n(.H>23 .if \n(.V>19 \
121 \{\
122 .    ds : e
123 .    ds 8 ss
124 .    ds o a
125 .    ds d- d\h'-1'\(ga
126 .    ds D- D\h'-1'\(hy
127 .    ds th \o'bp'
128 .    ds Th \o'LP'
129 .    ds ae ae
130 .    ds Ae AE
131 .\}
132 .rm #[ #] #H #V #F C
133 .\" ========================================================================
134 .\"
135 .IX Title "SSL_CTX_set_verify 3"
136 .TH SSL_CTX_set_verify 3 "2016-05-03" "1.0.2h" "OpenSSL"
137 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
138 .\" way too many mistakes in technical documents.
139 .if n .ad l
140 .nh
141 .SH "NAME"
142 SSL_CTX_set_verify, SSL_set_verify, SSL_CTX_set_verify_depth, SSL_set_verify_depth \- set peer certificate verification parameters
143 .SH "SYNOPSIS"
144 .IX Header "SYNOPSIS"
145 .Vb 1
146 \& #include <openssl/ssl.h>
147 \&
148 \& void SSL_CTX_set_verify(SSL_CTX *ctx, int mode,
149 \&                         int (*verify_callback)(int, X509_STORE_CTX *));
150 \& void SSL_set_verify(SSL *s, int mode,
151 \&                     int (*verify_callback)(int, X509_STORE_CTX *));
152 \& void SSL_CTX_set_verify_depth(SSL_CTX *ctx,int depth);
153 \& void SSL_set_verify_depth(SSL *s, int depth);
154 \&
155 \& int verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx);
156 .Ve
157 .SH "DESCRIPTION"
158 .IX Header "DESCRIPTION"
159 \&\fISSL_CTX_set_verify()\fR sets the verification flags for \fBctx\fR to be \fBmode\fR and
160 specifies the \fBverify_callback\fR function to be used. If no callback function
161 shall be specified, the \s-1NULL\s0 pointer can be used for \fBverify_callback\fR.
162 .PP
163 \&\fISSL_set_verify()\fR sets the verification flags for \fBssl\fR to be \fBmode\fR and
164 specifies the \fBverify_callback\fR function to be used. If no callback function
165 shall be specified, the \s-1NULL\s0 pointer can be used for \fBverify_callback\fR. In
166 this case last \fBverify_callback\fR set specifically for this \fBssl\fR remains. If
167 no special \fBcallback\fR was set before, the default callback for the underlying
168 \&\fBctx\fR is used, that was valid at the time \fBssl\fR was created with
169 \&\fISSL_new\fR\|(3).
170 .PP
171 \&\fISSL_CTX_set_verify_depth()\fR sets the maximum \fBdepth\fR for the certificate chain
172 verification that shall be allowed for \fBctx\fR. (See the \s-1BUGS\s0 section.)
173 .PP
174 \&\fISSL_set_verify_depth()\fR sets the maximum \fBdepth\fR for the certificate chain
175 verification that shall be allowed for \fBssl\fR. (See the \s-1BUGS\s0 section.)
176 .SH "NOTES"
177 .IX Header "NOTES"
178 The verification of certificates can be controlled by a set of logically
179 or'ed \fBmode\fR flags:
180 .IP "\s-1SSL_VERIFY_NONE\s0" 4
181 .IX Item "SSL_VERIFY_NONE"
182 \&\fBServer mode:\fR the server will not send a client certificate request to the
183 client, so the client will not send a certificate.
184 .Sp
185 \&\fBClient mode:\fR if not using an anonymous cipher (by default disabled), the
186 server will send a certificate which will be checked. The result of the
187 certificate verification process can be checked after the \s-1TLS/SSL\s0 handshake
188 using the \fISSL_get_verify_result\fR\|(3) function.
189 The handshake will be continued regardless of the verification result.
190 .IP "\s-1SSL_VERIFY_PEER\s0" 4
191 .IX Item "SSL_VERIFY_PEER"
192 \&\fBServer mode:\fR the server sends a client certificate request to the client.
193 The certificate returned (if any) is checked. If the verification process
194 fails, the \s-1TLS/SSL\s0 handshake is
195 immediately terminated with an alert message containing the reason for
196 the verification failure.
197 The behaviour can be controlled by the additional
198 \&\s-1SSL_VERIFY_FAIL_IF_NO_PEER_CERT\s0 and \s-1SSL_VERIFY_CLIENT_ONCE\s0 flags.
199 .Sp
200 \&\fBClient mode:\fR the server certificate is verified. If the verification process
201 fails, the \s-1TLS/SSL\s0 handshake is
202 immediately terminated with an alert message containing the reason for
203 the verification failure. If no server certificate is sent, because an
204 anonymous cipher is used, \s-1SSL_VERIFY_PEER\s0 is ignored.
205 .IP "\s-1SSL_VERIFY_FAIL_IF_NO_PEER_CERT\s0" 4
206 .IX Item "SSL_VERIFY_FAIL_IF_NO_PEER_CERT"
207 \&\fBServer mode:\fR if the client did not return a certificate, the \s-1TLS/SSL\s0
208 handshake is immediately terminated with a \*(L"handshake failure\*(R" alert.
209 This flag must be used together with \s-1SSL_VERIFY_PEER.\s0
210 .Sp
211 \&\fBClient mode:\fR ignored
212 .IP "\s-1SSL_VERIFY_CLIENT_ONCE\s0" 4
213 .IX Item "SSL_VERIFY_CLIENT_ONCE"
214 \&\fBServer mode:\fR only request a client certificate on the initial \s-1TLS/SSL\s0
215 handshake. Do not ask for a client certificate again in case of a
216 renegotiation. This flag must be used together with \s-1SSL_VERIFY_PEER.\s0
217 .Sp
218 \&\fBClient mode:\fR ignored
219 .PP
220 Exactly one of the \fBmode\fR flags \s-1SSL_VERIFY_NONE\s0 and \s-1SSL_VERIFY_PEER\s0 must be
221 set at any time.
222 .PP
223 The actual verification procedure is performed either using the built-in
224 verification procedure or using another application provided verification
225 function set with
226 \&\fISSL_CTX_set_cert_verify_callback\fR\|(3).
227 The following descriptions apply in the case of the built-in procedure. An
228 application provided procedure also has access to the verify depth information
229 and the \fIverify_callback()\fR function, but the way this information is used
230 may be different.
231 .PP
232 \&\fISSL_CTX_set_verify_depth()\fR and \fISSL_set_verify_depth()\fR set the limit up
233 to which depth certificates in a chain are used during the verification
234 procedure. If the certificate chain is longer than allowed, the certificates
235 above the limit are ignored. Error messages are generated as if these
236 certificates would not be present, most likely a
237 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY will be issued.
238 The depth count is \*(L"level 0:peer certificate\*(R", \*(L"level 1: \s-1CA\s0 certificate\*(R",
239 \&\*(L"level 2: higher level \s-1CA\s0 certificate\*(R", and so on. Setting the maximum
240 depth to 2 allows the levels 0, 1, and 2. The default depth limit is 100,
241 allowing for the peer certificate and additional 100 \s-1CA\s0 certificates.
242 .PP
243 The \fBverify_callback\fR function is used to control the behaviour when the
244 \&\s-1SSL_VERIFY_PEER\s0 flag is set. It must be supplied by the application and
245 receives two arguments: \fBpreverify_ok\fR indicates, whether the verification of
246 the certificate in question was passed (preverify_ok=1) or not
247 (preverify_ok=0). \fBx509_ctx\fR is a pointer to the complete context used
248 for the certificate chain verification.
249 .PP
250 The certificate chain is checked starting with the deepest nesting level
251 (the root \s-1CA\s0 certificate) and worked upward to the peer's certificate.
252 At each level signatures and issuer attributes are checked. Whenever
253 a verification error is found, the error number is stored in \fBx509_ctx\fR
254 and \fBverify_callback\fR is called with \fBpreverify_ok\fR=0. By applying
255 X509_CTX_store_* functions \fBverify_callback\fR can locate the certificate
256 in question and perform additional steps (see \s-1EXAMPLES\s0). If no error is
257 found for a certificate, \fBverify_callback\fR is called with \fBpreverify_ok\fR=1
258 before advancing to the next level.
259 .PP
260 The return value of \fBverify_callback\fR controls the strategy of the further
261 verification process. If \fBverify_callback\fR returns 0, the verification
262 process is immediately stopped with \*(L"verification failed\*(R" state. If
263 \&\s-1SSL_VERIFY_PEER\s0 is set, a verification failure alert is sent to the peer and
264 the \s-1TLS/SSL\s0 handshake is terminated. If \fBverify_callback\fR returns 1,
265 the verification process is continued. If \fBverify_callback\fR always returns
266 1, the \s-1TLS/SSL\s0 handshake will not be terminated with respect to verification
267 failures and the connection will be established. The calling process can
268 however retrieve the error code of the last verification error using
269 \&\fISSL_get_verify_result\fR\|(3) or by maintaining its
270 own error storage managed by \fBverify_callback\fR.
271 .PP
272 If no \fBverify_callback\fR is specified, the default callback will be used.
273 Its return value is identical to \fBpreverify_ok\fR, so that any verification
274 failure will lead to a termination of the \s-1TLS/SSL\s0 handshake with an
275 alert message, if \s-1SSL_VERIFY_PEER\s0 is set.
276 .SH "BUGS"
277 .IX Header "BUGS"
278 In client mode, it is not checked whether the \s-1SSL_VERIFY_PEER\s0 flag
279 is set, but whether \s-1SSL_VERIFY_NONE\s0 is not set. This can lead to
280 unexpected behaviour, if the \s-1SSL_VERIFY_PEER\s0 and \s-1SSL_VERIFY_NONE\s0 are not
281 used as required (exactly one must be set at any time).
282 .PP
283 The certificate verification depth set with SSL[_CTX]\fI_verify_depth()\fR
284 stops the verification at a certain depth. The error message produced
285 will be that of an incomplete certificate chain and not
286 X509_V_ERR_CERT_CHAIN_TOO_LONG as may be expected.
287 .SH "RETURN VALUES"
288 .IX Header "RETURN VALUES"
289 The SSL*_set_verify*() functions do not provide diagnostic information.
290 .SH "EXAMPLES"
291 .IX Header "EXAMPLES"
292 The following code sequence realizes an example \fBverify_callback\fR function
293 that will always continue the \s-1TLS/SSL\s0 handshake regardless of verification
294 failure, if wished. The callback realizes a verification depth limit with
295 more informational output.
296 .PP
297 All verification errors are printed; information about the certificate chain
298 is printed on request.
299 The example is realized for a server that does allow but not require client
300 certificates.
301 .PP
302 The example makes use of the ex_data technique to store application data
303 into/retrieve application data from the \s-1SSL\s0 structure
304 (see \fISSL_get_ex_new_index\fR\|(3),
305 \&\fISSL_get_ex_data_X509_STORE_CTX_idx\fR\|(3)).
306 .PP
307 .Vb 10
308 \& ...
309 \& typedef struct {
310 \&   int verbose_mode;
311 \&   int verify_depth;
312 \&   int always_continue;
313 \& } mydata_t;
314 \& int mydata_index;
315 \& ...
316 \& static int verify_callback(int preverify_ok, X509_STORE_CTX *ctx)
317 \& {
318 \&    char    buf[256];
319 \&    X509   *err_cert;
320 \&    int     err, depth;
321 \&    SSL    *ssl;
322 \&    mydata_t *mydata;
323 \&
324 \&    err_cert = X509_STORE_CTX_get_current_cert(ctx);
325 \&    err = X509_STORE_CTX_get_error(ctx);
326 \&    depth = X509_STORE_CTX_get_error_depth(ctx);
327 \&
328 \&    /*
329 \&     * Retrieve the pointer to the SSL of the connection currently treated
330 \&     * and the application specific data stored into the SSL object.
331 \&     */
332 \&    ssl = X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx());
333 \&    mydata = SSL_get_ex_data(ssl, mydata_index);
334 \&
335 \&    X509_NAME_oneline(X509_get_subject_name(err_cert), buf, 256);
336 \&
337 \&    /*
338 \&     * Catch a too long certificate chain. The depth limit set using
339 \&     * SSL_CTX_set_verify_depth() is by purpose set to "limit+1" so
340 \&     * that whenever the "depth>verify_depth" condition is met, we
341 \&     * have violated the limit and want to log this error condition.
342 \&     * We must do it here, because the CHAIN_TOO_LONG error would not
343 \&     * be found explicitly; only errors introduced by cutting off the
344 \&     * additional certificates would be logged.
345 \&     */
346 \&    if (depth > mydata\->verify_depth) {
347 \&        preverify_ok = 0;
348 \&        err = X509_V_ERR_CERT_CHAIN_TOO_LONG;
349 \&        X509_STORE_CTX_set_error(ctx, err);
350 \&    } 
351 \&    if (!preverify_ok) {
352 \&        printf("verify error:num=%d:%s:depth=%d:%s\en", err,
353 \&                 X509_verify_cert_error_string(err), depth, buf);
354 \&    }
355 \&    else if (mydata\->verbose_mode)
356 \&    {
357 \&        printf("depth=%d:%s\en", depth, buf);
358 \&    }
359 \&
360 \&    /*
361 \&     * At this point, err contains the last verification error. We can use
362 \&     * it for something special
363 \&     */
364 \&    if (!preverify_ok && (err == X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT))
365 \&    {
366 \&      X509_NAME_oneline(X509_get_issuer_name(ctx\->current_cert), buf, 256);
367 \&      printf("issuer= %s\en", buf);
368 \&    }
369 \&
370 \&    if (mydata\->always_continue)
371 \&      return 1;
372 \&    else
373 \&      return preverify_ok;
374 \& }
375 \& ...
376 \&
377 \& mydata_t mydata;
378 \&
379 \& ...
380 \& mydata_index = SSL_get_ex_new_index(0, "mydata index", NULL, NULL, NULL);
381 \&
382 \& ...
383 \& SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
384 \&                    verify_callback);
385 \&
386 \& /*
387 \&  * Let the verify_callback catch the verify_depth error so that we get
388 \&  * an appropriate error in the logfile.
389 \&  */
390 \& SSL_CTX_set_verify_depth(verify_depth + 1);
391 \&
392 \& /*
393 \&  * Set up the SSL specific data into "mydata" and store it into th SSL
394 \&  * structure.
395 \&  */
396 \& mydata.verify_depth = verify_depth; ...
397 \& SSL_set_ex_data(ssl, mydata_index, &mydata);
398 \&                                             
399 \& ...
400 \& SSL_accept(ssl);       /* check of success left out for clarity */
401 \& if (peer = SSL_get_peer_certificate(ssl))
402 \& {
403 \&   if (SSL_get_verify_result(ssl) == X509_V_OK)
404 \&   {
405 \&     /* The client sent a certificate which verified OK */
406 \&   }
407 \& }
408 .Ve
409 .SH "SEE ALSO"
410 .IX Header "SEE ALSO"
411 \&\fIssl\fR\|(3), \fISSL_new\fR\|(3),
412 \&\fISSL_CTX_get_verify_mode\fR\|(3),
413 \&\fISSL_get_verify_result\fR\|(3),
414 \&\fISSL_CTX_load_verify_locations\fR\|(3),
415 \&\fISSL_get_peer_certificate\fR\|(3),
416 \&\fISSL_CTX_set_cert_verify_callback\fR\|(3),
417 \&\fISSL_get_ex_data_X509_STORE_CTX_idx\fR\|(3),
418 \&\fISSL_get_ex_new_index\fR\|(3)