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