openssl-prebuild/linux_amd64/share/doc/openssl/html/man1/openssl-x509.html
2020-03-02 16:50:34 +00:00

924 lines
38 KiB
HTML
Executable File

<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>openssl-x509</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:root@localhost" />
</head>
<body style="background-color: white">
<!-- INDEX BEGIN -->
<div name="index">
<p><a name="__index__"></a></p>
<ul>
<li><a href="#name">NAME</a></li>
<li><a href="#synopsis">SYNOPSIS</a></li>
<li><a href="#description">DESCRIPTION</a></li>
<li><a href="#options">OPTIONS</a></li>
<ul>
<li><a href="#input__output__and_general_purpose_options">Input, Output, and General Purpose Options</a></li>
<li><a href="#display_options">Display Options</a></li>
<li><a href="#trust_settings">Trust Settings</a></li>
<li><a href="#signing_options">Signing Options</a></li>
<li><a href="#text_options">Text Options</a></li>
</ul>
<li><a href="#examples">EXAMPLES</a></li>
<li><a href="#notes">NOTES</a></li>
<li><a href="#certificate_extensions">CERTIFICATE EXTENSIONS</a></li>
<li><a href="#bugs">BUGS</a></li>
<li><a href="#see_also">SEE ALSO</a></li>
<li><a href="#history">HISTORY</a></li>
<li><a href="#copyright">COPYRIGHT</a></li>
</ul>
<hr name="index" />
</div>
<!-- INDEX END -->
<p>
</p>
<hr />
<h1><a name="name">NAME</a></h1>
<p>openssl-x509 - Certificate display and signing utility</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<p><strong>openssl</strong> <strong>x509</strong>
[<strong>-help</strong>]
[<strong>-inform</strong> <strong>DER</strong>|<strong>PEM</strong>]
[<strong>-outform</strong> <strong>DER</strong>|<strong>PEM</strong>]
[<strong>-keyform</strong> <strong>DER</strong>|<strong>PEM</strong>|<strong>ENGINE</strong>]
[<strong>-CAform</strong> <strong>DER</strong>|<strong>PEM</strong>]
[<strong>-CAkeyform</strong> <strong>DER</strong>|<strong>PEM</strong>|<strong>ENGINE</strong>]
[<strong>-in</strong> <em>filename</em>]
[<strong>-out</strong> <em>filename</em>]
[<strong>-serial</strong>]
[<strong>-hash</strong>]
[<strong>-subject_hash</strong>]
[<strong>-subject_hash_old</strong>]
[<strong>-issuer_hash</strong>]
[<strong>-issuer_hash_old</strong>]
[<strong>-ocspid</strong>]
[<strong>-subject</strong>]
[<strong>-issuer</strong>]
[<strong>-email</strong>]
[<strong>-ocsp_uri</strong>]
[<strong>-startdate</strong>]
[<strong>-enddate</strong>]
[<strong>-purpose</strong>]
[<strong>-dates</strong>]
[<strong>-checkend</strong> <em>num</em>]
[<strong>-modulus</strong>]
[<strong>-pubkey</strong>]
[<strong>-fingerprint</strong>]
[<strong>-alias</strong>]
[<strong>-noout</strong>]
[<strong>-trustout</strong>]
[<strong>-clrtrust</strong>]
[<strong>-clrreject</strong>]
[<strong>-addtrust</strong> <em>arg</em>]
[<strong>-addreject</strong> <em>arg</em>]
[<strong>-setalias</strong> <em>arg</em>]
[<strong>-days</strong> <em>arg</em>]
[<strong>-set_serial</strong> <em>n</em>]
[<strong>-signkey</strong> <em>arg</em>]
[<strong>-badsig</strong>]
[<strong>-passin</strong> <em>arg</em>]
[<strong>-x509toreq</strong>]
[<strong>-req</strong>]
[<strong>-CA</strong> <em>filename</em>]
[<strong>-CAkey</strong> <em>filename</em>]
[<strong>-CAcreateserial</strong>]
[<strong>-CAserial</strong> <em>filename</em>]
[<strong>-new</strong>]
[<strong>-next_serial</strong>]
[<strong>-nocert</strong>]
[<strong>-force_pubkey</strong> <em>filename</em>]
[<strong>-subj</strong> <em>arg</em>]
[<strong>-text</strong>]
[<strong>-ext</strong> <em>extensions</em>]
[<strong>-certopt</strong> <em>option</em>]
[<strong>-checkhost</strong> <em>host</em>]
[<strong>-checkemail</strong> <em>host</em>]
[<strong>-checkip</strong> <em>ipaddr</em>]
[<strong>-C</strong>]
[<strong>-<em>digest</em></strong>]
[<strong>-clrext</strong>]
[<strong>-extfile</strong> <em>filename</em>]
[<strong>-extensions</strong> <em>section</em>]
[<strong>-sigopt</strong> <em>nm</em>:<em>v</em>]
[<strong>-preserve_dates</strong>]
[<strong>-nameopt</strong> <em>option</em>]
[<strong>-rand</strong> <em>files</em>]
[<strong>-writerand</strong> <em>file</em>]
[<strong>-engine</strong> <em>id</em>]</p>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>This command is a multi purpose certificate utility. It can
be used to display certificate information, convert certificates to
various forms, sign certificate requests like a &quot;mini CA&quot; or edit
certificate trust settings.</p>
<p>Since there are a large number of options they will split up into
various sections.</p>
<p>
</p>
<hr />
<h1><a name="options">OPTIONS</a></h1>
<p>
</p>
<h2><a name="input__output__and_general_purpose_options">Input, Output, and General Purpose Options</a></h2>
<dl>
<dt><strong><a name="help" class="item"><strong>-help</strong></a></strong></dt>
<dd>
<p>Print out a usage message.</p>
</dd>
<dt><strong><a name="inform_der_pem_outform_der_pem" class="item"><strong>-inform</strong> <strong>DER</strong>|<strong>PEM</strong>, <strong>-outform</strong> <strong>DER</strong>|<strong>PEM</strong></a></strong></dt>
<dd>
<p>The input and formats; the default is <strong>PEM</strong>.
See <em>openssl(1)/Format Options</em> for details.</p>
<p>The input is normally an X.509 certificate, but this can change if other
options such as <strong>-req</strong> are used.</p>
</dd>
<dt><strong><a name="in_filename" class="item"><strong>-in</strong> <em>filename</em></a></strong></dt>
<dd>
<p>This specifies the input filename to read a certificate from or standard input
if this option is not specified.</p>
</dd>
<dt><strong><a name="out_filename" class="item"><strong>-out</strong> <em>filename</em></a></strong></dt>
<dd>
<p>This specifies the output filename to write to or standard output by
default.</p>
</dd>
<dt><strong><a name="digest" class="item"><strong>-<em>digest</em></strong></a></strong></dt>
<dd>
<p>The digest to use.
This affects any signing or display option that uses a message
digest, such as the <strong>-fingerprint</strong>, <strong>-signkey</strong> and <strong>-CA</strong> options.
Any digest supported by the <em>openssl-dgst(1)</em> command can be used.
If not specified then SHA1 is used with <strong>-fingerprint</strong> or
the default digest for the signing algorithm is used, typically SHA256.</p>
</dd>
<dt><strong><a name="preserve_dates" class="item"><strong>-preserve_dates</strong></a></strong></dt>
<dd>
<p>When signing a certificate, preserve the &quot;notBefore&quot; and &quot;notAfter&quot; dates
instead of adjusting them to current time and duration.
Cannot be used with the <strong>-days</strong> option.</p>
<p>[<strong>-rand</strong> <em>files</em>]
[<strong>-writerand</strong> <em>file</em>]</p>
</dd>
<dt><strong><a name="engine_id" class="item"><strong>-engine</strong> <em>id</em></a></strong></dt>
<dd>
<p>See <em>openssl(1)/Engine Options</em>.</p>
</dd>
</dl>
<p>
</p>
<h2><a name="display_options">Display Options</a></h2>
<p>Note: the <strong>-alias</strong> and <strong>-purpose</strong> options are also display options
but are described in the <a href="#trust_settings">Trust Settings</a> section.</p>
<dl>
<dt><strong><a name="text" class="item"><strong>-text</strong></a></strong></dt>
<dd>
<p>Prints out the certificate in text form. Full details are output including the
public key, signature algorithms, issuer and subject names, serial number
any extensions present and any trust settings.</p>
</dd>
<dt><strong><a name="ext_extensions" class="item"><strong>-ext</strong> <em>extensions</em></a></strong></dt>
<dd>
<p>Prints out the certificate extensions in text form. Extensions are specified
with a comma separated string, e.g., &quot;subjectAltName,subjectKeyIdentifier&quot;.
See the <em>x509v3_config(5)</em> manual page for the extension names.</p>
</dd>
<dt><strong><a name="certopt_option" class="item"><strong>-certopt</strong> <em>option</em></a></strong></dt>
<dd>
<p>Customise the output format used with <strong>-text</strong>. The <em>option</em> argument
can be a single option or multiple options separated by commas. The
<strong>-certopt</strong> switch may be also be used more than once to set multiple
options. See the <a href="#text_options">Text Options</a> section for more information.</p>
</dd>
<dt><strong><a name="checkhost_host" class="item"><strong>-checkhost</strong> <em>host</em></a></strong></dt>
<dd>
<p>Check that the certificate matches the specified host.</p>
</dd>
<dt><strong><a name="checkemail_email" class="item"><strong>-checkemail</strong> <em>email</em></a></strong></dt>
<dd>
<p>Check that the certificate matches the specified email address.</p>
</dd>
<dt><strong><a name="checkip_ipaddr" class="item"><strong>-checkip</strong> <em>ipaddr</em></a></strong></dt>
<dd>
<p>Check that the certificate matches the specified IP address.</p>
</dd>
<dt><strong><a name="noout" class="item"><strong>-noout</strong></a></strong></dt>
<dd>
<p>This option prevents output of the encoded version of the certificate.</p>
</dd>
<dt><strong><a name="pubkey" class="item"><strong>-pubkey</strong></a></strong></dt>
<dd>
<p>Outputs the certificate's SubjectPublicKeyInfo block in PEM format.</p>
</dd>
<dt><strong><a name="modulus" class="item"><strong>-modulus</strong></a></strong></dt>
<dd>
<p>This option prints out the value of the modulus of the public key
contained in the certificate.</p>
</dd>
<dt><strong><a name="serial" class="item"><strong>-serial</strong></a></strong></dt>
<dd>
<p>Outputs the certificate serial number.</p>
</dd>
<dt><strong><a name="subject_hash" class="item"><strong>-subject_hash</strong></a></strong></dt>
<dd>
<p>Outputs the &quot;hash&quot; of the certificate subject name. This is used in OpenSSL to
form an index to allow certificates in a directory to be looked up by subject
name.</p>
</dd>
<dt><strong><a name="issuer_hash" class="item"><strong>-issuer_hash</strong></a></strong></dt>
<dd>
<p>Outputs the &quot;hash&quot; of the certificate issuer name.</p>
</dd>
<dt><strong><a name="ocspid" class="item"><strong>-ocspid</strong></a></strong></dt>
<dd>
<p>Outputs the OCSP hash values for the subject name and public key.</p>
</dd>
<dt><strong><a name="hash" class="item"><strong>-hash</strong></a></strong></dt>
<dd>
<p>Synonym for &quot;-subject_hash&quot; for backward compatibility reasons.</p>
</dd>
<dt><strong><a name="subject_hash_old" class="item"><strong>-subject_hash_old</strong></a></strong></dt>
<dd>
<p>Outputs the &quot;hash&quot; of the certificate subject name using the older algorithm
as used by OpenSSL before version 1.0.0.</p>
</dd>
<dt><strong><a name="issuer_hash_old" class="item"><strong>-issuer_hash_old</strong></a></strong></dt>
<dd>
<p>Outputs the &quot;hash&quot; of the certificate issuer name using the older algorithm
as used by OpenSSL before version 1.0.0.</p>
</dd>
<dt><strong><a name="subject" class="item"><strong>-subject</strong></a></strong></dt>
<dd>
<p>Outputs the subject name.</p>
</dd>
<dt><strong><a name="issuer" class="item"><strong>-issuer</strong></a></strong></dt>
<dd>
<p>Outputs the issuer name.</p>
</dd>
<dt><strong><a name="nameopt_option" class="item"><strong>-nameopt</strong> <em>option</em></a></strong></dt>
<dd>
<p>This specifies how the subject or issuer names are displayed.
See <em>openssl(1)/Name Format Options</em> for details.</p>
</dd>
<dt><strong><a name="email" class="item"><strong>-email</strong></a></strong></dt>
<dd>
<p>Outputs the email address(es) if any.</p>
</dd>
<dt><strong><a name="ocsp_uri" class="item"><strong>-ocsp_uri</strong></a></strong></dt>
<dd>
<p>Outputs the OCSP responder address(es) if any.</p>
</dd>
<dt><strong><a name="startdate" class="item"><strong>-startdate</strong></a></strong></dt>
<dd>
<p>Prints out the start date of the certificate, that is the notBefore date.</p>
</dd>
<dt><strong><a name="enddate" class="item"><strong>-enddate</strong></a></strong></dt>
<dd>
<p>Prints out the expiry date of the certificate, that is the notAfter date.</p>
</dd>
<dt><strong><a name="dates" class="item"><strong>-dates</strong></a></strong></dt>
<dd>
<p>Prints out the start and expiry dates of a certificate.</p>
</dd>
<dt><strong><a name="checkend_arg" class="item"><strong>-checkend</strong> <em>arg</em></a></strong></dt>
<dd>
<p>Checks if the certificate expires within the next <em>arg</em> seconds and exits
nonzero if yes it will expire or zero if not.</p>
</dd>
<dt><strong><a name="fingerprint" class="item"><strong>-fingerprint</strong></a></strong></dt>
<dd>
<p>Calculates and outputs the digest of the DER encoded version of the entire
certificate (see digest options).
This is commonly called a &quot;fingerprint&quot;. Because of the nature of message
digests, the fingerprint of a certificate is unique to that certificate and
two certificates with the same fingerprint can be considered to be the same.</p>
</dd>
<dt><strong><a name="c" class="item"><strong>-C</strong></a></strong></dt>
<dd>
<p>This outputs the certificate in the form of a C source file.</p>
</dd>
</dl>
<p>
</p>
<h2><a name="trust_settings">Trust Settings</a></h2>
<p>A <strong>trusted certificate</strong> is an ordinary certificate which has several
additional pieces of information attached to it such as the permitted
and prohibited uses of the certificate and an &quot;alias&quot;.</p>
<p>Normally when a certificate is being verified at least one certificate
must be &quot;trusted&quot;. By default a trusted certificate must be stored
locally and must be a root CA: any certificate chain ending in this CA
is then usable for any purpose.</p>
<p>Trust settings currently are only used with a root CA. They allow a finer
control over the purposes the root CA can be used for. For example a CA
may be trusted for SSL client but not SSL server use.</p>
<p>See the description in <em>openssl-verify(1)</em> for more information
on the meaning of trust settings.</p>
<p>Future versions of OpenSSL will recognize trust settings on any
certificate: not just root CAs.</p>
<dl>
<dt><strong><a name="trustout" class="item"><strong>-trustout</strong></a></strong></dt>
<dd>
<p>Output a <strong>trusted</strong> certificate rather than an ordinary. An ordinary
or trusted certificate can be input but by default an ordinary
certificate is output and any trust settings are discarded. With the
<strong>-trustout</strong> option a trusted certificate is output. A trusted
certificate is automatically output if any trust settings are modified.</p>
</dd>
<dt><strong><a name="setalias_arg" class="item"><strong>-setalias</strong> <em>arg</em></a></strong></dt>
<dd>
<p>Sets the alias of the certificate. This will allow the certificate
to be referred to using a nickname for example &quot;Steve's Certificate&quot;.</p>
</dd>
<dt><strong><a name="alias" class="item"><strong>-alias</strong></a></strong></dt>
<dd>
<p>Outputs the certificate alias, if any.</p>
</dd>
<dt><strong><a name="clrtrust" class="item"><strong>-clrtrust</strong></a></strong></dt>
<dd>
<p>Clears all the permitted or trusted uses of the certificate.</p>
</dd>
<dt><strong><a name="clrreject" class="item"><strong>-clrreject</strong></a></strong></dt>
<dd>
<p>Clears all the prohibited or rejected uses of the certificate.</p>
</dd>
<dt><strong><a name="addtrust_arg" class="item"><strong>-addtrust</strong> <em>arg</em></a></strong></dt>
<dd>
<p>Adds a trusted certificate use.
Any object name can be used here but currently only <strong>clientAuth</strong> (SSL client
use), <strong>serverAuth</strong> (SSL server use), <strong>emailProtection</strong> (S/MIME email) and
<strong>anyExtendedKeyUsage</strong> are used.
As of OpenSSL 1.1.0, the last of these blocks all purposes when rejected or
enables all purposes when trusted.
Other OpenSSL applications may define additional uses.</p>
</dd>
<dt><strong><a name="addreject_arg" class="item"><strong>-addreject</strong> <em>arg</em></a></strong></dt>
<dd>
<p>Adds a prohibited use. It accepts the same values as the <strong>-addtrust</strong>
option.</p>
</dd>
<dt><strong><a name="purpose" class="item"><strong>-purpose</strong></a></strong></dt>
<dd>
<p>This option performs tests on the certificate extensions and outputs
the results. For a more complete description see the
<a href="#certificate_extensions">CERTIFICATE EXTENSIONS</a> section.</p>
</dd>
</dl>
<p>
</p>
<h2><a name="signing_options">Signing Options</a></h2>
<p>This command can be used to sign certificates and requests: it
can thus behave like a &quot;mini CA&quot;.</p>
<dl>
<dt><strong><a name="signkey_arg" class="item"><strong>-signkey</strong> <em>arg</em></a></strong></dt>
<dd>
<p>This option causes the input file to be self signed using the supplied
private key or engine. The private key's format is specified with the
<strong>-keyform</strong> option.</p>
<p>It sets the issuer name to the subject name (i.e., makes it self-issued)
and changes the public key to the supplied value (unless overridden by
<strong>-force_pubkey</strong>). It sets the validity start date to the current time
and the end date to a value determined by the <strong>-days</strong> option.
It retains any certificate extensions unless the <strong>-clrext</strong> option is supplied;
this includes, for example, any existing key identifier extensions.</p>
</dd>
<dt><strong><a name="badsig" class="item"><strong>-badsig</strong></a></strong></dt>
<dd>
<p>Corrupt the signature before writing it; this can be useful
for testing.</p>
</dd>
<dt><strong><a name="sigopt_nm_v" class="item"><strong>-sigopt</strong> <em>nm</em>:<em>v</em></a></strong></dt>
<dd>
<p>Pass options to the signature algorithm during sign or verify operations.
Names and values of these options are algorithm-specific.</p>
</dd>
<dt><strong><a name="passin_arg" class="item"><strong>-passin</strong> <em>arg</em></a></strong></dt>
<dd>
<p>The key password source. For more information about the format of <em>arg</em>
see <em>openssl(1)/Pass Phrase Options</em>.</p>
</dd>
<dt><strong><a name="clrext" class="item"><strong>-clrext</strong></a></strong></dt>
<dd>
<p>Delete any extensions from a certificate. This option is used when a
certificate is being created from another certificate (for example with
the <strong>-signkey</strong> or the <strong>-CA</strong> options). Normally all extensions are
retained.</p>
</dd>
<dt><strong><a name="keyform_der_pem_engine" class="item"><strong>-keyform</strong> <strong>DER</strong>|<strong>PEM</strong>|<strong>ENGINE</strong></a></strong></dt>
<dd>
<p>The key format; the default is <strong>PEM</strong>.
See <em>openssl(1)/Format Options</em> for details.</p>
</dd>
<dt><strong><a name="caform_der_pem_cakeyform_der_pem_engine" class="item"><strong>-CAform</strong> <strong>DER</strong>|<strong>PEM</strong>, <strong>-CAkeyform</strong> <strong>DER</strong>|<strong>PEM</strong>|<strong>ENGINE</strong></a></strong></dt>
<dd>
<p>The format for the CA certificate and key; the default is <strong>PEM</strong>.
See <em>openssl(1)/Format Options</em> for details.</p>
</dd>
<dt><strong><a name="days_arg" class="item"><strong>-days</strong> <em>arg</em></a></strong></dt>
<dd>
<p>Specifies the number of days to make a certificate valid for. The default
is 30 days. Cannot be used with the <strong>-preserve_dates</strong> option.</p>
</dd>
<dt><strong><a name="x509toreq" class="item"><strong>-x509toreq</strong></a></strong></dt>
<dd>
<p>Converts a certificate into a certificate request. The <strong>-signkey</strong> option
is used to pass the required private key.</p>
</dd>
<dt><strong><a name="req" class="item"><strong>-req</strong></a></strong></dt>
<dd>
<p>By default a certificate is expected on input. With this option a
certificate request is expected instead.</p>
</dd>
<dt><strong><a name="set_serial_n" class="item"><strong>-set_serial</strong> <em>n</em></a></strong></dt>
<dd>
<p>Specifies the serial number to use. This option can be used with either
the <strong>-signkey</strong> or <strong>-CA</strong> options. If used in conjunction with the <strong>-CA</strong>
option the serial number file (as specified by the <strong>-CAserial</strong> or
<strong>-CAcreateserial</strong> options) is not used.</p>
<p>The serial number can be decimal or hex (if preceded by <code>0x</code>).</p>
</dd>
<dt><strong><a name="ca_filename" class="item"><strong>-CA</strong> <em>filename</em></a></strong></dt>
<dd>
<p>Specifies the CA certificate to be used for signing. When this option is
present, this command behaves like a &quot;mini CA&quot;. The input file is signed by
this CA using this option: that is its issuer name is set to the subject name
of the CA and it is digitally signed using the CAs private key.</p>
<p>This option is normally combined with the <strong>-req</strong> option. Without the
<strong>-req</strong> option the input is a certificate which must be self signed.</p>
</dd>
<dt><strong><a name="cakey_filename" class="item"><strong>-CAkey</strong> <em>filename</em></a></strong></dt>
<dd>
<p>Sets the CA private key to sign a certificate with. If this option is
not specified then it is assumed that the CA private key is present in
the CA certificate file.</p>
</dd>
<dt><strong><a name="caserial_filename" class="item"><strong>-CAserial</strong> <em>filename</em></a></strong></dt>
<dd>
<p>Sets the CA serial number file to use.</p>
<p>When the <strong>-CA</strong> option is used to sign a certificate it uses a serial
number specified in a file. This file consists of one line containing
an even number of hex digits with the serial number to use. After each
use the serial number is incremented and written out to the file again.</p>
<p>The default filename consists of the CA certificate file base name with
<em class="file">.srl</em> appended. For example if the CA certificate file is called
<em class="file">mycacert.pem</em> it expects to find a serial number file called
<em class="file">mycacert.srl</em>.</p>
</dd>
<dt><strong><a name="cacreateserial" class="item"><strong>-CAcreateserial</strong></a></strong></dt>
<dd>
<p>With this option the CA serial number file is created if it does not exist:
it will contain the serial number &quot;02&quot; and the certificate being signed will
have the 1 as its serial number. If the <strong>-CA</strong> option is specified
and the serial number file does not exist a random number is generated;
this is the recommended practice.</p>
</dd>
<dt><strong><a name="extfile_filename" class="item"><strong>-extfile</strong> <em>filename</em></a></strong></dt>
<dd>
<p>File containing certificate extensions to use. If not specified then
no extensions are added to the certificate.</p>
</dd>
<dt><strong><a name="extensions_section" class="item"><strong>-extensions</strong> <em>section</em></a></strong></dt>
<dd>
<p>The section to add certificate extensions from. If this option is not
specified then the extensions should either be contained in the unnamed
(default) section or the default section should contain a variable called
&quot;extensions&quot; which contains the section to use. See the
<em>x509v3_config(5)</em> manual page for details of the
extension section format.</p>
</dd>
<dt><strong><a name="new" class="item"><strong>-new</strong></a></strong></dt>
<dd>
<p>Generate a certificate from scratch, not using an input certificate
or certificate request. So the <strong>-in</strong> option must not be used in this case.
Instead, the <strong>-subj</strong> and &lt;-force_pubkey&gt; options need to be given.</p>
</dd>
<dt><strong><a name="next_serial" class="item"><strong>-next_serial</strong></a></strong></dt>
<dd>
<p>Set the serial to be one more than the number in the certificate.</p>
</dd>
<dt><strong><a name="nocert" class="item"><strong>-nocert</strong></a></strong></dt>
<dd>
<p>Do not generate or output a certificate.</p>
</dd>
<dt><strong><a name="force_pubkey_filename" class="item"><strong>-force_pubkey</strong> <em>filename</em></a></strong></dt>
<dd>
<p>When a certificate is created set its public key to the key in <em>filename</em>
instead of the key contained in the input or given with the <strong>-signkey</strong> option.</p>
<p>This option is useful for creating self-issued certificates that are not
self-signed, for instance when the key cannot be used for signing, such as DH.
It can also be used in conjunction with b&lt;-new&gt; and <strong>-subj</strong> to directly
generate a certificate containing any desired public key.</p>
<p>The format of the key file can be specified using the <strong>-keyform</strong> option.</p>
</dd>
<dt><strong><a name="subj_arg" class="item"><strong>-subj</strong> <em>arg</em></a></strong></dt>
<dd>
<p>When a certificate is created set its subject name to the given value.
The arg must be formatted as <code>/type0=value0/type1=value1/type2=...</code>.
Keyword characters may be escaped by \ (backslash), and whitespace is retained.
Empty values are permitted, but the corresponding type will not be included
in the certificate. Giving a single <code>/</code> will lead to an empty sequence of RDNs
(a NULL subject DN).</p>
<p>Unless the <strong>-CA</strong> option is given the issuer is set to the same value.</p>
<p>This option can be used in conjunction with the <strong>-force_pubkey</strong> option
to create a certificate even without providing an input certificate
or certificate request.</p>
</dd>
</dl>
<p>
</p>
<h2><a name="text_options">Text Options</a></h2>
<p>As well as customising the name output format, it is also possible to
customise the actual fields printed using the <strong>certopt</strong> options when
the <strong>text</strong> option is present. The default behaviour is to print all fields.</p>
<dl>
<dt><strong><a name="compatible" class="item"><strong>compatible</strong></a></strong></dt>
<dd>
<p>Use the old format. This is equivalent to specifying no output options at all.</p>
</dd>
<dt><strong><a name="no_header" class="item"><strong>no_header</strong></a></strong></dt>
<dd>
<p>Don't print header information: that is the lines saying &quot;Certificate&quot;
and &quot;Data&quot;.</p>
</dd>
<dt><strong><a name="no_version" class="item"><strong>no_version</strong></a></strong></dt>
<dd>
<p>Don't print out the version number.</p>
</dd>
<dt><strong><a name="no_serial" class="item"><strong>no_serial</strong></a></strong></dt>
<dd>
<p>Don't print out the serial number.</p>
</dd>
<dt><strong><a name="no_signame" class="item"><strong>no_signame</strong></a></strong></dt>
<dd>
<p>Don't print out the signature algorithm used.</p>
</dd>
<dt><strong><a name="no_validity" class="item"><strong>no_validity</strong></a></strong></dt>
<dd>
<p>Don't print the validity, that is the <strong>notBefore</strong> and <strong>notAfter</strong> fields.</p>
</dd>
<dt><strong><a name="no_subject" class="item"><strong>no_subject</strong></a></strong></dt>
<dd>
<p>Don't print out the subject name.</p>
</dd>
<dt><strong><a name="no_issuer" class="item"><strong>no_issuer</strong></a></strong></dt>
<dd>
<p>Don't print out the issuer name.</p>
</dd>
<dt><strong><a name="no_pubkey" class="item"><strong>no_pubkey</strong></a></strong></dt>
<dd>
<p>Don't print out the public key.</p>
</dd>
<dt><strong><a name="no_sigdump" class="item"><strong>no_sigdump</strong></a></strong></dt>
<dd>
<p>Don't give a hexadecimal dump of the certificate signature.</p>
</dd>
<dt><strong><a name="no_aux" class="item"><strong>no_aux</strong></a></strong></dt>
<dd>
<p>Don't print out certificate trust information.</p>
</dd>
<dt><strong><a name="no_extensions" class="item"><strong>no_extensions</strong></a></strong></dt>
<dd>
<p>Don't print out any X509V3 extensions.</p>
</dd>
<dt><strong><a name="ext_default" class="item"><strong>ext_default</strong></a></strong></dt>
<dd>
<p>Retain default extension behaviour: attempt to print out unsupported
certificate extensions.</p>
</dd>
<dt><strong><a name="ext_error" class="item"><strong>ext_error</strong></a></strong></dt>
<dd>
<p>Print an error message for unsupported certificate extensions.</p>
</dd>
<dt><strong><a name="ext_parse" class="item"><strong>ext_parse</strong></a></strong></dt>
<dd>
<p>ASN1 parse unsupported extensions.</p>
</dd>
<dt><strong><a name="ext_dump" class="item"><strong>ext_dump</strong></a></strong></dt>
<dd>
<p>Hex dump unsupported extensions.</p>
</dd>
<dt><strong><a name="ca_default" class="item"><strong>ca_default</strong></a></strong></dt>
<dd>
<p>The value used by <em>openssl-ca(1)</em>, equivalent to <strong>no_issuer</strong>, <strong>no_pubkey</strong>,
<strong>no_header</strong>, and <strong>no_version</strong>.</p>
</dd>
</dl>
<p>
</p>
<hr />
<h1><a name="examples">EXAMPLES</a></h1>
<p>Note: in these examples the '\' means the example should be all on one
line.</p>
<p>Display the contents of a certificate:</p>
<pre>
openssl x509 -in cert.pem -noout -text</pre>
<p>Display the &quot;Subject Alternative Name&quot; extension of a certificate:</p>
<pre>
openssl x509 -in cert.pem -noout -ext subjectAltName</pre>
<p>Display more extensions of a certificate:</p>
<pre>
openssl x509 -in cert.pem -noout -ext subjectAltName,nsCertType</pre>
<p>Display the certificate serial number:</p>
<pre>
openssl x509 -in cert.pem -noout -serial</pre>
<p>Display the certificate subject name:</p>
<pre>
openssl x509 -in cert.pem -noout -subject</pre>
<p>Display the certificate subject name in <a href="http://www.ietf.org/rfc/rfc2253.txt" class="rfc">RFC2253</a> form:</p>
<pre>
openssl x509 -in cert.pem -noout -subject -nameopt RFC2253</pre>
<p>Display the certificate subject name in oneline form on a terminal
supporting UTF8:</p>
<pre>
openssl x509 -in cert.pem -noout -subject -nameopt oneline,-esc_msb</pre>
<p>Display the certificate SHA1 fingerprint:</p>
<pre>
openssl x509 -sha1 -in cert.pem -noout -fingerprint</pre>
<p>Convert a certificate from PEM to DER format:</p>
<pre>
openssl x509 -in cert.pem -inform PEM -out cert.der -outform DER</pre>
<p>Convert a certificate to a certificate request:</p>
<pre>
openssl x509 -x509toreq -in cert.pem -out req.pem -signkey key.pem</pre>
<p>Convert a certificate request into a self signed certificate using
extensions for a CA:</p>
<pre>
openssl x509 -req -in careq.pem -extfile openssl.cnf -extensions v3_ca \
-signkey key.pem -out cacert.pem</pre>
<p>Sign a certificate request using the CA certificate above and add user
certificate extensions:</p>
<pre>
openssl x509 -req -in req.pem -extfile openssl.cnf -extensions v3_usr \
-CA cacert.pem -CAkey key.pem -CAcreateserial</pre>
<p>Set a certificate to be trusted for SSL client use and change set its alias to
&quot;Steve's Class 1 CA&quot;</p>
<pre>
openssl x509 -in cert.pem -addtrust clientAuth \
-setalias &quot;Steve's Class 1 CA&quot; -out trust.pem</pre>
<p>
</p>
<hr />
<h1><a name="notes">NOTES</a></h1>
<p>The conversion to UTF8 format used with the name options assumes that
T61Strings use the ISO8859-1 character set. This is wrong but Netscape
and MSIE do this as do many certificates. So although this is incorrect
it is more likely to display the majority of certificates correctly.</p>
<p>The <strong>-email</strong> option searches the subject name and the subject alternative
name extension. Only unique email addresses will be printed out: it will
not print the same address more than once.</p>
<p>
</p>
<hr />
<h1><a name="certificate_extensions">CERTIFICATE EXTENSIONS</a></h1>
<p>The <strong>-purpose</strong> option checks the certificate extensions and determines
what the certificate can be used for. The actual checks done are rather
complex and include various hacks and workarounds to handle broken
certificates and software.</p>
<p>The same code is used when verifying untrusted certificates in chains
so this section is useful if a chain is rejected by the verify code.</p>
<p>The basicConstraints extension CA flag is used to determine whether the
certificate can be used as a CA. If the CA flag is true then it is a CA,
if the CA flag is false then it is not a CA. <strong>All</strong> CAs should have the
CA flag set to true.</p>
<p>If the basicConstraints extension is absent then the certificate is
considered to be a &quot;possible CA&quot; other extensions are checked according
to the intended use of the certificate. A warning is given in this case
because the certificate should really not be regarded as a CA: however
it is allowed to be a CA to work around some broken software.</p>
<p>If the certificate is a V1 certificate (and thus has no extensions) and
it is self signed it is also assumed to be a CA but a warning is again
given: this is to work around the problem of Verisign roots which are V1
self signed certificates.</p>
<p>If the keyUsage extension is present then additional restraints are
made on the uses of the certificate. A CA certificate <strong>must</strong> have the
keyCertSign bit set if the keyUsage extension is present.</p>
<p>The extended key usage extension places additional restrictions on the
certificate uses. If this extension is present (whether critical or not)
the key can only be used for the purposes specified.</p>
<p>A complete description of each test is given below. The comments about
basicConstraints and keyUsage and V1 certificates above apply to <strong>all</strong>
CA certificates.</p>
<dl>
<dt><strong><a name="ssl_client" class="item"><strong>SSL Client</strong></a></strong></dt>
<dd>
<p>The extended key usage extension must be absent or include the &quot;web client
authentication&quot; OID. keyUsage must be absent or it must have the
digitalSignature bit set. Netscape certificate type must be absent or it must
have the SSL client bit set.</p>
</dd>
<dt><strong><a name="ssl_client_ca" class="item"><strong>SSL Client CA</strong></a></strong></dt>
<dd>
<p>The extended key usage extension must be absent or include the &quot;web client
authentication&quot; OID. Netscape certificate type must be absent or it must have
the SSL CA bit set: this is used as a work around if the basicConstraints
extension is absent.</p>
</dd>
<dt><strong><a name="ssl_server" class="item"><strong>SSL Server</strong></a></strong></dt>
<dd>
<p>The extended key usage extension must be absent or include the &quot;web server
authentication&quot; and/or one of the SGC OIDs. keyUsage must be absent or it
must have the digitalSignature, the keyEncipherment set or both bits set.
Netscape certificate type must be absent or have the SSL server bit set.</p>
</dd>
<dt><strong><a name="ssl_server_ca" class="item"><strong>SSL Server CA</strong></a></strong></dt>
<dd>
<p>The extended key usage extension must be absent or include the &quot;web server
authentication&quot; and/or one of the SGC OIDs. Netscape certificate type must
be absent or the SSL CA bit must be set: this is used as a work around if the
basicConstraints extension is absent.</p>
</dd>
<dt><strong><a name="netscape_ssl_server" class="item"><strong>Netscape SSL Server</strong></a></strong></dt>
<dd>
<p>For Netscape SSL clients to connect to an SSL server it must have the
keyEncipherment bit set if the keyUsage extension is present. This isn't
always valid because some cipher suites use the key for digital signing.
Otherwise it is the same as a normal SSL server.</p>
</dd>
<dt><strong><a name="common_s_mime_client_tests" class="item"><strong>Common S/MIME Client Tests</strong></a></strong></dt>
<dd>
<p>The extended key usage extension must be absent or include the &quot;email
protection&quot; OID. Netscape certificate type must be absent or should have the
S/MIME bit set. If the S/MIME bit is not set in Netscape certificate type
then the SSL client bit is tolerated as an alternative but a warning is shown:
this is because some Verisign certificates don't set the S/MIME bit.</p>
</dd>
<dt><strong><a name="s_mime_signing" class="item"><strong>S/MIME Signing</strong></a></strong></dt>
<dd>
<p>In addition to the common S/MIME client tests the digitalSignature bit or
the nonRepudiation bit must be set if the keyUsage extension is present.</p>
</dd>
<dt><strong><a name="s_mime_encryption" class="item"><strong>S/MIME Encryption</strong></a></strong></dt>
<dd>
<p>In addition to the common S/MIME tests the keyEncipherment bit must be set
if the keyUsage extension is present.</p>
</dd>
<dt><strong><a name="s_mime_ca" class="item"><strong>S/MIME CA</strong></a></strong></dt>
<dd>
<p>The extended key usage extension must be absent or include the &quot;email
protection&quot; OID. Netscape certificate type must be absent or must have the
S/MIME CA bit set: this is used as a work around if the basicConstraints
extension is absent.</p>
</dd>
<dt><strong><a name="crl_signing" class="item"><strong>CRL Signing</strong></a></strong></dt>
<dd>
<p>The keyUsage extension must be absent or it must have the CRL signing bit
set.</p>
</dd>
<dt><strong><a name="crl_signing_ca" class="item"><strong>CRL Signing CA</strong></a></strong></dt>
<dd>
<p>The normal CA tests apply. Except in this case the basicConstraints extension
must be present.</p>
</dd>
</dl>
<p>
</p>
<hr />
<h1><a name="bugs">BUGS</a></h1>
<p>Extensions in certificates are not transferred to certificate requests and
vice versa.</p>
<p>It is possible to produce invalid certificates or requests by specifying the
wrong private key or using inconsistent options in some cases: these should
be checked.</p>
<p>There should be options to explicitly set such things as start and end
dates rather than an offset from the current time.</p>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<p><em>openssl(1)</em>,
<a href="#req">openssl-req(1)</a>,
<em>openssl-ca(1)</em>,
<em>openssl-genrsa(1)</em>,
<em>openssl-gendsa(1)</em>,
<em>openssl-verify(1)</em>,
<em>x509v3_config(5)</em></p>
<p>
</p>
<hr />
<h1><a name="history">HISTORY</a></h1>
<p>The hash algorithm used in the <strong>-subject_hash</strong> and <strong>-issuer_hash</strong> options
before OpenSSL 1.0.0 was based on the deprecated MD5 algorithm and the encoding
of the distinguished name. In OpenSSL 1.0.0 and later it is based on a canonical
version of the DN using SHA1. This means that any directories using the old
form must have their links rebuilt using <em>openssl-rehash(1)</em> or similar.</p>
<p>
</p>
<hr />
<h1><a name="copyright">COPYRIGHT</a></h1>
<p>Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved.</p>
<p>Licensed under the Apache License 2.0 (the &quot;License&quot;). You may not use
this file except in compliance with the License. You can obtain a copy
in the file LICENSE in the source distribution or at
<a href="https://www.openssl.org/source/license.html">https://www.openssl.org/source/license.html</a>.</p>
</body>
</html>