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