openssl-verification-options.pod revision 1.1 1 1.1 christos =pod
2 1.1 christos
3 1.1 christos =head1 NAME
4 1.1 christos
5 1.1 christos openssl-verification-options - generic X.509 certificate verification options
6 1.1 christos
7 1.1 christos =head1 SYNOPSIS
8 1.1 christos
9 1.1 christos B<openssl>
10 1.1 christos I<command>
11 1.1 christos [ I<options> ... ]
12 1.1 christos [ I<parameters> ... ]
13 1.1 christos
14 1.1 christos =head1 DESCRIPTION
15 1.1 christos
16 1.1 christos There are many situations where X.509 certificates are verified
17 1.1 christos within the OpenSSL libraries and in various OpenSSL commands.
18 1.1 christos
19 1.1 christos Certificate verification is implemented by L<X509_verify_cert(3)>.
20 1.1 christos It is a complicated process consisting of a number of steps
21 1.1 christos and depending on numerous options.
22 1.1 christos The most important of them are detailed in the following sections.
23 1.1 christos
24 1.1 christos In a nutshell, a valid chain of certificates needs to be built up and verified
25 1.1 christos starting from the I<target certificate> that is to be verified
26 1.1 christos and ending in a certificate that due to some policy is trusted.
27 1.1 christos Certificate validation can be performed in the context of a I<purpose>, which
28 1.1 christos is a high-level specification of the intended use of the target certificate,
29 1.1 christos such as C<sslserver> for TLS servers, or (by default) for any purpose.
30 1.1 christos
31 1.1 christos The details of how each OpenSSL command handles errors
32 1.1 christos are documented on the specific command page.
33 1.1 christos
34 1.1 christos DANE support is documented in L<openssl-s_client(1)>,
35 1.1 christos L<SSL_CTX_dane_enable(3)>, L<SSL_set1_host(3)>,
36 1.1 christos L<X509_VERIFY_PARAM_set_flags(3)>, and L<X509_check_host(3)>.
37 1.1 christos
38 1.1 christos =head2 Trust Anchors
39 1.1 christos
40 1.1 christos In general, according to RFC 4158 and RFC 5280, a I<trust anchor> is
41 1.1 christos any public key and related subject distinguished name (DN) that
42 1.1 christos for some reason is considered trusted
43 1.1 christos and thus is acceptable as the root of a chain of certificates.
44 1.1 christos
45 1.1 christos In practice, trust anchors are given in the form of certificates,
46 1.1 christos where their essential fields are the public key and the subject DN.
47 1.1 christos In addition to the requirements in RFC 5280,
48 1.1 christos OpenSSL checks the validity period of such certificates
49 1.1 christos and makes use of some further fields.
50 1.1 christos In particular, the subject key identifier extension, if present,
51 1.1 christos is used for matching trust anchors during chain building.
52 1.1 christos
53 1.1 christos In the most simple and common case, trust anchors are by default
54 1.1 christos all self-signed "root" CA certificates that are placed in the I<trust store>,
55 1.1 christos which is a collection of certificates that are trusted for certain uses.
56 1.1 christos This is akin to what is used in the trust stores of Mozilla Firefox,
57 1.1 christos or Apple's and Microsoft's certificate stores, ...
58 1.1 christos
59 1.1 christos From the OpenSSL perspective, a trust anchor is a certificate
60 1.1 christos that should be augmented with an explicit designation for which
61 1.1 christos uses of a target certificate the certificate may serve as a trust anchor.
62 1.1 christos In PEM encoding, this is indicated by the C<TRUSTED CERTIFICATE> string.
63 1.1 christos Such a designation provides a set of positive trust attributes
64 1.1 christos explicitly stating trust for the listed purposes
65 1.1 christos and/or a set of negative trust attributes
66 1.1 christos explicitly rejecting the use for the listed purposes.
67 1.1 christos The purposes are encoded using the values defined for the extended key usages
68 1.1 christos (EKUs) that may be given in X.509 extensions of end-entity certificates.
69 1.1 christos See also the L</Extended Key Usage> section below.
70 1.1 christos
71 1.1 christos The currently recognized uses are
72 1.1 christos B<clientAuth> (SSL client use), B<serverAuth> (SSL server use),
73 1.1 christos B<emailProtection> (S/MIME email use), B<codeSigning> (object signer use),
74 1.1 christos B<OCSPSigning> (OCSP responder use), B<OCSP> (OCSP request use),
75 1.1 christos B<timeStamping> (TSA server use), and B<anyExtendedKeyUsage>.
76 1.1 christos As of OpenSSL 1.1.0, the last of these blocks all uses when rejected or
77 1.1 christos enables all uses when trusted.
78 1.1 christos
79 1.1 christos A certificate, which may be CA certificate or an end-entity certificate,
80 1.1 christos is considered a trust anchor for the given use
81 1.1 christos if and only if all the following conditions hold:
82 1.1 christos
83 1.1 christos =over 4
84 1.1 christos
85 1.1 christos =item *
86 1.1 christos
87 1.1 christos It is an an element of the trust store.
88 1.1 christos
89 1.1 christos =item *
90 1.1 christos
91 1.1 christos It does not have a negative trust attribute rejecting the given use.
92 1.1 christos
93 1.1 christos =item *
94 1.1 christos
95 1.1 christos It has a positive trust attribute accepting the given use
96 1.1 christos or (by default) one of the following compatibility conditions apply:
97 1.1 christos It is self-signed or the B<-partial_chain> option is given
98 1.1 christos (which corresponds to the B<X509_V_FLAG_PARTIAL_CHAIN> flag being set).
99 1.1 christos
100 1.1 christos =back
101 1.1 christos
102 1.1 christos =head2 Certification Path Building
103 1.1 christos
104 1.1 christos First, a certificate chain is built up starting from the target certificate
105 1.1 christos and ending in a trust anchor.
106 1.1 christos
107 1.1 christos The chain is built up iteratively, looking up in turn
108 1.1 christos a certificate with suitable key usage that
109 1.1 christos matches as an issuer of the current "subject" certificate as described below.
110 1.1 christos If there is such a certificate, the first one found that is currently valid
111 1.1 christos is taken, otherwise the one that expired most recently of all such certificates.
112 1.1 christos For efficiency, no backtracking is performed, thus
113 1.1 christos any further candidate issuer certificates that would match equally are ignored.
114 1.1 christos
115 1.1 christos When a self-signed certificate has been added, chain construction stops.
116 1.1 christos In this case it must fully match a trust anchor, otherwise chain building fails.
117 1.1 christos
118 1.1 christos A candidate issuer certificate matches a subject certificate
119 1.1 christos if all of the following conditions hold:
120 1.1 christos
121 1.1 christos =over 4
122 1.1 christos
123 1.1 christos =item *
124 1.1 christos
125 1.1 christos Its subject name matches the issuer name of the subject certificate.
126 1.1 christos
127 1.1 christos =item *
128 1.1 christos
129 1.1 christos If the subject certificate has an authority key identifier extension,
130 1.1 christos each of its sub-fields equals the corresponding subject key identifier, serial
131 1.1 christos number, and issuer field of the candidate issuer certificate,
132 1.1 christos as far as the respective fields are present in both certificates.
133 1.1 christos
134 1.1 christos =item *
135 1.1 christos
136 1.1 christos The certificate signature algorithm used to sign the subject certificate
137 1.1 christos is supported and
138 1.1 christos equals the public key algorithm of the candidate issuer certificate.
139 1.1 christos
140 1.1 christos =back
141 1.1 christos
142 1.1 christos The lookup first searches for issuer certificates in the trust store.
143 1.1 christos If it does not find a match there it consults
144 1.1 christos the list of untrusted ("intermediate" CA) certificates, if provided.
145 1.1 christos
146 1.1 christos =head2 Certification Path Validation
147 1.1 christos
148 1.1 christos When the certificate chain building process was successful
149 1.1 christos the chain components and their links are checked thoroughly.
150 1.1 christos
151 1.1 christos The first step is to check that each certificate is well-formed.
152 1.1 christos Part of these checks are enabled only if the B<-x509_strict> option is given.
153 1.1 christos
154 1.1 christos The second step is to check the X.509v3 extensions of every certificate
155 1.1 christos for consistency with the intended specific purpose, if any.
156 1.1 christos If the B<-purpose> option is not given then no such checks are done except for
157 1.1 christos CMS signature checking, where by default C<smimesign> is checked, and SSL/(D)TLS
158 1.1 christos connection setup, where by default C<sslserver> or C<sslclient> are checked.
159 1.1 christos The X.509v3 extensions of the target or "leaf" certificate
160 1.1 christos must be compatible with the specified purpose.
161 1.1 christos All other certificates down the chain are checked to be valid CA certificates,
162 1.1 christos and possibly also further non-standard checks are performed.
163 1.1 christos The precise extensions required are described in detail
164 1.1 christos in the L</Certificate Extensions> section below.
165 1.1 christos
166 1.1 christos The third step is to check the trust settings on the last certificate
167 1.1 christos (which typically is a self-signed root CA certificate).
168 1.1 christos It must be trusted for the given use.
169 1.1 christos For compatibility with previous versions of OpenSSL, a self-signed certificate
170 1.1 christos with no trust attributes is considered to be valid for all uses.
171 1.1 christos
172 1.1 christos The fourth, and final, step is to check the validity of the certificate chain.
173 1.1 christos For each element in the chain, including the root CA certificate,
174 1.1 christos the validity period as specified by the C<notBefore> and C<notAfter> fields
175 1.1 christos is checked against the current system time.
176 1.1 christos The B<-attime> flag may be used to use a reference time other than "now."
177 1.1 christos The certificate signature is checked as well
178 1.1 christos (except for the signature of the typically self-signed root CA certificate,
179 1.1 christos which is verified only if the B<-check_ss_sig> option is given).
180 1.1 christos When verifying a certificate signature
181 1.1 christos the keyUsage extension (if present) of the candidate issuer certificate
182 1.1 christos is checked to permit digitalSignature for signing proxy certificates
183 1.1 christos or to permit keyCertSign for signing other certificates, respectively.
184 1.1 christos If all operations complete successfully then certificate is considered
185 1.1 christos valid. If any operation fails then the certificate is not valid.
186 1.1 christos
187 1.1 christos =head1 OPTIONS
188 1.1 christos
189 1.1 christos =head2 Trusted Certificate Options
190 1.1 christos
191 1.1 christos The following options specify how to supply the certificates
192 1.1 christos that can be used as trust anchors for certain uses.
193 1.1 christos As mentioned, a collection of such certificates is called a I<trust store>.
194 1.1 christos
195 1.1 christos Note that OpenSSL does not provide a default set of trust anchors. Many
196 1.1 christos Linux distributions include a system default and configure OpenSSL to point
197 1.1 christos to that. Mozilla maintains an influential trust store that can be found at
198 1.1 christos L<https://www.mozilla.org/en-US/about/governance/policies/security-group/certs/>.
199 1.1 christos
200 1.1 christos The certificates to add to the trust store
201 1.1 christos can be specified using following options.
202 1.1 christos
203 1.1 christos =over 4
204 1.1 christos
205 1.1 christos =item B<-CAfile> I<file>
206 1.1 christos
207 1.1 christos Load the specified file which contains a trusted certificate in DER format
208 1.1 christos or potentially several of them in case the input is in PEM format.
209 1.1 christos PEM-encoded certificates may also have trust attributes set.
210 1.1 christos
211 1.1 christos =item B<-no-CAfile>
212 1.1 christos
213 1.1 christos Do not load the default file of trusted certificates.
214 1.1 christos
215 1.1 christos =item B<-CApath> I<dir>
216 1.1 christos
217 1.1 christos Use the specified directory as a collection of trusted certificates,
218 1.1 christos i.e., a trust store.
219 1.1 christos Files should be named with the hash value of the X.509 SubjectName of each
220 1.1 christos certificate. This is so that the library can extract the IssuerName,
221 1.1 christos hash it, and directly lookup the file to get the issuer certificate.
222 1.1 christos See L<openssl-rehash(1)> for information on creating this type of directory.
223 1.1 christos
224 1.1 christos =item B<-no-CApath>
225 1.1 christos
226 1.1 christos Do not use the default directory of trusted certificates.
227 1.1 christos
228 1.1 christos =item B<-CAstore> I<uri>
229 1.1 christos
230 1.1 christos Use I<uri> as a store of CA certificates.
231 1.1 christos The URI may indicate a single certificate, as well as a collection of them.
232 1.1 christos With URIs in the C<file:> scheme, this acts as B<-CAfile> or
233 1.1 christos B<-CApath>, depending on if the URI indicates a single file or
234 1.1 christos directory.
235 1.1 christos See L<ossl_store-file(7)> for more information on the C<file:> scheme.
236 1.1 christos
237 1.1 christos These certificates are also used when building the server certificate
238 1.1 christos chain (for example with L<openssl-s_server(1)>) or client certificate
239 1.1 christos chain (for example with L<openssl-s_time(1)>).
240 1.1 christos
241 1.1 christos =item B<-no-CAstore>
242 1.1 christos
243 1.1 christos Do not use the default store of trusted CA certificates.
244 1.1 christos
245 1.1 christos =back
246 1.1 christos
247 1.1 christos =head2 Verification Options
248 1.1 christos
249 1.1 christos The certificate verification can be fine-tuned with the following flags.
250 1.1 christos
251 1.1 christos =over 4
252 1.1 christos
253 1.1 christos =item B<-verbose>
254 1.1 christos
255 1.1 christos Print extra information about the operations being performed.
256 1.1 christos
257 1.1 christos =item B<-attime> I<timestamp>
258 1.1 christos
259 1.1 christos Perform validation checks using time specified by I<timestamp> and not
260 1.1 christos current system time. I<timestamp> is the number of seconds since
261 1.1 christos January 1, 1970 (i.e., the Unix Epoch).
262 1.1 christos
263 1.1 christos =item B<-no_check_time>
264 1.1 christos
265 1.1 christos This option suppresses checking the validity period of certificates and CRLs
266 1.1 christos against the current time. If option B<-attime> is used to specify
267 1.1 christos a verification time, the check is not suppressed.
268 1.1 christos
269 1.1 christos =item B<-x509_strict>
270 1.1 christos
271 1.1 christos This disables non-compliant workarounds for broken certificates.
272 1.1 christos Thus errors are thrown on certificates not compliant with RFC 5280.
273 1.1 christos
274 1.1 christos When this option is set,
275 1.1 christos among others, the following certificate well-formedness conditions are checked:
276 1.1 christos
277 1.1 christos =over 4
278 1.1 christos
279 1.1 christos =item *
280 1.1 christos
281 1.1 christos The basicConstraints of CA certificates must be marked critical.
282 1.1 christos
283 1.1 christos =item *
284 1.1 christos
285 1.1 christos CA certificates must explicitly include the keyUsage extension.
286 1.1 christos
287 1.1 christos =item *
288 1.1 christos
289 1.1 christos If a pathlenConstraint is given the key usage keyCertSign must be allowed.
290 1.1 christos
291 1.1 christos =item *
292 1.1 christos
293 1.1 christos The pathlenConstraint must not be given for non-CA certificates.
294 1.1 christos
295 1.1 christos =item *
296 1.1 christos
297 1.1 christos The issuer name of any certificate must not be empty.
298 1.1 christos
299 1.1 christos =item *
300 1.1 christos
301 1.1 christos The subject name of CA certs, certs with keyUsage crlSign, and certs
302 1.1 christos without subjectAlternativeName must not be empty.
303 1.1 christos
304 1.1 christos =item *
305 1.1 christos
306 1.1 christos If a subjectAlternativeName extension is given it must not be empty.
307 1.1 christos
308 1.1 christos =item *
309 1.1 christos
310 1.1 christos The signatureAlgorithm field and the cert signature must be consistent.
311 1.1 christos
312 1.1 christos =item *
313 1.1 christos
314 1.1 christos Any given authorityKeyIdentifier and any given subjectKeyIdentifier
315 1.1 christos must not be marked critical.
316 1.1 christos
317 1.1 christos =item *
318 1.1 christos
319 1.1 christos The authorityKeyIdentifier must be given for X.509v3 certs unless they
320 1.1 christos are self-signed.
321 1.1 christos
322 1.1 christos =item *
323 1.1 christos
324 1.1 christos The subjectKeyIdentifier must be given for all X.509v3 CA certs.
325 1.1 christos
326 1.1 christos =back
327 1.1 christos
328 1.1 christos =item B<-ignore_critical>
329 1.1 christos
330 1.1 christos Normally if an unhandled critical extension is present that is not
331 1.1 christos supported by OpenSSL the certificate is rejected (as required by RFC5280).
332 1.1 christos If this option is set critical extensions are ignored.
333 1.1 christos
334 1.1 christos =item B<-issuer_checks>
335 1.1 christos
336 1.1 christos Ignored.
337 1.1 christos
338 1.1 christos =item B<-crl_check>
339 1.1 christos
340 1.1 christos Checks end entity certificate validity by attempting to look up a valid CRL.
341 1.1 christos If a valid CRL cannot be found an error occurs.
342 1.1 christos
343 1.1 christos =item B<-crl_check_all>
344 1.1 christos
345 1.1 christos Checks the validity of B<all> certificates in the chain by attempting
346 1.1 christos to look up valid CRLs.
347 1.1 christos
348 1.1 christos =item B<-use_deltas>
349 1.1 christos
350 1.1 christos Enable support for delta CRLs.
351 1.1 christos
352 1.1 christos =item B<-extended_crl>
353 1.1 christos
354 1.1 christos Enable extended CRL features such as indirect CRLs and alternate CRL
355 1.1 christos signing keys.
356 1.1 christos
357 1.1 christos =item B<-suiteB_128_only>, B<-suiteB_128>, B<-suiteB_192>
358 1.1 christos
359 1.1 christos Enable the Suite B mode operation at 128 bit Level of Security, 128 bit or
360 1.1 christos 192 bit, or only 192 bit Level of Security respectively.
361 1.1 christos See RFC6460 for details. In particular the supported signature algorithms are
362 1.1 christos reduced to support only ECDSA and SHA256 or SHA384 and only the elliptic curves
363 1.1 christos P-256 and P-384.
364 1.1 christos
365 1.1 christos =item B<-auth_level> I<level>
366 1.1 christos
367 1.1 christos Set the certificate chain authentication security level to I<level>.
368 1.1 christos The authentication security level determines the acceptable signature and
369 1.1 christos public key strength when verifying certificate chains. For a certificate
370 1.1 christos chain to validate, the public keys of all the certificates must meet the
371 1.1 christos specified security I<level>. The signature algorithm security level is
372 1.1 christos enforced for all the certificates in the chain except for the chain's
373 1.1 christos I<trust anchor>, which is either directly trusted or validated by means
374 1.1 christos other than its signature. See L<SSL_CTX_set_security_level(3)> for the
375 1.1 christos definitions of the available levels. The default security level is -1,
376 1.1 christos or "not set". At security level 0 or lower all algorithms are acceptable.
377 1.1 christos Security level 1 requires at least 80-bit-equivalent security and is broadly
378 1.1 christos interoperable, though it will, for example, reject MD5 signatures or RSA
379 1.1 christos keys shorter than 1024 bits.
380 1.1 christos
381 1.1 christos =item B<-partial_chain>
382 1.1 christos
383 1.1 christos Allow verification to succeed if an incomplete chain can be built.
384 1.1 christos That is, a chain ending in a certificate that normally would not be trusted
385 1.1 christos (because it has no matching positive trust attributes and is not self-signed)
386 1.1 christos but is an element of the trust store.
387 1.1 christos This certificate may be self-issued or belong to an intermediate CA.
388 1.1 christos
389 1.1 christos =item B<-check_ss_sig>
390 1.1 christos
391 1.1 christos Verify the signature of
392 1.1 christos the last certificate in a chain if the certificate is supposedly self-signed.
393 1.1 christos This is prohibited and will result in an error if it is a non-conforming CA
394 1.1 christos certificate with key usage restrictions not including the keyCertSign bit.
395 1.1 christos This verification is disabled by default because it doesn't add any security.
396 1.1 christos
397 1.1 christos =item B<-allow_proxy_certs>
398 1.1 christos
399 1.1 christos Allow the verification of proxy certificates.
400 1.1 christos
401 1.1 christos =item B<-trusted_first>
402 1.1 christos
403 1.1 christos As of OpenSSL 1.1.0 this option is on by default and cannot be disabled.
404 1.1 christos
405 1.1 christos When constructing the certificate chain, the trusted certificates specified
406 1.1 christos via B<-CAfile>, B<-CApath>, B<-CAstore> or B<-trusted> are always used
407 1.1 christos before any certificates specified via B<-untrusted>.
408 1.1 christos
409 1.1 christos =item B<-no_alt_chains>
410 1.1 christos
411 1.1 christos As of OpenSSL 1.1.0, since B<-trusted_first> always on, this option has no
412 1.1 christos effect.
413 1.1 christos
414 1.1 christos =item B<-trusted> I<file>
415 1.1 christos
416 1.1 christos Parse I<file> as a set of one or more certificates.
417 1.1 christos Each of them qualifies as trusted if has a suitable positive trust attribute
418 1.1 christos or it is self-signed or the B<-partial_chain> option is specified.
419 1.1 christos This option implies the B<-no-CAfile>, B<-no-CApath>, and B<-no-CAstore> options
420 1.1 christos and it cannot be used with the B<-CAfile>, B<-CApath> or B<-CAstore> options, so
421 1.1 christos only certificates specified using the B<-trusted> option are trust anchors.
422 1.1 christos This option may be used multiple times.
423 1.1 christos
424 1.1 christos =item B<-untrusted> I<file>
425 1.1 christos
426 1.1 christos Parse I<file> as a set of one or more certificates.
427 1.1 christos All certificates (typically of intermediate CAs) are considered untrusted
428 1.1 christos and may be used to
429 1.1 christos construct a certificate chain from the target certificate to a trust anchor.
430 1.1 christos This option may be used multiple times.
431 1.1 christos
432 1.1 christos =item B<-policy> I<arg>
433 1.1 christos
434 1.1 christos Enable policy processing and add I<arg> to the user-initial-policy-set (see
435 1.1 christos RFC5280). The policy I<arg> can be an object name or an OID in numeric form.
436 1.1 christos This argument can appear more than once.
437 1.1 christos
438 1.1 christos =item B<-explicit_policy>
439 1.1 christos
440 1.1 christos Set policy variable require-explicit-policy (see RFC5280).
441 1.1 christos
442 1.1 christos =item B<-policy_check>
443 1.1 christos
444 1.1 christos Enables certificate policy processing.
445 1.1 christos
446 1.1 christos =item B<-policy_print>
447 1.1 christos
448 1.1 christos Print out diagnostics related to policy processing.
449 1.1 christos
450 1.1 christos =item B<-inhibit_any>
451 1.1 christos
452 1.1 christos Set policy variable inhibit-any-policy (see RFC5280).
453 1.1 christos
454 1.1 christos =item B<-inhibit_map>
455 1.1 christos
456 1.1 christos Set policy variable inhibit-policy-mapping (see RFC5280).
457 1.1 christos
458 1.1 christos =item B<-purpose> I<purpose>
459 1.1 christos
460 1.1 christos A high-level specification of the intended use of the target certificate.
461 1.1 christos Currently predefined purposes are C<sslclient>, C<sslserver>, C<nssslserver>,
462 1.1 christos C<smimesign>, C<smimeencrypt>, C<crlsign>, C<ocsphelper>, C<timestampsign>,
463 1.1 christos C<codesign> and C<any>.
464 1.1 christos If peer certificate verification is enabled, by default the TLS implementation
465 1.1 christos and thus the commands L<openssl-s_client(1)> and L<openssl-s_server(1)>
466 1.1 christos check for consistency with
467 1.1 christos TLS server (C<sslserver>) or TLS client use (C<sslclient>), respectively.
468 1.1 christos By default, CMS signature validation, which can be done via L<openssl-cms(1)>,
469 1.1 christos checks for consistency with S/MIME signing use (C<smimesign>).
470 1.1 christos
471 1.1 christos While IETF RFC 5280 says that B<id-kp-serverAuth> and B<id-kp-clientAuth>
472 1.1 christos are only for WWW use, in practice they are used for all kinds of TLS clients
473 1.1 christos and servers, and this is what OpenSSL assumes as well.
474 1.1 christos
475 1.1 christos =item B<-verify_depth> I<num>
476 1.1 christos
477 1.1 christos Limit the certificate chain to I<num> intermediate CA certificates.
478 1.1 christos A maximal depth chain can have up to I<num>+2 certificates, since neither the
479 1.1 christos end-entity certificate nor the trust-anchor certificate count against the
480 1.1 christos B<-verify_depth> limit.
481 1.1 christos
482 1.1 christos =item B<-verify_email> I<email>
483 1.1 christos
484 1.1 christos Verify if I<email> matches the email address in Subject Alternative Name or
485 1.1 christos the email in the subject Distinguished Name.
486 1.1 christos
487 1.1 christos =item B<-verify_hostname> I<hostname>
488 1.1 christos
489 1.1 christos Verify if I<hostname> matches DNS name in Subject Alternative Name or
490 1.1 christos Common Name in the subject certificate.
491 1.1 christos
492 1.1 christos =item B<-verify_ip> I<ip>
493 1.1 christos
494 1.1 christos Verify if I<ip> matches the IP address in Subject Alternative Name of
495 1.1 christos the subject certificate.
496 1.1 christos
497 1.1 christos =item B<-verify_name> I<name>
498 1.1 christos
499 1.1 christos Use a set of verification parameters, also known as verification method,
500 1.1 christos identified by I<name>. The currently predefined methods are named C<ssl_client>,
501 1.1 christos C<ssl_server>, C<smime_sign> with alias C<pkcs7>, C<code_sign>, and C<default>.
502 1.1 christos These mimic the combinations of purpose and trust settings used in SSL/(D)TLS,
503 1.1 christos CMS/PKCS7 (including S/MIME), and code signing.
504 1.1 christos
505 1.1 christos The verification parameters include the trust model, various flags that can
506 1.1 christos partly be set also via other command-line options, and the verification purpose,
507 1.1 christos which in turn implies certificate key usage and extended key usage requirements.
508 1.1 christos
509 1.1 christos The trust model determines which auxiliary trust or reject OIDs are applicable
510 1.1 christos to verifying the given certificate chain.
511 1.1 christos They can be given using the B<-addtrust> and B<-addreject> options
512 1.1 christos for L<openssl-x509(1)>.
513 1.1 christos
514 1.1 christos =back
515 1.1 christos
516 1.1 christos =head2 Extended Verification Options
517 1.1 christos
518 1.1 christos Sometimes there may be more than one certificate chain leading to an
519 1.1 christos end-entity certificate.
520 1.1 christos This usually happens when a root or intermediate CA signs a certificate
521 1.1 christos for another a CA in other organization.
522 1.1 christos Another reason is when a CA might have intermediates that use two different
523 1.1 christos signature formats, such as a SHA-1 and a SHA-256 digest.
524 1.1 christos
525 1.1 christos The following options can be used to provide data that will allow the
526 1.1 christos OpenSSL command to generate an alternative chain.
527 1.1 christos
528 1.1 christos =over 4
529 1.1 christos
530 1.1 christos =item B<-xkey> I<infile>, B<-xcert> I<infile>, B<-xchain>
531 1.1 christos
532 1.1 christos Specify an extra certificate, private key and certificate chain. These behave
533 1.1 christos in the same manner as the B<-cert>, B<-key> and B<-cert_chain> options. When
534 1.1 christos specified, the callback returning the first valid chain will be in use by the
535 1.1 christos client.
536 1.1 christos
537 1.1 christos =item B<-xchain_build>
538 1.1 christos
539 1.1 christos Specify whether the application should build the certificate chain to be
540 1.1 christos provided to the server for the extra certificates via the B<-xkey>,
541 1.1 christos B<-xcert>, and B<-xchain> options.
542 1.1 christos
543 1.1 christos =item B<-xcertform> B<DER>|B<PEM>|B<P12>
544 1.1 christos
545 1.1 christos The input format for the extra certificate.
546 1.1 christos This option has no effect and is retained for backward compatibility only.
547 1.1 christos
548 1.1 christos =item B<-xkeyform> B<DER>|B<PEM>|B<P12>
549 1.1 christos
550 1.1 christos The input format for the extra key.
551 1.1 christos This option has no effect and is retained for backward compatibility only.
552 1.1 christos
553 1.1 christos =back
554 1.1 christos
555 1.1 christos =head2 Certificate Extensions
556 1.1 christos
557 1.1 christos Options like B<-purpose> and B<-verify_name> trigger the processing of specific
558 1.1 christos certificate extensions, which determine what certificates can be used for.
559 1.1 christos
560 1.1 christos =head3 Basic Constraints
561 1.1 christos
562 1.1 christos The basicConstraints extension CA flag is used to determine whether the
563 1.1 christos certificate can be used as a CA. If the CA flag is true then it is a CA,
564 1.1 christos if the CA flag is false then it is not a CA. B<All> CAs should have the
565 1.1 christos CA flag set to true.
566 1.1 christos
567 1.1 christos If the basicConstraints extension is absent,
568 1.1 christos which includes the case that it is an X.509v1 certificate,
569 1.1 christos then the certificate is considered to be a "possible CA" and
570 1.1 christos other extensions are checked according to the intended use of the certificate.
571 1.1 christos The treatment of certificates without basicConstraints as a CA
572 1.1 christos is presently supported, but this could change in the future.
573 1.1 christos
574 1.1 christos =head3 Key Usage
575 1.1 christos
576 1.1 christos If the keyUsage extension is present then additional restraints are
577 1.1 christos made on the uses of the certificate. A CA certificate B<must> have the
578 1.1 christos keyCertSign bit set if the keyUsage extension is present.
579 1.1 christos
580 1.1 christos =head3 Extended Key Usage
581 1.1 christos
582 1.1 christos The extKeyUsage (EKU) extension places additional restrictions on
583 1.1 christos certificate use. If this extension is present (whether critical or not)
584 1.1 christos in an end-entity certficiate, the key is allowed only for the uses specified,
585 1.1 christos while the special EKU B<anyExtendedKeyUsage> allows for all uses.
586 1.1 christos
587 1.1 christos Note that according to RFC 5280 section 4.2.1.12,
588 1.1 christos the Extended Key Usage extension will appear only in end-entity certificates,
589 1.1 christos and consequently the standard certification path validation described
590 1.1 christos in its section 6 does not include EKU checks for CA certificates.
591 1.1 christos The CA/Browser Forum requires for TLS server, S/MIME, and code signing use
592 1.1 christos the presence of respective EKUs in subordinate CA certificates (while excluding
593 1.1 christos them for root CA certificates), while taking over from RFC 5280
594 1.1 christos the certificate validity concept and certificate path validation.
595 1.1 christos
596 1.1 christos For historic reasons, OpenSSL has its own way of interpreting and checking
597 1.1 christos EKU extensions on CA certificates, which may change in the future.
598 1.1 christos It does not require the presence of EKU extensions in CA certificates,
599 1.1 christos but in case the verification purpose is
600 1.1 christos C<sslclient>, C<nssslserver>, C<sslserver>, C<smimesign>, or C<smimeencrypt>,
601 1.1 christos it checks that any present EKU extension (that does not contain
602 1.1 christos B<anyExtendedKeyUsage>) contains the respective EKU as detailed below.
603 1.1 christos Moreover, it does these checks even for trust anchor certificates.
604 1.1 christos
605 1.1 christos =head3 Checks Implied by Specific Predefined Policies
606 1.1 christos
607 1.1 christos A specific description of each check is given below. The comments about
608 1.1 christos basicConstraints and keyUsage and X.509v1 certificates above apply to B<all>
609 1.1 christos CA certificates.
610 1.1 christos
611 1.1 christos =over 4
612 1.1 christos
613 1.1 christos =item B<(D)TLS Client> (C<sslclient>)
614 1.1 christos
615 1.1 christos Any given extended key usage extension must allow for C<clientAuth>
616 1.1 christos ("TLS WWW client authentication").
617 1.1 christos
618 1.1 christos For target certificates,
619 1.1 christos the key usage must allow for C<digitalSignature> and/or C<keyAgreement>.
620 1.1 christos The Netscape certificate type must be absent or have the SSL client bit set.
621 1.1 christos
622 1.1 christos For all other certificates the normal CA checks apply. In addition,
623 1.1 christos the Netscape certificate type must be absent or have the SSL CA bit set.
624 1.1 christos This is used as a workaround if the basicConstraints extension is absent.
625 1.1 christos
626 1.1 christos =item B<(D)TLS Server> (C<sslserver>)
627 1.1 christos
628 1.1 christos Any given extended key usage extension must allow for C<serverAuth>
629 1.1 christos ("TLS WWW server authentication") and/or include one of the SGC OIDs.
630 1.1 christos
631 1.1 christos For target certificates, the key usage must
632 1.1 christos allow for C<digitalSignature>, C<keyEncipherment>, and/or C<keyAgreement>.
633 1.1 christos The Netscape certificate type must be absent or have the SSL server bit set.
634 1.1 christos
635 1.1 christos For all other certificates the normal CA checks apply. In addition,
636 1.1 christos the Netscape certificate type must be absent or have the SSL CA bit set.
637 1.1 christos This is used as a workaround if the basicConstraints extension is absent.
638 1.1 christos
639 1.1 christos =item B<Netscape SSL Server> (C<nssslserver>)
640 1.1 christos
641 1.1 christos In addition to what has been described for B<sslserver>, for a Netscape
642 1.1 christos SSL client to connect to an SSL server, its EE certficate must have the
643 1.1 christos B<keyEncipherment> bit set if the keyUsage extension is present. This isn't
644 1.1 christos always valid because some cipher suites use the key for digital signing.
645 1.1 christos Otherwise it is the same as a normal SSL server.
646 1.1 christos
647 1.1 christos =item B<Common S/MIME Checks>
648 1.1 christos
649 1.1 christos Any given extended key usage extension must allow for C<emailProtection>.
650 1.1 christos
651 1.1 christos For target certificates,
652 1.1 christos the Netscape certificate type must be absent or should have the S/MIME bit set.
653 1.1 christos If the S/MIME bit is not set in the Netscape certificate type
654 1.1 christos then the SSL client bit is tolerated as an alternative but a warning is shown.
655 1.1 christos This is because some Verisign certificates don't set the S/MIME bit.
656 1.1 christos
657 1.1 christos For all other certificates the normal CA checks apply. In addition,
658 1.1 christos the Netscape certificate type must be absent or have the S/MIME CA bit set.
659 1.1 christos This is used as a workaround if the basicConstraints extension is absent.
660 1.1 christos
661 1.1 christos =item B<S/MIME Signing> (C<smimesign>)
662 1.1 christos
663 1.1 christos In addition to the common S/MIME checks, for target certficiates
664 1.1 christos the key usage must allow for C<digitalSignature> and/or B<nonRepudiation>.
665 1.1 christos
666 1.1 christos =item B<S/MIME Encryption> (C<smimeencrypt>)
667 1.1 christos
668 1.1 christos In addition to the common S/MIME checks, for target certficiates
669 1.1 christos the key usage must allow for C<keyEncipherment>.
670 1.1 christos
671 1.1 christos =item B<CRL Signing> (C<crlsign>)
672 1.1 christos
673 1.1 christos For target certificates, the key usage must allow for C<cRLSign>.
674 1.1 christos
675 1.1 christos For all other certifcates the normal CA checks apply.
676 1.1 christos Except in this case the basicConstraints extension must be present.
677 1.1 christos
678 1.1 christos =item B<OCSP Helper> (C<ocsphelper>)
679 1.1 christos
680 1.1 christos For target certificates, no checks are performed at this stage,
681 1.1 christos but special checks apply; see L<OCSP_basic_verify(3)>.
682 1.1 christos
683 1.1 christos For all other certifcates the normal CA checks apply.
684 1.1 christos
685 1.1 christos =item B<Timestamp Signing> (C<timestampsign>)
686 1.1 christos
687 1.1 christos For target certificates, if the key usage extension is present, it must include
688 1.1 christos C<digitalSignature> and/or C<nonRepudiation> and must not include other bits.
689 1.1 christos The EKU extension must be present and contain C<timeStamping> only.
690 1.1 christos Moreover, it must be marked as critical.
691 1.1 christos
692 1.1 christos For all other certifcates the normal CA checks apply.
693 1.1 christos
694 1.1 christos =item B<Code Signing> (C<codesign>)
695 1.1 christos
696 1.1 christos For target certificates,
697 1.1 christos the key usage extension must be present and marked critical and
698 1.1 christos include <digitalSignature>, but must not include C<keyCertSign> nor C<cRLSign>.
699 1.1 christos The EKU extension must be present and contain C<codeSign>,
700 1.1 christos but must not include C<anyExtendedKeyUsage> nor C<serverAuth>.
701 1.1 christos
702 1.1 christos For all other certifcates the normal CA checks apply.
703 1.1 christos
704 1.1 christos =back
705 1.1 christos
706 1.1 christos =head1 BUGS
707 1.1 christos
708 1.1 christos The issuer checks still suffer from limitations in the underlying X509_LOOKUP
709 1.1 christos API. One consequence of this is that trusted certificates with matching
710 1.1 christos subject name must appear in a file (as specified by the B<-CAfile> option),
711 1.1 christos a directory (as specified by B<-CApath>),
712 1.1 christos or a store (as specified by B<-CAstore>).
713 1.1 christos If there are multiple such matches, possibly in multiple locations,
714 1.1 christos only the first one (in the mentioned order of locations) is recognised.
715 1.1 christos
716 1.1 christos =head1 SEE ALSO
717 1.1 christos
718 1.1 christos L<X509_verify_cert(3)>,
719 1.1 christos L<OCSP_basic_verify(3)>,
720 1.1 christos L<openssl-verify(1)>,
721 1.1 christos L<openssl-ocsp(1)>,
722 1.1 christos L<openssl-ts(1)>,
723 1.1 christos L<openssl-s_client(1)>,
724 1.1 christos L<openssl-s_server(1)>,
725 1.1 christos L<openssl-smime(1)>,
726 1.1 christos L<openssl-cmp(1)>,
727 1.1 christos L<openssl-cms(1)>
728 1.1 christos
729 1.1 christos =head1 HISTORY
730 1.1 christos
731 1.1 christos The checks enabled by B<-x509_strict> have been extended in OpenSSL 3.0.
732 1.1 christos
733 1.1 christos =head1 COPYRIGHT
734 1.1 christos
735 1.1 christos Copyright 2000-2024 The OpenSSL Project Authors. All Rights Reserved.
736 1.1 christos
737 1.1 christos Licensed under the Apache License 2.0 (the "License"). You may not use
738 1.1 christos this file except in compliance with the License. You can obtain a copy
739 1.1 christos in the file LICENSE in the source distribution or at
740 1.1 christos L<https://www.openssl.org/source/license.html>.
741 1.1 christos
742 1.1 christos =cut
743