[BACK]Return to openssl.1 CVS log [TXT][DIR] Up to [local] / src / usr.bin / openssl

File: [local] / src / usr.bin / openssl / openssl.1 (download)

Revision 1.78, Tue Sep 20 16:40:05 2016 UTC (7 years, 8 months ago) by jmc
Branch: MAIN
Changes since 1.77: +40 -41 lines

shorten the verify error list;

.\" $OpenBSD: openssl.1,v 1.78 2016/09/20 16:40:05 jmc Exp $
.\" ====================================================================
.\" Copyright (c) 1998-2002 The OpenSSL Project.  All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\"
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\"
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in
.\"    the documentation and/or other materials provided with the
.\"    distribution.
.\"
.\" 3. All advertising materials mentioning features or use of this
.\"    software must display the following acknowledgment:
.\"    "This product includes software developed by the OpenSSL Project
.\"    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
.\"
.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
.\"    endorse or promote products derived from this software without
.\"    prior written permission. For written permission, please contact
.\"    openssl-core@openssl.org.
.\"
.\" 5. Products derived from this software may not be called "OpenSSL"
.\"    nor may "OpenSSL" appear in their names without prior written
.\"    permission of the OpenSSL Project.
.\"
.\" 6. Redistributions of any form whatsoever must retain the following
.\"    acknowledgment:
.\"    "This product includes software developed by the OpenSSL Project
.\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
.\" OF THE POSSIBILITY OF SUCH DAMAGE.
.\" ====================================================================
.\"
.\" This product includes cryptographic software written by Eric Young
.\" (eay@cryptsoft.com).  This product includes software written by Tim
.\" Hudson (tjh@cryptsoft.com).
.\"
.\"
.\" Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
.\" All rights reserved.
.\"
.\" This package is an SSL implementation written
.\" by Eric Young (eay@cryptsoft.com).
.\" The implementation was written so as to conform with Netscapes SSL.
.\"
.\" This library is free for commercial and non-commercial use as long as
.\" the following conditions are aheared to.  The following conditions
.\" apply to all code found in this distribution, be it the RC4, RSA,
.\" lhash, DES, etc., code; not just the SSL code.  The SSL documentation
.\" included with this distribution is covered by the same copyright terms
.\" except that the holder is Tim Hudson (tjh@cryptsoft.com).
.\"
.\" Copyright remains Eric Young's, and as such any Copyright notices in
.\" the code are not to be removed.
.\" If this package is used in a product, Eric Young should be given attribution
.\" as the author of the parts of the library used.
.\" This can be in the form of a textual message at program startup or
.\" in documentation (online or textual) provided with the package.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\"    must display the following acknowledgement:
.\"    "This product includes cryptographic software written by
.\"     Eric Young (eay@cryptsoft.com)"
.\"    The word 'cryptographic' can be left out if the rouines from the library
.\"    being used are not cryptographic related :-).
.\" 4. If you include any Windows specific code (or a derivative thereof) from
.\"    the apps directory (application code) you must include an
.\"    acknowledgement:
.\"    "This product includes software written by Tim Hudson
.\"     (tjh@cryptsoft.com)"
.\"
.\" THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" The licence and distribution terms for any publically available version or
.\" derivative of this code cannot be changed.  i.e. this code cannot simply be
.\" copied and put under another distribution licence
.\" [including the GNU Public Licence.]
.\"
.\" OPENSSL
.\"
.Dd $Mdocdate: September 20 2016 $
.Dt OPENSSL 1
.Os
.Sh NAME
.Nm openssl
.Nd OpenSSL command line tool
.Sh SYNOPSIS
.Nm
.Cm command
.Op Ar command_opts
.Op Ar command_args
.Pp
.Nm
.Cm list-standard-commands |
.Cm list-message-digest-commands |
.Cm list-cipher-commands |
.Cm list-cipher-algorithms |
.Cm list-message-digest-algorithms |
.Cm list-public-key-algorithms
.Pp
.Nm
.Cm no- Ns Ar command
.Sh DESCRIPTION
.Nm OpenSSL
is a cryptography toolkit implementing the
Transport Layer Security
.Pq TLS v1
network protocol,
as well as related cryptography standards.
.Pp
The
.Nm
program is a command line tool for using the various
cryptography functions of
.Nm openssl Ns 's
crypto library from the shell.
.Pp
The pseudo-commands
.Cm list-standard-commands , list-message-digest-commands ,
and
.Cm list-cipher-commands
output a list
.Pq one entry per line
of the names of all standard commands, message digest commands,
or cipher commands, respectively, that are available in the present
.Nm
utility.
.Pp
The pseudo-commands
.Cm list-cipher-algorithms
and
.Cm list-message-digest-algorithms
list all cipher and message digest names,
one entry per line.
Aliases are listed as:
.Pp
.D1 from => to
.Pp
The pseudo-command
.Cm list-public-key-algorithms
lists all supported public key algorithms.
.Pp
The pseudo-command
.Cm no- Ns Ar command
tests whether a command of the
specified name is available.
If
.Ar command
does not exist,
it returns 0
and prints
.Cm no- Ns Ar command ;
otherwise it returns 1 and prints
.Ar command .
In both cases, the output goes to stdout and nothing is printed to stderr.
Additional command line arguments are always ignored.
Since for each cipher there is a command of the same name,
this provides an easy way for shell scripts to test for the
availability of ciphers in the
.Nm
program.
.Pp
.Sy Note :
.Cm no- Ns Ar command
is not able to detect pseudo-commands such as
.Cm quit ,
.Cm list- Ns Ar ... Ns Cm -commands ,
or
.Cm no- Ns Ar command
itself.
.Sh ASN1PARSE
.nr nS 1
.Nm "openssl asn1parse"
.Op Fl i
.Op Fl dlimit Ar number
.Op Fl dump
.Op Fl genconf Ar file
.Op Fl genstr Ar str
.Op Fl in Ar file
.Op Fl inform Cm der | pem | txt
.Op Fl length Ar number
.Op Fl noout
.Op Fl offset Ar number
.Op Fl oid Ar file
.Op Fl out Ar file
.Op Fl strparse Ar offset
.nr nS 0
.Pp
The
.Nm asn1parse
command is a diagnostic utility that can parse ASN.1 structures.
It can also be used to extract data from ASN.1 formatted data.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl dlimit Ar number
Dump the first
.Ar number
bytes of unknown data in hex form.
.It Fl dump
Dump unknown data in hex form.
.It Fl genconf Ar file , Fl genstr Ar str
Generate encoded data based on string
.Ar str ,
file
.Ar file ,
or both, using the format described in
.Xr ASN1_generate_nconf 3 .
If only
.Ar file
is present then the string is obtained from the default section
using the name
.Dq asn1 .
The encoded data is passed through the ASN1 parser and printed out as
though it came from a file;
the contents can thus be examined and written to a file using the
.Fl out
option.
.It Fl i
Indent the output according to the
.Qq depth
of the structures.
.It Fl in Ar file
The input file to read from, or standard input if not specified.
.It Fl inform Cm der | pem | txt
The input format.
.It Fl length Ar number
Number of bytes to parse; the default is until end of file.
.It Fl noout
Do not output the parsed version of the input file.
.It Fl offset Ar number
Starting offset to begin parsing; the default is start of file.
.It Fl oid Ar file
A file containing additional object identifiers
.Pq OIDs .
If an OID
.Pq object identifier
is not part of
.Nm openssl Ns 's
internal table it will be represented in
numerical form
.Pq for example 1.2.3.4 .
.Pp
Each line consists of three columns:
the first column is the OID in numerical format and should be followed by
whitespace.
The second column is the
.Qq short name ,
which is a single word followed by whitespace.
The final column is the rest of the line and is the
.Qq long name .
.Nm asn1parse
displays the long name.
.It Fl out Ar file
The DER-encoded output file; the default is no encoded output
(useful when combined with
.Fl strparse ) .
.It Fl strparse Ar offset
Parse the content octets of the ASN.1 object starting at
.Ar offset .
This option can be used multiple times to
.Qq drill down
into a nested structure.
.El
.Sh CA
.nr nS 1
.Nm "openssl ca"
.Op Fl batch
.Op Fl cert Ar file
.Op Fl config Ar file
.Op Fl crl_CA_compromise Ar time
.Op Fl crl_compromise Ar time
.Op Fl crl_hold Ar instruction
.Op Fl crl_reason Ar reason
.Op Fl crldays Ar days
.Op Fl crlexts Ar section
.Op Fl crlhours Ar hours
.Op Fl days Ar arg
.Op Fl enddate Ar date
.Op Fl extensions Ar section
.Op Fl extfile Ar section
.Op Fl gencrl
.Op Fl in Ar file
.Op Fl infiles
.Op Fl key Ar keyfile
.Op Fl keyfile Ar arg
.Op Fl keyform Ar PEM
.Op Fl md Ar arg
.Op Fl msie_hack
.Op Fl name Ar section
.Op Fl noemailDN
.Op Fl notext
.Op Fl out Ar file
.Op Fl outdir Ar dir
.Op Fl passin Ar arg
.Op Fl policy Ar arg
.Op Fl preserveDN
.Op Fl revoke Ar file
.Op Fl spkac Ar file
.Op Fl ss_cert Ar file
.Op Fl startdate Ar date
.Op Fl status Ar serial
.Op Fl subj Ar arg
.Op Fl updatedb
.Op Fl verbose
.nr nS 0
.Pp
The
.Nm ca
command is a minimal certificate authority (CA) application.
It can be used to sign certificate requests in a variety of forms
and generate certificate revocation lists (CRLs).
It also maintains a text database of issued certificates and their status.
.Pp
The options relevant to CAs are as follows:
.Bl -tag -width "XXXX"
.It Fl batch
Batch mode.
In this mode no questions will be asked
and all certificates will be certified automatically.
.It Fl cert Ar file
The CA certificate file.
.It Fl config Ar file
Specify an alternative configuration file.
.It Fl days Ar arg
The number of days to certify the certificate for.
.It Fl enddate Ar date
Set the expiry date.
The format of the date is YYMMDDHHMMSSZ
.Pq the same as an ASN1 UTCTime structure .
.It Fl extensions Ar section
The section of the configuration file containing certificate extensions
to be added when a certificate is issued (defaults to
.Cm x509_extensions
unless the
.Fl extfile
option is used).
If no extension section is present, a V1 certificate is created.
If the extension section is present
.Pq even if it is empty ,
then a V3 certificate is created.
.It Fl extfile Ar file
An additional configuration
.Ar file
to read certificate extensions from
(using the default section unless the
.Fl extensions
option is also used).
.It Fl in Ar file
An input
.Ar file
containing a single certificate request to be signed by the CA.
.It Fl infiles
If present, this should be the last option; all subsequent arguments
are assumed to be the names of files containing certificate requests.
.It Fl key Ar keyfile
The password used to encrypt the private key.
Since on some systems the command line arguments are visible,
this option should be used with caution.
.It Fl keyfile Ar file
The private key to sign requests with.
.It Fl keyform Ar PEM
Private key file format.
.It Fl md Ar alg
The message digest to use.
Possible values include
.Ar md5
and
.Ar sha1 .
This option also applies to CRLs.
.It Fl msie_hack
This is a legacy option to make
.Nm ca
work with very old versions of the IE certificate enrollment control
.Qq certenr3 .
It used UniversalStrings for almost everything.
Since the old control has various security bugs,
its use is strongly discouraged.
The newer control
.Qq Xenroll
does not need this option.
.It Fl name Ar section
Specifies the configuration file
.Ar section
to use (overrides
.Cm default_ca
in the
.Cm ca
section).
.It Fl noemailDN
The DN of a certificate can contain the EMAIL field if present in the
request DN, however it is good policy just having the email set into
the
.Cm altName
extension of the certificate.
When this option is set, the EMAIL field is removed from the certificate's
subject and set only in the, eventually present, extensions.
The
.Ar email_in_dn
keyword can be used in the configuration file to enable this behaviour.
.It Fl notext
Don't output the text form of a certificate to the output file.
.It Fl out Ar file
The output file to output certificates to.
The default is standard output.
The certificate details will also be printed out to this file.
.It Fl outdir Ar directory
The
.Ar directory
to output certificates to.
The certificate will be written to a file consisting of the
serial number in hex with
.Qq .pem
appended.
.It Fl passin Ar arg
The key password source.
.It Fl policy Ar arg
Define the CA
.Qq policy
to use.
The policy section in the configuration file
consists of a set of variables corresponding to certificate DN fields.
The values may be one of
.Qq match
(the value must match the same field in the CA certificate),
.Qq supplied
(the value must be present), or
.Qq optional
(the value may be present).
Any fields not mentioned in the policy section
are silently deleted, unless the
.Fl preserveDN
option is set,
but this can be regarded more of a quirk than intended behaviour.
.It Fl preserveDN
Normally, the DN order of a certificate is the same as the order of the
fields in the relevant policy section.
When this option is set, the order is the same as the request.
This is largely for compatibility with the older IE enrollment control
which would only accept certificates if their DNs matched the order of the
request.
This is not needed for Xenroll.
.It Fl spkac Ar file
A file containing a single Netscape signed public key and challenge,
and additional field values to be signed by the CA.
This will usually come from the
KEYGEN tag in an HTML form to create a new private key.
It is, however, possible to create SPKACs using the
.Nm spkac
utility.
.Pp
The file should contain the variable SPKAC set to the value of
the SPKAC and also the required DN components as name value pairs.
If it's necessary to include the same component twice,
then it can be preceded by a number and a
.Sq \&. .
.It Fl ss_cert Ar file
A single self-signed certificate to be signed by the CA.
.It Fl startdate Ar date
Set the start date.
The format of the date is YYMMDDHHMMSSZ
.Pq the same as an ASN1 UTCTime structure .
.It Fl status Ar serial
Show the status of the certificate with serial number
.Ar serial .
.It Fl updatedb
Update database for expired certificates.
.It Fl verbose
Print extra details about the operations being performed.
.El
.Pp
The options relevant to CRLs are as follows:
.Bl -tag -width "XXXX"
.It Fl crl_CA_compromise Ar time
This is the same as
.Fl crl_compromise ,
except the revocation reason is set to CACompromise.
.It Fl crl_compromise Ar time
Set the revocation reason to keyCompromise and the compromise time to
.Ar time .
.Ar time
should be in GeneralizedTime format, i.e. YYYYMMDDHHMMSSZ.
.It Fl crl_hold Ar instruction
Set the CRL revocation reason code to certificateHold and the hold
instruction to
.Ar instruction
which must be an OID.
Although any OID can be used, only holdInstructionNone
(the use of which is discouraged by RFC 2459), holdInstructionCallIssuer or
holdInstructionReject will normally be used.
.It Fl crl_reason Ar reason
Revocation reason, where
.Ar reason
is one of:
unspecified, keyCompromise, CACompromise, affiliationChanged, superseded,
cessationOfOperation, certificateHold or removeFromCRL.
The matching of
.Ar reason
is case insensitive.
Setting any revocation reason will make the CRL v2.
In practice, removeFromCRL is not particularly useful because it is only used
in delta CRLs which are not currently implemented.
.It Fl crldays Ar num
The number of days before the next CRL is due.
This is the days from now to place in the CRL
.Cm nextUpdate
field.
.It Fl crlexts Ar section
The
.Ar section
of the configuration file containing CRL extensions to include.
If no CRL extension section is present then a V1 CRL is created;
if the CRL extension section is present
.Pq even if it is empty
then a V2 CRL is created.
The CRL extensions specified are CRL extensions and
.Em not
CRL entry extensions.
It should be noted that some software
.Pq for example Netscape
can't handle V2 CRLs.
.It Fl crlhours Ar num
The number of hours before the next CRL is due.
.It Fl gencrl
Generate a CRL based on information in the index file.
.It Fl revoke Ar file
A
.Ar file
containing a certificate to revoke.
.It Fl subj Ar arg
Supersedes the subject name given in the request.
The
.Ar arg
must be formatted as
.Ar /type0=value0/type1=value1/type2=... ;
characters may be escaped by
.Sq \e
.Pq backslash ,
no spaces are skipped.
.El
.Pp
Many of the options can be set in the
.Cm ca
section of the configuration file
(or in the default section of the configuration file),
specified using
.Cm default_ca
or
.Fl name .
The options
.Cm preserve
and
.Cm msie_hack
are read directly from the
.Cm ca
section.
.Pp
Many of the configuration file options are identical to command line
options.
Where the option is present in the configuration file and the command line,
the command line value is used.
Where an option is described as mandatory, then it must be present in
the configuration file or the command line equivalent
.Pq if any
used.
.Bl -tag -width "XXXX"
.It Cm certificate
The same as
.Fl cert .
It gives the file containing the CA certificate.
Mandatory.
.It Cm copy_extensions
Determines how extensions in certificate requests should be handled.
If set to
.Cm none
or this option is not present, then extensions are
ignored and not copied to the certificate.
If set to
.Cm copy ,
then any extensions present in the request that are not already present
are copied to the certificate.
If set to
.Cm copyall ,
then all extensions in the request are copied to the certificate:
if the extension is already present in the certificate it is deleted first.
.Pp
The
.Cm copy_extensions
option should be used with caution.
If care is not taken, it can be a security risk.
For example, if a certificate request contains a
.Cm basicConstraints
extension with CA:TRUE and the
.Cm copy_extensions
value is set to
.Cm copyall
and the user does not spot
this when the certificate is displayed, then this will hand the requestor
a valid CA certificate.
.Pp
This situation can be avoided by setting
.Cm copy_extensions
to
.Cm copy
and including
.Cm basicConstraints
with CA:FALSE in the configuration file.
Then if the request contains a
.Cm basicConstraints
extension, it will be ignored.
.Pp
The main use of this option is to allow a certificate request to supply
values for certain extensions such as
.Cm subjectAltName .
.It Cm crl_extensions
The same as
.Fl crlexts .
.It Cm crlnumber
A text file containing the next CRL number to use in hex.
The CRL number will be inserted in the CRLs only if this file exists.
If this file is present, it must contain a valid CRL number.
.It Cm database
The text database file to use.
Mandatory.
This file must be present, though initially it will be empty.
.It Cm default_crl_hours , default_crl_days
The same as the
.Fl crlhours
and
.Fl crldays
options.
These will only be used if neither command line option is present.
At least one of these must be present to generate a CRL.
.It Cm default_days
The same as the
.Fl days
option.
The number of days to certify a certificate for.
.It Cm default_enddate
The same as the
.Fl enddate
option.
Either this option or
.Cm default_days
.Pq or the command line equivalents
must be present.
.It Cm default_md
The same as the
.Fl md
option.
The message digest to use.
Mandatory.
.It Cm default_startdate
The same as the
.Fl startdate
option.
The start date to certify a certificate for.
If not set, the current time is used.
.It Cm email_in_dn
The same as
.Fl noemailDN .
If the EMAIL field is to be removed from the DN of the certificate,
simply set this to
.Qq no .
If not present, the default is to allow for the EMAIL field in the
certificate's DN.
.It Cm msie_hack
The same as
.Fl msie_hack .
.It Cm name_opt , cert_opt
These options allow the format used to display the certificate details
when asking the user to confirm signing.
All the options supported by the
.Nm x509
utilities'
.Fl nameopt
and
.Fl certopt
switches can be used here, except that
.Cm no_signame
and
.Cm no_sigdump
are permanently set and cannot be disabled
(this is because the certificate signature cannot be displayed because
the certificate has not been signed at this point).
.Pp
For convenience, the value
.Cm ca_default
is accepted by both to produce a reasonable output.
.Pp
If neither option is present, the format used in earlier versions of
.Nm openssl
is used.
Use of the old format is
.Em strongly
discouraged because it only displays fields mentioned in the
.Cm policy
section,
mishandles multicharacter string types and does not display extensions.
.It Cm new_certs_dir
The same as the
.Fl outdir
command line option.
It specifies the directory where new certificates will be placed.
Mandatory.
.It Cm oid_file
This specifies a file containing additional object identifiers.
Each line of the file should consist of the numerical form of the
object identifier followed by whitespace, then the short name followed
by whitespace and finally the long name.
.It Cm oid_section
This specifies a section in the configuration file containing extra
object identifiers.
Each line should consist of the short name of the object identifier
followed by
.Sq =
and the numerical form.
The short and long names are the same when this option is used.
.It Cm policy
The same as
.Fl policy .
Mandatory.
.It Cm preserve
The same as
.Fl preserveDN .
.It Cm private_key
Same as the
.Fl keyfile
option.
The file containing the CA private key.
Mandatory.
.It Cm serial
A text file containing the next serial number to use in hex.
Mandatory.
This file must be present and contain a valid serial number.
.It Cm unique_subject
If the value
.Cm yes
is given, the valid certificate entries in the
database must have unique subjects.
If the value
.Cm no
is given,
several valid certificate entries may have the exact same subject.
The default value is
.Cm yes .
.It Cm x509_extensions
The same as
.Fl extensions .
.El
.Sh CIPHERS
.Nm openssl ciphers
.Op Fl hVv
.Op Fl tls1
.Op Ar cipherlist
.Pp
The
.Nm ciphers
command converts
.Nm openssl
cipher lists into ordered SSL cipher preference lists.
It can be used as a way to determine the appropriate cipher list.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl h , \&?
Print a brief usage message.
.It Fl tls1
Only include TLS v1 ciphers.
.It Fl V
Verbose.
List ciphers with a complete description of protocol version,
key exchange, authentication, encryption and mac algorithms,
any key size restrictions,
and cipher suite codes (hex format).
.It Fl v
Like
.Fl V ,
but without cipher suite codes.
.It Ar cipherlist
A cipher list to convert to a cipher preference list.
If it is not included, the default cipher list will be used.
.Pp
The cipher list consists of one or more cipher strings
separated by colons.
Commas or spaces are also acceptable separators, but colons are normally used.
.Pp
The actual cipher string can take several different forms:
.Pp
It can consist of a single cipher suite, such as RC4-SHA.
.Pp
It can represent a list of cipher suites containing a certain algorithm,
or cipher suites of a certain type.
For example SHA1 represents all cipher suites using the digest algorithm SHA1.
.Pp
Lists of cipher suites can be combined in a single cipher string using the
.Sq +
character
(logical AND operation).
For example, SHA1+DES represents all cipher suites
containing the SHA1 and DES algorithms.
.Pp
Each cipher string can be optionally preceded by the characters
.Sq \&! ,
.Sq - ,
or
.Sq + .
If
.Sq !\&
is used, then the ciphers are permanently deleted from the list.
The ciphers deleted can never reappear in the list even if they are
explicitly stated.
If
.Sq -
is used, then the ciphers are deleted from the list, but some or
all of the ciphers can be added again by later options.
If
.Sq +
is used, then the ciphers are moved to the end of the list.
This option doesn't add any new ciphers, it just moves matching existing ones.
.Pp
If none of these characters is present, the string is just interpreted
as a list of ciphers to be appended to the current preference list.
If the list includes any ciphers already present, they will be ignored;
that is, they will not be moved to the end of the list.
.Pp
Additionally, the cipher string
.Cm @STRENGTH
can be used at any point to sort the current cipher list in order of
encryption algorithm key length.
.El
.Pp
The following is a list of all permitted cipher strings and their meanings.
.Bl -tag -width "XXXX"
.It Cm DEFAULT
The default cipher list.
This is determined at compile time and is currently
.Cm ALL:!aNULL:!eNULL:!SSLv2 .
This must be the first cipher string specified.
.It Cm COMPLEMENTOFDEFAULT
The ciphers included in
.Cm ALL ,
but not enabled by default.
Currently this is
.Cm ADH .
Note that this rule does not cover
.Cm eNULL ,
which is not included by
.Cm ALL
(use
.Cm COMPLEMENTOFALL
if necessary).
.It Cm ALL
All cipher suites except the
.Cm eNULL
ciphers, which must be explicitly enabled.
.It Cm COMPLEMENTOFALL
The cipher suites not enabled by
.Cm ALL ,
currently being
.Cm eNULL .
.It Cm HIGH
.Qq High
encryption cipher suites.
This currently means those with key lengths larger than 128 bits.
.It Cm MEDIUM
.Qq Medium
encryption cipher suites, currently those using 128-bit encryption.
.It Cm LOW
.Qq Low
encryption cipher suites, currently those using 64- or 56-bit encryption
algorithms.
.It Cm eNULL , NULL
The
.Qq NULL
ciphers; that is, those offering no encryption.
Because these offer no encryption at all and are a security risk,
they are disabled unless explicitly included.
.It Cm aNULL
The cipher suites offering no authentication.
This is currently the anonymous DH algorithms.
These cipher suites are vulnerable to a
.Qq man in the middle
attack, so their use is normally discouraged.
.It Cm kRSA , RSA
Cipher suites using RSA key exchange.
.It Cm kEDH
Cipher suites using ephemeral DH key agreement.
.It Cm aRSA
Cipher suites using RSA authentication, i.e. the certificates carry RSA keys.
.It Cm aDSS , DSS
Cipher suites using DSS authentication, i.e. the certificates carry DSS keys.
.It Cm TLSv1
TLS v1.0 cipher suites.
.It Cm DH
Cipher suites using DH, including anonymous DH.
.It Cm ADH
Anonymous DH cipher suites.
.It Cm AES
Cipher suites using AES.
.It Cm 3DES
Cipher suites using triple DES.
.It Cm DES
Cipher suites using DES
.Pq not triple DES .
.It Cm RC4
Cipher suites using RC4.
.It Cm CAMELLIA
Cipher suites using Camellia.
.It Cm CHACHA20
Cipher suites using ChaCha20.
.It Cm IDEA
Cipher suites using IDEA.
.It Cm MD5
Cipher suites using MD5.
.It Cm SHA1 , SHA
Cipher suites using SHA1.
.El
.Sh CRL
.nr nS 1
.Nm "openssl crl"
.Op Fl CAfile Ar file
.Op Fl CApath Ar dir
.Op Fl fingerprint
.Op Fl hash
.Op Fl in Ar file
.Op Fl inform Cm der | pem
.Op Fl issuer
.Op Fl lastupdate
.Op Fl nextupdate
.Op Fl noout
.Op Fl out Ar file
.Op Fl outform Cm der | pem
.Op Fl text
.nr nS 0
.Pp
The
.Nm crl
command processes CRL files in DER or PEM format.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl CAfile Ar file
Verify the signature on a CRL by looking up the issuing certificate in
.Ar file .
.It Fl CApath Ar directory
Verify the signature on a CRL by looking up the issuing certificate in
.Ar dir .
This directory must be a standard certificate directory,
i.e. a hash of each subject name (using
.Cm x509 Fl hash )
should be linked to each certificate.
.It Fl fingerprint
Print the CRL fingerprint.
.It Fl hash
Output a hash of the issuer name.
This can be used to look up CRLs in a directory by issuer name.
.It Fl in Ar file
The input file to read from, or standard input if not specified.
.It Fl inform Cm der | pem
The input format.
.It Fl issuer
Output the issuer name.
.It Fl lastupdate
Output the
.Cm lastUpdate
field.
.It Fl nextupdate
Output the
.Cm nextUpdate
field.
.It Fl noout
Do not output the encoded version of the CRL.
.It Fl out Ar file
The output file to write to, or standard output if not specified.
.It Fl outform Cm der | pem
The output format.
.It Fl text
Print the CRL in plain text.
.El
.Sh CRL2PKCS7
.nr nS 1
.Nm "openssl crl2pkcs7"
.Op Fl certfile Ar file
.Op Fl in Ar file
.Op Fl inform Cm der | pem
.Op Fl nocrl
.Op Fl out Ar file
.Op Fl outform Cm der | pem
.nr nS 0
.Pp
The
.Nm crl2pkcs7
command takes an optional CRL and one or more
certificates and converts them into a PKCS#7 degenerate
.Qq certificates only
structure.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl certfile Ar file
Add the certificates in PEM
.Ar file
to the PKCS#7 structure.
This option can be used more than once
to read certificates from multiple files.
.It Fl in Ar file
Read the CRL from
.Ar file ,
or standard input if not specified.
.It Fl inform Cm der | pem
The input format.
.It Fl nocrl
Normally, a CRL is included in the output file.
With this option, no CRL is
included in the output file and a CRL is not read from the input file.
.It Fl out Ar file
Write the PKCS#7 structure to
.Ar file ,
or standard output if not specified.
.It Fl outform Cm der | pem
The output format.
.El
.Sh DGST
.nr nS 1
.Nm "openssl dgst"
.Op Fl cd
.Op Fl binary
.Op Fl Ar digest
.Op Fl hex
.Op Fl hmac Ar key
.Op Fl keyform Cm pem
.Op Fl mac Ar algorithm
.Op Fl macopt Ar nm : Ns Ar v
.Op Fl out Ar file
.Op Fl passin Ar arg
.Op Fl prverify Ar file
.Op Fl sign Ar file
.Op Fl signature Ar file
.Op Fl sigopt Ar nm : Ns Ar v
.Op Fl verify Ar file
.Op Ar
.nr nS 0
.Pp
The digest functions output the message digest of a supplied
.Ar file
or
.Ar files
in hexadecimal form.
They can also be used for digital signing and verification.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl binary
Output the digest or signature in binary form.
.It Fl c
Print the digest in two-digit groups separated by colons.
.It Fl d
Print BIO debugging information.
.It Fl Ar digest
Use the specified message
.Ar digest .
The default is MD5.
The available digests can be displayed using
.Nm openssl
.Cm list-message-digest-commands .
The following are equivalent:
.Nm openssl dgst
.Fl md5
and
.Nm openssl
.Cm md5 .
.It Fl hex
Digest is to be output as a hex dump.
This is the default case for a
.Qq normal
digest as opposed to a digital signature.
.It Fl hmac Ar key
Create a hashed MAC using
.Ar key .
.It Fl keyform Cm pem
Specifies the key format to sign the digest with.
.It Fl mac Ar algorithm
Create a keyed Message Authentication Code (MAC).
The most popular MAC algorithm is HMAC (hash-based MAC),
but there are other MAC algorithms which are not based on hash.
MAC keys and other options should be set via the
.Fl macopt
parameter.
.It Fl macopt Ar nm : Ns Ar v
Passes options to the MAC algorithm, specified by
.Fl mac .
The following options are supported by HMAC:
.Bl -tag -width Ds
.It Cm key : Ns Ar string
Specifies the MAC key as an alphanumeric string
(use if the key contain printable characters only).
String length must conform to any restrictions of the MAC algorithm.
.It Cm hexkey : Ns Ar string
Specifies the MAC key in hexadecimal form (two hex digits per byte).
Key length must conform to any restrictions of the MAC algorithm.
.El
.It Fl out Ar file
The output file to write to,
or standard output if not specified.
.It Fl passin Ar arg
The key password source.
.It Fl prverify Ar file
Verify the signature using the private key in
.Ar file .
The output is either
.Qq Verification OK
or
.Qq Verification Failure .
.It Fl sign Ar file
Digitally sign the digest using the private key in
.Ar file .
.It Fl signature Ar file
The actual signature to verify.
.It Fl sigopt Ar nm : Ns Ar v
Pass options to the signature algorithm during sign or verify operations.
The names and values of these options are algorithm-specific.
.It Fl verify Ar file
Verify the signature using the public key in
.Ar file .
The output is either
.Qq Verification OK
or
.Qq Verification Failure .
.It Ar
File or files to digest.
If no files are specified then standard input is used.
.El
.Sh DHPARAM
.nr nS 1
.Nm "openssl dhparam"
.Op Fl 2 | 5
.Op Fl C
.Op Fl check
.Op Fl dsaparam
.Op Fl in Ar file
.Op Fl inform Cm der | pem
.Op Fl noout
.Op Fl out Ar file
.Op Fl outform Cm der | pem
.Op Fl text
.Op Ar numbits
.nr nS 0
.Pp
The
.Nm dhparam
command is used to manipulate DH parameter files.
Only the older PKCS#3 DH is supported,
not the newer X9.42 DH.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl 2 , 5
The generator to use;
2 is the default.
If present, the input file is ignored and parameters are generated instead.
.It Fl C
Convert the parameters into C code.
The parameters can then be loaded by calling the
.No get_dh Ns Ar numbits
function.
.It Fl check
Check the DH parameters.
.It Fl dsaparam
Read or create DSA parameters,
converted to DH format on output.
Otherwise,
.Qq strong
primes
.Pq such that (p-1)/2 is also prime
will be used for DH parameter generation.
.Pp
DH parameter generation with the
.Fl dsaparam
option is much faster,
and the recommended exponent length is shorter,
which makes DH key exchange more efficient.
Beware that with such DSA-style DH parameters,
a fresh DH key should be created for each use to
avoid small-subgroup attacks that may be possible otherwise.
.It Fl in Ar file
The input file to read from,
or standard input if not specified.
.It Fl inform Cm der | pem
The input format.
.It Fl noout
Do not output the encoded version of the parameters.
.It Fl out Ar file
The output file to write to,
or standard output if not specified.
.It Fl outform Cm der | pem
The output format.
.It Fl text
Print the DH parameters in plain text.
.It Ar numbits
Generate a parameter set of size
.Ar numbits .
It must be the last option.
If not present, a value of 2048 is used.
If this value is present, the input file is ignored and
parameters are generated instead.
.El
.Sh DSA
.nr nS 1
.Nm "openssl dsa"
.Oo
.Fl aes128 | aes192 | aes256 |
.Fl des | des3
.Oc
.Op Fl in Ar file
.Op Fl inform Cm der | pem
.Op Fl modulus
.Op Fl noout
.Op Fl out Ar file
.Op Fl outform Cm der | pem
.Op Fl passin Ar arg
.Op Fl passout Ar arg
.Op Fl pubin
.Op Fl pubout
.Op Fl text
.nr nS 0
.Pp
The
.Nm dsa
command processes DSA keys.
They can be converted between various forms and their components printed out.
.Pp
.Sy Note :
This command uses the traditional
.Nm SSLeay
compatible format for private key encryption:
newer applications should use the more secure PKCS#8 format using the
.Nm pkcs8
command.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Xo
.Fl aes128 | aes192 | aes256 |
.Fl des | des3
.Xc
Encrypt the private key with the AES, DES, or the triple DES
ciphers, respectively, before outputting it.
A pass phrase is prompted for.
If none of these options are specified, the key is written in plain text.
This means that using the
.Nm dsa
utility to read an encrypted key with no encryption option can be used to
remove the pass phrase from a key,
or by setting the encryption options it can be used to add or change
the pass phrase.
These options can only be used with PEM format output files.
.It Fl in Ar file
The input file to read from,
or standard input if not specified.
If the key is encrypted, a pass phrase will be prompted for.
.It Fl inform Cm der | pem
The input format.
.It Fl modulus
Print the value of the public key component of the key.
.It Fl noout
Do not output the encoded version of the key.
.It Fl out Ar file
The output file to write to,
or standard output if not specified.
If any encryption options are set then a pass phrase will be
prompted for.
.It Fl outform Cm der | pem
The output format.
.It Fl passin Ar arg
The key password source.
.It Fl passout Ar arg
The output file password source.
.It Fl pubin
Read in a public key, not a private key.
.It Fl pubout
Output a public key, not a private key.
Automatically set if the input is a public key.
.It Fl text
Print the public/private key in plain text.
.El
.Sh DSAPARAM
.nr nS 1
.Nm "openssl dsaparam"
.Op Fl C
.Op Fl genkey
.Op Fl in Ar file
.Op Fl inform Cm der | pem
.Op Fl noout
.Op Fl out Ar file
.Op Fl outform Cm der | pem
.Op Fl text
.Op Ar numbits
.nr nS 0
.Pp
The
.Nm dsaparam
command is used to manipulate or generate DSA parameter files.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl C
Convert the parameters into C code.
The parameters can then be loaded by calling the
.No get_dsa Ns Ar XXX
function.
.It Fl genkey
Generate a DSA key either using the specified or generated
parameters.
.It Fl in Ar file
The input file to read from,
or standard input if not specified.
If the
.Ar numbits
parameter is included, then this option is ignored.
.It Fl inform Cm der | pem
The input format.
.It Fl noout
Do not output the encoded version of the parameters.
.It Fl out Ar file
The output file to write to,
or standard output if not specified.
.It Fl outform Cm der | pem
The output format.
.It Fl text
Print the DSA parameters in plain text.
.It Ar numbits
Generate a parameter set of size
.Ar numbits .
If this option is included, the input file is ignored.
.El
.Sh EC
.nr nS 1
.Nm "openssl ec"
.Op Fl conv_form Ar arg
.Op Fl des
.Op Fl des3
.Op Fl in Ar file
.Op Fl inform Cm der | pem
.Op Fl noout
.Op Fl out Ar file
.Op Fl outform Cm der | pem
.Op Fl param_enc Ar arg
.Op Fl param_out
.Op Fl passin Ar arg
.Op Fl passout Ar arg
.Op Fl pubin
.Op Fl pubout
.Op Fl text
.nr nS 0
.Pp
The
.Nm ec
command processes EC keys.
They can be converted between various
forms and their components printed out.
.Nm openssl
uses the private key format specified in
.Dq SEC 1: Elliptic Curve Cryptography
.Pq Lk http://www.secg.org/ .
To convert an
EC private key into the PKCS#8 private key format use the
.Nm pkcs8
command.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl conv_form Ar arg
Specify how the points on the elliptic curve are converted
into octet strings.
Possible values are:
.Cm compressed
(the default),
.Cm uncompressed ,
and
.Cm hybrid .
For more information regarding
the point conversion forms see the X9.62 standard.
Note:
Due to patent issues the
.Cm compressed
option is disabled by default for binary curves
and can be enabled by defining the preprocessor macro
.Dv OPENSSL_EC_BIN_PT_COMP
at compile time.
.It Fl des | des3
Encrypt the private key with DES, triple DES, or
any other cipher supported by
.Nm openssl .
A pass phrase is prompted for.
If none of these options is specified the key is written in plain text.
This means that using the
.Nm ec
utility to read in an encrypted key with no
encryption option can be used to remove the pass phrase from a key,
or by setting the encryption options
it can be use to add or change the pass phrase.
These options can only be used with PEM format output files.
.It Fl in Ar file
The input file to read a key from,
or standard input if not specified.
If the key is encrypted a pass phrase will be prompted for.
.It Fl inform Cm der | pem
The input format.
.It Fl noout
Do not output the encoded version of the key.
.It Fl out Ar file
The output filename to write to,
or standard output if not specified.
If any encryption options are set then a pass phrase will be prompted for.
.It Fl outform Cm der | pem
The output format.
.It Fl param_enc Ar arg
Specify how the elliptic curve parameters are encoded.
Possible value are:
.Cm named_curve ,
i.e. the EC parameters are specified by an OID; or
.Cm explicit ,
where the EC parameters are explicitly given
(see RFC 3279 for the definition of the EC parameter structures).
The default value is
.Cm named_curve .
Note: the
.Cm implicitlyCA
alternative,
as specified in RFC 3279,
is currently not implemented.
.It Fl passin Ar arg
The key password source.
.It Fl passout Ar arg
The output file password source.
.It Fl pubin
Read in a public key, not a private key.
.It Fl pubout
Output a public key, not a private key.
Automatically set if the input is a public key.
.It Fl text
Print the public/private key in plain text.
.El
.Sh ECPARAM
.nr nS 1
.Nm "openssl ecparam"
.Op Fl C
.Op Fl check
.Op Fl conv_form Ar arg
.Op Fl genkey
.Op Fl in Ar file
.Op Fl inform Cm der | pem
.Op Fl list_curves
.Op Fl name Ar arg
.Op Fl no_seed
.Op Fl noout
.Op Fl out Ar file
.Op Fl outform Cm der | pem
.Op Fl param_enc Ar arg
.Op Fl text
.nr nS 0
.Pp
The
.Nm ecparam
command is used to manipulate or generate EC parameter files.
.Nm openssl
is not able to generate new groups so
.Nm ecparam
can only create EC parameters from known (named) curves.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl C
Convert the EC parameters into C code.
The parameters can then be loaded by calling the
.No get_ec_group_ Ns Ar XXX
function.
.It Fl check
Validate the elliptic curve parameters.
.It Fl conv_form Ar arg
Specify how the points on the elliptic curve are converted
into octet strings.
Possible values are:
.Cm compressed
(the default),
.Cm uncompressed ,
and
.Cm hybrid .
For more information regarding
the point conversion forms see the X9.62 standard.
Note:
Due to patent issues the
.Cm compressed
option is disabled by default for binary curves
and can be enabled by defining the preprocessor macro
.Dv OPENSSL_EC_BIN_PT_COMP
at compile time.
.It Fl genkey
Generate an EC private key using the specified parameters.
.It Fl in Ar file
The input file to read from,
or standard input if not specified.
.It Fl inform Cm der | pem
The input format.
.It Fl list_curves
Print a list of all
currently implemented EC parameter names and exit.
.It Fl name Ar arg
Use the EC parameters with the specified "short" name.
.It Fl no_seed
Do not include the seed for the parameter generation
in the ECParameters structure (see RFC 3279).
.It Fl noout
Do not output the encoded version of the parameters.
.It Fl out Ar file
The output file to write to,
or standard output if not specified.
.It Fl outform Cm der | pem
The output format.
.It Fl param_enc Ar arg
Specify how the elliptic curve parameters are encoded.
Possible value are:
.Cm named_curve ,
i.e. the EC parameters are specified by an OID, or
.Cm explicit ,
where the EC parameters are explicitly given
(see RFC 3279 for the definition of the EC parameter structures).
The default value is
.Cm named_curve .
Note: the
.Cm implicitlyCA
alternative, as specified in RFC 3279,
is currently not implemented.
.It Fl text
Print the EC parameters in plain text.
.El
.Sh ENC
.nr nS 1
.Nm "openssl enc"
.Fl ciphername
.Op Fl AadePp
.Op Fl base64
.Op Fl bufsize Ar number
.Op Fl debug
.Op Fl in Ar file
.Op Fl iv Ar IV
.Op Fl K Ar key
.Op Fl k Ar password
.Op Fl kfile Ar file
.Op Fl md Ar digest
.Op Fl none
.Op Fl nopad
.Op Fl nosalt
.Op Fl out Ar file
.Op Fl pass Ar arg
.Op Fl S Ar salt
.Op Fl salt
.nr nS 0
.Pp
The symmetric cipher commands allow data to be encrypted or decrypted
using various block and stream ciphers using keys based on passwords
or explicitly provided.
Base64 encoding or decoding can also be performed either by itself
or in addition to the encryption or decryption.
The program can be called either as
.Nm openssl Ar ciphername
or
.Nm openssl enc - Ns Ar ciphername .
.Pp
Some of the ciphers do not have large keys and others have security
implications if not used correctly.
All the block ciphers normally use PKCS#5 padding,
also known as standard block padding.
If padding is disabled, the input data must be a multiple of the cipher
block length.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl A
If the
.Fl a
option is set, then base64 process the data on one line.
.It Fl a , base64
Base64 process the data.
This means that if encryption is taking place, the data is base64-encoded
after encryption.
If decryption is set, the input data is base64-decoded before
being decrypted.
.It Fl bufsize Ar number
Set the buffer size for I/O.
.It Fl d
Decrypt the input data.
.It Fl debug
Debug the BIOs used for I/O.
.It Fl e
Encrypt the input data.
This is the default.
.It Fl in Ar file
The input file to read from,
or standard input if not specified.
.It Fl iv Ar IV
The actual
.Ar IV
.Pq initialisation vector
to use:
this must be represented as a string comprised only of hex digits.
When only the
.Ar key
is specified using the
.Fl K
option,
the IV must explicitly be defined.
When a password is being specified using one of the other options,
the IV is generated from this password.
.It Fl K Ar key
The actual
.Ar key
to use:
this must be represented as a string comprised only of hex digits.
If only the key is specified,
the IV must also be specified using the
.Fl iv
option.
When both a
.Ar key
and a
.Ar password
are specified, the
.Ar key
given with the
.Fl K
option will be used and the IV generated from the password will be taken.
It probably does not make much sense to specify both
.Ar key
and
.Ar password .
.It Fl k Ar password
The
.Ar password
to derive the key from.
Superseded by the
.Fl pass
option.
.It Fl kfile Ar file
Read the password to derive the key from the first line of
.Ar file .
Superseded by the
.Fl pass
option.
.It Fl md Ar digest
Use
.Ar digest
to create a key from a pass phrase.
.Ar digest
may be one of
.Cm md5
or
.Cm sha1 .
.It Fl none
Use NULL cipher (no encryption or decryption of input).
.It Fl nopad
Disable standard block padding.
.It Fl nosalt
Don't use a salt in the key derivation routines.
This option should
.Em NEVER
be used
since it makes it possible to perform efficient dictionary
attacks on the password and to attack stream cipher encrypted data.
.It Fl out Ar file
The output file to write to,
or standard output if not specified.
.It Fl P
Print out the salt, key, and IV used, then immediately exit;
don't do any encryption or decryption.
.It Fl p
Print out the salt, key, and IV used.
.It Fl pass Ar arg
The password source.
.It Fl S Ar salt
The actual
.Ar salt
to use:
this must be represented as a string comprised only of hex digits.
.It Fl salt
Use a salt in the key derivation routines (the default).
When the salt is being used
the first eight bytes of the encrypted data are reserved for the salt:
it is randomly generated when encrypting a file and read from the
encrypted file when it is decrypted.
.El
.Sh ERRSTR
.Nm openssl errstr
.Op Fl stats
.Ar errno ...
.Pp
The
.Nm errstr
command performs error number to error string conversion,
generating a human-readable string representing the error code
.Ar errno .
The string is obtained through the
.Xr ERR_error_string_n 3
function and has the following format:
.Pp
.Dl error:[error code]:[library name]:[function name]:[reason string]
.Pp
.Bq error code
is an 8-digit hexadecimal number.
The remaining fields
.Bq library name ,
.Bq function name ,
and
.Bq reason string
are all ASCII text.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl stats
Print debugging statistics about various aspects of the hash table.
.El
.Sh GENDSA
.nr nS 1
.Nm "openssl gendsa"
.Oo
.Fl aes128 | aes192 | aes256 |
.Fl des | des3
.Oc
.Op Fl out Ar file
.Op Ar paramfile
.nr nS 0
.Pp
The
.Nm gendsa
command generates a DSA private key from a DSA parameter file
(typically generated by the
.Nm openssl dsaparam
command).
DSA key generation is little more than random number generation so it is
much quicker than,
for example,
RSA key generation.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Xo
.Fl aes128 | aes192 | aes256 |
.Fl des | des3
.Xc
Encrypt the private key with the AES, DES,
or the triple DES ciphers, respectively, before outputting it.
A pass phrase is prompted for.
If none of these options are specified, no encryption is used.
.It Fl out Ar file
The output file to write to,
or standard output if not specified.
.It Ar paramfile
Specify the DSA parameter file to use.
The parameters in this file determine the size of the private key.
.El
.Sh GENPKEY
.nr nS 1
.Nm "openssl genpkey"
.Op Fl algorithm Ar alg
.Op Ar cipher
.Op Fl genparam
.Op Fl out Ar file
.Op Fl outform Cm der | pem
.Op Fl paramfile Ar file
.Op Fl pass Ar arg
.Op Fl pkeyopt Ar opt : Ns Ar value
.Op Fl text
.nr nS 0
.Pp
The
.Nm genpkey
command generates private keys.
The use of this
program is encouraged over the algorithm specific utilities
because additional algorithm options can be used.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl algorithm Ar alg
The public key algorithm to use,
such as RSA, DSA, or DH.
This option must precede any
.Fl pkeyopt
options.
The options
.Fl paramfile
and
.Fl algorithm
are mutually exclusive.
.It Ar cipher
Encrypt the private key with the supplied cipher.
Any algorithm name accepted by
.Xr EVP_get_cipherbyname 3
is acceptable.
.It Fl genparam
Generate a set of parameters instead of a private key.
This option must precede any
.Fl algorithm ,
.Fl paramfile ,
or
.Fl pkeyopt
options.
.It Fl out Ar file
The output file to write to,
or standard output if not specified.
.It Fl outform Cm der | pem
The output format.
.It Fl paramfile Ar file
Some public key algorithms generate a private key based on a set of parameters,
which can be supplied using this option.
If this option is used the public key
algorithm used is determined by the parameters.
This option must precede any
.Fl pkeyopt
options.
The options
.Fl paramfile
and
.Fl algorithm
are mutually exclusive.
.It Fl pass Ar arg
The output file password source.
.It Fl pkeyopt Ar opt : Ns Ar value
Set the public key algorithm option
.Ar opt
to
.Ar value ,
as follows:
.Bl -tag -width Ds -offset indent
.It rsa_keygen_bits : Ns Ar numbits
(RSA)
The number of bits in the generated key.
The default is 2048.
.It rsa_keygen_pubexp : Ns Ar value
(RSA)
The RSA public exponent value.
This can be a large decimal or hexadecimal value if preceded by 0x.
The default is 65537.
.It dsa_paramgen_bits : Ns Ar numbits
(DSA)
The number of bits in the generated parameters.
The default is 1024.
.It dh_paramgen_prime_len : Ns Ar numbits
(DH)
The number of bits in the prime parameter
.Ar p .
.It dh_paramgen_generator : Ns Ar value
(DH)
The value to use for the generator
.Ar g .
.It ec_paramgen_curve : Ns Ar curve
(EC)
The EC curve to use.
.El
.It Fl text
Print the private/public key in plain text.
.El
.Sh GENRSA
.nr nS 1
.Nm "openssl genrsa"
.Op Fl 3 | f4
.Op Fl aes128 | aes192 | aes256 | des | des3
.Op Fl out Ar file
.Op Fl passout Ar arg
.Op Ar numbits
.nr nS 0
.Pp
The
.Nm genrsa
command generates an RSA private key,
which essentially involves the generation of two prime numbers.
When generating the key,
various symbols will be output to indicate the progress of the generation.
A
.Sq \&.
represents each number which has passed an initial sieve test;
.Sq +
means a number has passed a single round of the Miller-Rabin primality test.
A newline means that the number has passed all the prime tests
(the actual number depends on the key size).
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl 3 | f4
The public exponent to use, either 3 or 65537.
The default is 65537.
.It Fl aes128 | aes192 | aes256 | des | des3
Encrypt the private key with the AES, DES,
or the triple DES ciphers, respectively, before outputting it.
If none of these options are specified, no encryption is used.
If encryption is used, a pass phrase is prompted for,
if it is not supplied via the
.Fl passout
option.
.It Fl out Ar file
The output file to write to,
or standard output if not specified.
.It Fl passout Ar arg
The output file password source.
.It Ar numbits
The size of the private key to generate in bits.
This must be the last option specified.
The default is 2048.
.El
.Sh NSEQ
.Nm openssl nseq
.Op Fl in Ar file
.Op Fl out Ar file
.Op Fl toseq
.Pp
The
.Nm nseq
command takes a file containing a Netscape certificate sequence
(an alternative to the standard PKCS#7 format)
and prints out the certificates contained in it,
or takes a file of certificates
and converts it into a Netscape certificate sequence.
.Pp
The PEM-encoded form uses the same headers and footers as a certificate:
.Bd -unfilled -offset indent
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----
.Ed
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl in Ar file
The input file to read from,
or standard input if not specified.
.It Fl out Ar file
The output file to write to,
or standard output if not specified.
.It Fl toseq
Normally, a Netscape certificate sequence will be input and the output
is the certificates contained in it.
With the
.Fl toseq
option the situation is reversed:
a Netscape certificate sequence is created from a file of certificates.
.El
.Sh OCSP
.nr nS 1
.Nm "openssl ocsp"
.Op Fl CA Ar file
.Op Fl CAfile Ar file
.Op Fl CApath Ar directory
.Op Fl cert Ar file
.Op Fl dgst Ar alg
.Op Fl host Ar hostname : Ns Ar port
.Op Fl index Ar indexfile
.Op Fl issuer Ar file
.Op Fl ndays Ar days
.Op Fl nmin Ar minutes
.Op Fl no_cert_checks
.Op Fl no_cert_verify
.Op Fl no_certs
.Op Fl no_chain
.Op Fl no_intern
.Op Fl no_nonce
.Op Fl no_signature_verify
.Op Fl nonce
.Op Fl noverify
.Op Fl nrequest Ar number
.Op Fl out Ar file
.Op Fl path Ar path
.Op Fl port Ar portnum
.Op Fl req_text
.Op Fl reqin Ar file
.Op Fl reqout Ar file
.Op Fl resp_key_id
.Op Fl resp_no_certs
.Op Fl resp_text
.Op Fl respin Ar file
.Op Fl respout Ar file
.Op Fl rkey Ar file
.Op Fl rother Ar file
.Op Fl rsigner Ar file
.Op Fl serial Ar number
.Op Fl sign_other Ar file
.Op Fl signer Ar file
.Op Fl signkey Ar file
.Op Fl status_age Ar age
.Op Fl text
.Op Fl trust_other
.Op Fl url Ar responder_url
.Op Fl VAfile Ar file
.Op Fl validity_period Ar nsec
.Op Fl verify_other Ar file
.nr nS 0
.Pp
The Online Certificate Status Protocol (OCSP)
enables applications to determine the (revocation) state
of an identified certificate (RFC 2560).
.Pp
The
.Nm ocsp
command performs many common OCSP tasks.
It can be used to print out requests and responses,
create requests and send queries to an OCSP responder,
and behave like a mini OCSP server itself.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl CAfile Ar file , Fl CApath Ar directory
A file or path containing trusted CA certificates,
used to verify the signature on the OCSP response.
.It Fl cert Ar file
Add the certificate
.Ar file
to the request.
The issuer certificate is taken from the previous
.Fl issuer
option, or an error occurs if no issuer certificate is specified.
.It Fl dgst Ar alg
Use the digest algorithm
.Ar alg
for certificate identification in the OCSP request.
By default SHA-1 is used.
.It Xo
.Fl host Ar hostname : Ns Ar port ,
.Fl path Ar path
.Xc
Send
the OCSP request to
.Ar hostname
on
.Ar port .
.Fl path
specifies the HTTP path name to use, or
.Pa /
by default.
.It Fl issuer Ar file
The current issuer certificate,
in PEM format.
Can be used multiple times
and must come before any
.Fl cert
options.
.It Fl no_cert_checks
Don't perform any additional checks on the OCSP response signer's certificate.
That is, do not make any checks to see if the signer's certificate is
authorised to provide the necessary status information:
as a result this option should only be used for testing purposes.
.It Fl no_cert_verify
Don't verify the OCSP response signer's certificate at all.
Since this option allows the OCSP response to be signed by any certificate,
it should only be used for testing purposes.
.It Fl no_certs
Don't include any certificates in the signed request.
.It Fl no_chain
Do not use certificates in the response as additional untrusted CA
certificates.
.It Fl no_intern
Ignore certificates contained in the OCSP response
when searching for the signer's certificate.
The signer's certificate must be specified with either the
.Fl verify_other
or
.Fl VAfile
options.
.It Fl no_signature_verify
Don't check the signature on the OCSP response.
Since this option tolerates invalid signatures on OCSP responses,
it will normally only be used for testing purposes.
.It Fl nonce , no_nonce
Add an OCSP nonce extension to a request,
or disable an OCSP nonce addition.
Normally, if an OCSP request is input using the
.Fl respin
option no nonce is added:
using the
.Fl nonce
option will force the addition of a nonce.
If an OCSP request is being created (using the
.Fl cert
and
.Fl serial
options)
a nonce is automatically added; specifying
.Fl no_nonce
overrides this.
.It Fl noverify
Don't attempt to verify the OCSP response signature or the nonce values.
This is normally only be used for debugging
since it disables all verification of the responder's certificate.
.It Fl out Ar file
Specify the output file to write to,
or standard output if not specified.
.It Fl req_text , resp_text , text
Print out the text form of the OCSP request, response, or both, respectively.
.It Fl reqin Ar file , Fl respin Ar file
Read an OCSP request or response file from
.Ar file .
These options are ignored
if an OCSP request or response creation is implied by other options
(for example with the
.Fl serial , cert ,
and
.Fl host
options).
.It Fl reqout Ar file , Fl respout Ar file
Write out the DER-encoded certificate request or response to
.Ar file .
.It Fl serial Ar num
Same as the
.Fl cert
option except the certificate with serial number
.Ar num
is added to the request.
The serial number is interpreted as a decimal integer unless preceded by
.Sq 0x .
Negative integers can also be specified
by preceding the value with a minus sign.
.It Fl sign_other Ar file
Additional certificates to include in the signed request.
.It Fl signer Ar file , Fl signkey Ar file
Sign the OCSP request using the certificate specified in the
.Fl signer
option and the private key specified by the
.Fl signkey
option.
If the
.Fl signkey
option is not present, then the private key is read from the same file
as the certificate.
If neither option is specified, the OCSP request is not signed.
.It Fl trust_other
The certificates specified by the
.Fl verify_other
option should be explicitly trusted and no additional checks will be
performed on them.
This is useful when the complete responder certificate chain is not available
or trusting a root CA is not appropriate.
.It Fl url Ar responder_url
Specify the responder URL.
Both HTTP and HTTPS
.Pq SSL/TLS
URLs can be specified.
.It Fl VAfile Ar file
A file containing explicitly trusted responder certificates.
Equivalent to the
.Fl verify_other
and
.Fl trust_other
options.
.It Fl validity_period Ar nsec , Fl status_age Ar age
The range of times, in seconds, which will be tolerated in an OCSP response.
Each certificate status response includes a notBefore time
and an optional notAfter time.
The current time should fall between these two values,
but the interval between the two times may be only a few seconds.
In practice the OCSP responder and clients' clocks may not be precisely
synchronised and so such a check may fail.
To avoid this the
.Fl validity_period
option can be used to specify an acceptable error range in seconds,
the default value being 5 minutes.
.Pp
If the notAfter time is omitted from a response,
it means that new status information is immediately available.
In this case the age of the notBefore field is checked
to see it is not older than
.Ar age
seconds old.
By default, this additional check is not performed.
.It Fl verify_other Ar file
A file containing additional certificates to search
when attempting to locate the OCSP response signing certificate.
Some responders omit the actual signer's certificate from the response,
so this can be used to supply the necessary certificate.
.El
.Pp
The options for the OCSP server are as follows:
.Bl -tag -width "XXXX"
.It Fl CA Ar file
CA certificate corresponding to the revocation information in
.Ar indexfile .
.It Fl index Ar indexfile
.Ar indexfile
is a text index file in ca format
containing certificate revocation information.
.Pp
If this option is specified,
.Nm ocsp
is in responder mode, otherwise it is in client mode.
The requests the responder processes can be either specified on
the command line (using the
.Fl issuer
and
.Fl serial
options), supplied in a file (using the
.Fl respin
option), or via external OCSP clients (if
.Ar port
or
.Ar url
is specified).
.Pp
If this option is present, then the
.Fl CA
and
.Fl rsigner
options must also be present.
.It Fl nmin Ar minutes , Fl ndays Ar days
Number of
.Ar minutes
or
.Ar days
when fresh revocation information is available:
used in the nextUpdate field.
If neither option is present,
the nextUpdate field is omitted,
meaning fresh revocation information is immediately available.
.It Fl nrequest Ar number
Exit after receiving
.Ar number
requests (the default is unlimited).
.It Fl port Ar portnum
Port to listen for OCSP requests on.
May also be specified using the
.Fl url
option.
.It Fl resp_key_id
Identify the signer certificate using the key ID;
the default is to use the subject name.
.It Fl resp_no_certs
Don't include any certificates in the OCSP response.
.It Fl rkey Ar file
The private key to sign OCSP responses with;
if not present, the file specified in the
.Fl rsigner
option is used.
.It Fl rother Ar file
Additional certificates to include in the OCSP response.
.It Fl rsigner Ar file
The certificate to sign OCSP responses with.
.El
.Pp
Initially the OCSP responder certificate is located and the signature on
the OCSP request checked using the responder certificate's public key.
Then a normal certificate verify is performed on the OCSP responder certificate
building up a certificate chain in the process.
The locations of the trusted certificates used to build the chain can be
specified by the
.Fl CAfile
and
.Fl CApath
options or they will be looked for in the standard
.Nm openssl
certificates directory.
.Pp
If the initial verify fails, the OCSP verify process halts with an error.
Otherwise the issuing CA certificate in the request is compared to the OCSP
responder certificate: if there is a match then the OCSP verify succeeds.
.Pp
Otherwise the OCSP responder certificate's CA is checked against the issuing
CA certificate in the request.
If there is a match and the OCSPSigning extended key usage is present
in the OCSP responder certificate, then the OCSP verify succeeds.
.Pp
Otherwise the root CA of the OCSP responder's CA is checked to see if it
is trusted for OCSP signing.
If it is, the OCSP verify succeeds.
.Pp
If none of these checks is successful, the OCSP verify fails.
What this effectively means is that if the OCSP responder certificate is
authorised directly by the CA it is issuing revocation information about
(and it is correctly configured),
then verification will succeed.
.Pp
If the OCSP responder is a global responder,
which can give details about multiple CAs
and has its own separate certificate chain,
then its root CA can be trusted for OCSP signing.
For example:
.Bd -literal -offset indent
$ openssl x509 -in ocspCA.pem -addtrust OCSPSigning \e
	-out trustedCA.pem
.Ed
.Pp
Alternatively, the responder certificate itself can be explicitly trusted
with the
.Fl VAfile
option.
.Sh PASSWD
.nr nS 1
.Nm "openssl passwd"
.Op Fl 1 | apr1 | crypt
.Op Fl in Ar file
.Op Fl noverify
.Op Fl quiet
.Op Fl reverse
.Op Fl salt Ar string
.Op Fl stdin
.Op Fl table
.Op Ar password
.nr nS 0
.Pp
The
.Nm passwd
command computes the hash of a password.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl 1
Use the MD5 based
.Bx
password algorithm
.Qq 1 .
.It Fl apr1
Use the
.Qq apr1
algorithm
.Po
Apache variant of the
.Bx
algorithm
.Pc .
.It Fl crypt
Use the
.Qq crypt
algorithm (the default).
.It Fl in Ar file
Read passwords from
.Ar file .
.It Fl noverify
Don't verify when reading a password from the terminal.
.It Fl quiet
Don't output warnings when passwords given on the command line are truncated.
.It Fl reverse
Switch table columns.
This only makes sense in conjunction with the
.Fl table
option.
.It Fl salt Ar string
Use the salt specified by
.Ar string .
When reading a password from the terminal, this implies
.Fl noverify .
.It Fl stdin
Read passwords from standard input.
.It Fl table
In the output list, prepend the cleartext password and a TAB character
to each password hash.
.El
.Sh PKCS7
.nr nS 1
.Nm "openssl pkcs7"
.Op Fl in Ar file
.Op Fl inform Cm der | pem
.Op Fl noout
.Op Fl out Ar file
.Op Fl outform Cm der | pem
.Op Fl print_certs
.Op Fl text
.nr nS 0
.Pp
The
.Nm pkcs7
command processes PKCS#7 files in DER or PEM format.
The PKCS#7 routines only understand PKCS#7 v 1.5 as specified in RFC 2315.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl in Ar file
The input file to read from,
or standard input if not specified.
.It Fl inform Cm der | pem
The input format.
.It Fl noout
Don't output the encoded version of the PKCS#7 structure
(or certificates if
.Fl print_certs
is set).
.It Fl out Ar file
The output to write to,
or standard output if not specified.
.It Fl outform Cm der | pem
The output format.
.It Fl print_certs
Print any certificates or CRLs contained in the file,
preceded by their subject and issuer names in a one-line format.
.It Fl text
Print certificate details in full rather than just subject and issuer names.
.El
.Sh PKCS8
.nr nS 1
.Nm "openssl pkcs8"
.Op Fl embed
.Op Fl in Ar file
.Op Fl inform Cm der | pem
.Op Fl nocrypt
.Op Fl noiter
.Op Fl nooct
.Op Fl nsdb
.Op Fl out Ar file
.Op Fl outform Cm der | pem
.Op Fl passin Ar arg
.Op Fl passout Ar arg
.Op Fl topk8
.Op Fl v1 Ar alg
.Op Fl v2 Ar alg
.nr nS 0
.Pp
The
.Nm pkcs8
command processes private keys
(both encrypted and unencrypted)
in PKCS#8 format
with a variety of PKCS#5 (v1.5 and v2.0) and PKCS#12 algorithms.
The default encryption is only 56 bits;
keys encrypted using PKCS#5 v2.0 algorithms and high iteration counts
are more secure.
.Pp
The encrypted form of a PEM-encoded PKCS#8 file uses the following
headers and footers:
.Bd -unfilled -offset indent
-----BEGIN ENCRYPTED PRIVATE KEY-----
-----END ENCRYPTED PRIVATE KEY-----
.Ed
.Pp
The unencrypted form uses:
.Bd -unfilled -offset indent
-----BEGIN PRIVATE KEY-----
-----END PRIVATE KEY-----
.Ed
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl embed
Generate DSA keys in a broken format.
The DSA parameters are embedded inside the PrivateKey structure.
In this form the OCTET STRING contains an ASN1 SEQUENCE consisting of
two structures:
a SEQUENCE containing the parameters and an ASN1 INTEGER containing
the private key.
.It Fl in Ar file
The input file to read from,
or standard input if not specified.
If the key is encrypted, a pass phrase will be prompted for.
.It Fl inform Cm der | pem
The input format.
.It Fl nocrypt
Generate an unencrypted PrivateKeyInfo structure.
This option does not encrypt private keys at all
and should only be used when absolutely necessary.
.It Fl noiter
Use an iteration count of 1.
See the
.Sx PKCS12
section below for a detailed explanation of this option.
.It Fl nooct
Generate RSA private keys in a broken format that some software uses.
Specifically the private key should be enclosed in an OCTET STRING,
but some software just includes the structure itself without the
surrounding OCTET STRING.
.It Fl nsdb
Generate DSA keys in a broken format compatible with Netscape
private key databases.
The PrivateKey contains a SEQUENCE
consisting of the public and private keys, respectively.
.It Fl out Ar file
The output file to write to,
or standard output if none is specified.
If any encryption options are set, a pass phrase will be prompted for.
.It Fl outform Cm der | pem
The output format.
.It Fl passin Ar arg
The key password source.
.It Fl passout Ar arg
The output file password source.
.It Fl topk8
Read a traditional format private key and write a PKCS#8 format key.
.It Fl v1 Ar alg
Specify a PKCS#5 v1.5 or PKCS#12 algorithm to use.
.Pp
.Bl -tag -width "XXXX" -compact
.It PBE-MD5-DES
56-bit DES.
.It PBE-SHA1-RC2-64 | PBE-MD5-RC2-64 | PBE-SHA1-DES
64-bit RC2 or 56-bit DES.
.It PBE-SHA1-RC4-128 | PBE-SHA1-RC4-40 | PBE-SHA1-3DES
.It PBE-SHA1-2DES | PBE-SHA1-RC2-128 | PBE-SHA1-RC2-40
PKCS#12 password-based encryption algorithm,
which allow strong encryption algorithms like triple DES or 128-bit RC2.
.El
.It Fl v2 Ar alg
Use PKCS#5 v2.0 algorithms.
Supports algorithms such as 168-bit triple DES or 128-bit RC2,
however not many implementations support PKCS#5 v2.0 yet
(if using private keys with
.Nm openssl
this doesn't matter).
.Pp
.Ar alg
is the encryption algorithm to use;
valid values include des, des3, and rc2.
It is recommended that des3 is used.
.El
.Sh PKCS12
.nr nS 1
.Nm "openssl pkcs12"
.Op Fl aes128 | aes192 | aes256 | des | des3
.Op Fl cacerts
.Op Fl CAfile Ar file
.Op Fl caname Ar name
.Op Fl CApath Ar directory
.Op Fl certfile Ar file
.Op Fl certpbe Ar alg
.Op Fl chain
.Op Fl clcerts
.Op Fl CSP Ar name
.Op Fl descert
.Op Fl export
.Op Fl in Ar file
.Op Fl info
.Op Fl inkey Ar file
.Op Fl keyex
.Op Fl keypbe Ar alg
.Op Fl keysig
.Op Fl macalg Ar alg
.Op Fl maciter
.Op Fl name Ar name
.Op Fl nocerts
.Op Fl nodes
.Op Fl noiter
.Op Fl nokeys
.Op Fl nomac
.Op Fl nomaciter
.Op Fl nomacver
.Op Fl noout
.Op Fl out Ar file
.Op Fl passin Ar arg
.Op Fl passout Ar arg
.Op Fl twopass
.nr nS 0
.Pp
The
.Nm pkcs12
command allows PKCS#12 files
.Pq sometimes referred to as PFX files
to be created and parsed.
By default, a PKCS#12 file is parsed;
a PKCS#12 file can be created by using the
.Fl export
option.
.Pp
The options for parsing a PKCS12 file are as follows:
.Bl -tag -width "XXXX"
.It Fl aes128 | aes192 | aes256 | des | des3
Encrypt private keys
using AES, DES, or triple DES, respectively.
The default is triple DES.
.It Fl cacerts
Only output CA certificates
.Pq not client certificates .
.It Fl clcerts
Only output client certificates
.Pq not CA certificates .
.It Fl in Ar file
The input file to read from,
or standard input if not specified.
.It Fl info
Output additional information about the PKCS#12 file structure,
algorithms used, and iteration counts.
.It Fl nocerts
Do not output certificates.
.It Fl nodes
Do not encrypt private keys.
.It Fl nokeys
Do not output private keys.
.It Fl nomacver
Do not attempt to verify the integrity MAC before reading the file.
.It Fl noout
Do not output the keys and certificates to the output file
version of the PKCS#12 file.
.It Fl out Ar file
The output file to write to,
or standard output if not specified.
.It Fl passin Ar arg
The key password source.
.It Fl passout Ar arg
The output file password source.
.It Fl twopass
Prompt for separate integrity and encryption passwords: most software
always assumes these are the same so this option will render such
PKCS#12 files unreadable.
.El
.Pp
The options for PKCS12 file creation are as follows:
.Bl -tag -width "XXXX"
.It Fl CAfile Ar file
CA storage as a file.
.It Fl CApath Ar directory
CA storage as a directory.
The directory must be a standard certificate directory:
that is, a hash of each subject name (using
.Nm x509 Fl hash )
should be linked to each certificate.
.It Fl caname Ar name
Specify the
.Qq friendly name
for other certificates.
May be used multiple times to specify names for all certificates
in the order they appear.
.It Fl certfile Ar file
A file to read additional certificates from.
.It Fl certpbe Ar alg , Fl keypbe Ar alg
Specify the algorithm used to encrypt the private key and
certificates to be selected.
Any PKCS#5 v1.5 or PKCS#12 PBE algorithm name can be used.
If a cipher name
(as output by the
.Cm list-cipher-algorithms
command) is specified then it
is used with PKCS#5 v2.0.
For interoperability reasons it is advisable to only use PKCS#12 algorithms.
.It Fl chain
Include the entire certificate chain of the user certificate.
The standard CA store is used for this search.
If the search fails, it is considered a fatal error.
.It Fl CSP Ar name
Write
.Ar name
as a Microsoft CSP name.
.It Fl descert
Encrypt the certificate using triple DES; this may render the PKCS#12
file unreadable by some
.Qq export grade
software.
By default, the private key is encrypted using triple DES and the
certificate using 40-bit RC2.
.It Fl export
Create a PKCS#12 file (rather than parsing one).
.It Fl in Ar file
The input file to read from,
or standard input if not specified,
in PEM format.
The order doesn't matter but one private key and its corresponding
certificate should be present.
If additional certificates are present, they will also be included
in the PKCS#12 file.
.It Fl inkey Ar file
File to read a private key from.
If not present, a private key must be present in the input file.
.It Fl keyex | keysig
Specify whether the private key is to be used for key exchange or just signing.
Normally,
.Qq export grade
software will only allow 512-bit RSA keys to be
used for encryption purposes, but arbitrary length keys for signing.
The
.Fl keysig
option marks the key for signing only.
Signing only keys can be used for S/MIME signing, authenticode
(ActiveX control signing)
and SSL client authentication.
.It Fl macalg Ar alg
Specify the MAC digest algorithm.
The default is SHA1.
.It Fl maciter
Included for compatibility only:
it used to be needed to use MAC iterations counts
but they are now used by default.
.It Fl name Ar name
Specify the
.Qq friendly name
for the certificate and private key.
This name is typically displayed in list boxes by software importing the file.
.It Fl nomac
Don't attempt to provide the MAC integrity.
.It Fl nomaciter , noiter
Affect the iteration counts on the MAC and key algorithms.
Unless you wish to produce files compatible with MSIE 4.0, you should leave
these options alone.
.Pp
To discourage attacks by using large dictionaries of common passwords,
the algorithm that derives keys from passwords can have an iteration count
applied to it: this causes a certain part of the algorithm to be repeated
and slows it down.
The MAC is used to check the file integrity but since it will normally
have the same password as the keys and certificates it could also be attacked.
By default, both MAC and encryption iteration counts are set to 2048;
using these options the MAC and encryption iteration counts can be set to 1.
Since this reduces the file security you should not use these options
unless you really have to.
Most software supports both MAC and key iteration counts.
MSIE 4.0 doesn't support MAC iteration counts, so it needs the
.Fl nomaciter
option.
.It Fl out Ar file
The output file to write to,
or standard output if not specified.
.It Fl passin Ar arg
The key password source.
.It Fl passout Ar arg
The output file password source.
.El
.Sh PKEY
.nr nS 1
.Nm "openssl pkey"
.Op Ar cipher
.Op Fl in Ar file
.Op Fl inform Cm der | pem
.Op Fl noout
.Op Fl out Ar file
.Op Fl outform Cm der | pem
.Op Fl passin Ar arg
.Op Fl passout Ar arg
.Op Fl pubin
.Op Fl pubout
.Op Fl text
.Op Fl text_pub
.nr nS 0
.Pp
The
.Nm pkey
command processes public or private keys.
They can be converted between various forms
and their components printed out.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Ar cipher
Encrypt the private key with the specified cipher.
Any algorithm name accepted by
.Xr EVP_get_cipherbyname 3
is acceptable, such as
.Cm des3 .
.It Fl in Ar file
The input file to read from,
or standard input if not specified.
If the key is encrypted a pass phrase will be prompted for.
.It Fl inform Cm der | pem
The input format.
.It Fl noout
Do not output the encoded version of the key.
.It Fl out Ar file
The output file to write to,
or standard output if not specified.
If any encryption options are set then a pass phrase
will be prompted for.
.It Fl outform Cm der | pem
The output format.
.It Fl passin Ar arg
The key password source.
.It Fl passout Ar arg
The output file password source.
.It Fl pubin
Read in a public key, not a private key.
.It Fl pubout
Output a public key, not a private key.
Automatically set if the input is a public key.
.It Fl text
Print the public/private key in plain text.
.It Fl text_pub
Print out only public key components
even if a private key is being processed.
.El
.Sh PKEYPARAM
.Cm openssl pkeyparam
.Op Fl in Ar file
.Op Fl noout
.Op Fl out Ar file
.Op Fl text
.Pp
The
.Nm pkeyparam
command processes public or private keys.
The key type is determined by the PEM headers.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl in Ar file
The input file to read from,
or standard input if not specified.
.It Fl noout
Do not output the encoded version of the parameters.
.It Fl out Ar file
The output file to write to,
or standard output if not specified.
.It Fl text
Print the parameters in plain text.
.El
.Sh PKEYUTL
.nr nS 1
.Nm "openssl pkeyutl"
.Op Fl asn1parse
.Op Fl certin
.Op Fl decrypt
.Op Fl derive
.Op Fl encrypt
.Op Fl hexdump
.Op Fl in Ar file
.Op Fl inkey Ar file
.Op Fl keyform Cm der | pem
.Op Fl out Ar file
.Op Fl passin Ar arg
.Op Fl peerform Cm der | pem
.Op Fl peerkey Ar file
.Op Fl pkeyopt Ar opt : Ns Ar value
.Op Fl pubin
.Op Fl rev
.Op Fl sigfile Ar file
.Op Fl sign
.Op Fl verify
.Op Fl verifyrecover
.nr nS 0
.Pp
The
.Nm pkeyutl
command can be used to perform public key operations using
any supported algorithm.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl asn1parse
ASN1parse the output data.
This is useful when combined with the
.Fl verifyrecover
option when an ASN1 structure is signed.
.It Fl certin
The input is a certificate containing a public key.
.It Fl decrypt
Decrypt the input data using a private key.
.It Fl derive
Derive a shared secret using the peer key.
.It Fl encrypt
Encrypt the input data using a public key.
.It Fl hexdump
Hex dump the output data.
.It Fl in Ar file
The input file to read from,
or standard input if not specified.
.It Fl inkey Ar file
The input key file.
By default it should be a private key.
.It Fl keyform Cm der | pem
The key format.
.It Fl out Ar file
The output file to write to,
or standard output if not specified.
.It Fl passin Ar arg
The key password source.
.It Fl peerform Cm der | pem
The peer key format.
.It Fl peerkey Ar file
The peer key file, used by key derivation (agreement) operations.
.It Fl pkeyopt Ar opt : Ns Ar value
Set the public key algorithm option
.Ar opt
to
.Ar value .
Unless otherwise mentioned, all algorithms support the format
.Ar digest : Ns Ar alg ,
which specifies the digest to use
for sign, verify, and verifyrecover operations.
The value
.Ar alg
should represent a digest name as used in the
.Xr EVP_get_digestbyname 3
function.
.Pp
The RSA algorithm supports the
encrypt, decrypt, sign, verify, and verifyrecover operations in general.
Some padding modes only support some of these
operations however.
.Bl -tag -width Ds
.It rsa_padding_mode : Ns Ar mode
This sets the RSA padding mode.
Acceptable values for
.Ar mode
are
.Cm pkcs1
for PKCS#1 padding;
.Cm none
for no padding;
.Cm oaep
for OAEP mode;
.Cm x931
for X9.31 mode;
and
.Cm pss
for PSS.
.Pp
In PKCS#1 padding if the message digest is not set then the supplied data is
signed or verified directly instead of using a DigestInfo structure.
If a digest is set then a DigestInfo
structure is used and its length
must correspond to the digest type.
For oeap mode only encryption and decryption is supported.
For x931 if the digest type is set it is used to format the block data;
otherwise the first byte is used to specify the X9.31 digest ID.
Sign, verify, and verifyrecover can be performed in this mode.
For pss mode only sign and verify are supported and the digest type must be
specified.
.It rsa_pss_saltlen : Ns Ar len
For pss
mode only this option specifies the salt length.
Two special values are supported:
-1 sets the salt length to the digest length.
When signing -2 sets the salt length to the maximum permissible value.
When verifying -2 causes the salt length to be automatically determined
based on the PSS block structure.
.El
.Pp
The DSA algorithm supports the sign and verify operations.
Currently there are no additional options other than
.Ar digest .
Only the SHA1 digest can be used and this digest is assumed by default.
.Pp
The DH algorithm supports the derive operation
and no additional options.
.Pp
The EC algorithm supports the sign, verify, and derive operations.
The sign and verify operations use ECDSA and derive uses ECDH.
Currently there are no additional options other than
.Ar digest .
Only the SHA1 digest can be used and this digest is assumed by default.
.It Fl pubin
The input file is a public key.
.It Fl rev
Reverse the order of the input buffer.
.It Fl sigfile Ar file
Signature file (verify operation only).
.It Fl sign
Sign the input data and output the signed result.
This requires a private key.
.It Fl verify
Verify the input data against the signature file and indicate if the
verification succeeded or failed.
.It Fl verifyrecover
Verify the input data and output the recovered data.
.El
.Sh PRIME
.Cm openssl prime
.Op Fl bits Ar n
.Op Fl checks Ar n
.Op Fl generate
.Op Fl hex
.Op Fl safe
.Ar p
.Pp
The
.Nm prime
command is used to generate prime numbers,
or to check numbers for primality.
Results are probabilistic:
they have an exceedingly high likelihood of being correct,
but are not guaranteed.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl bits Ar n
Specify the number of bits in the generated prime number.
Must be used in conjunction with
.Fl generate .
.It Fl checks Ar n
Perform a Miller-Rabin probabilistic primality test with
.Ar n
iterations.
The default is 20.
.It Fl generate
Generate a pseudo-random prime number.
Must be used in conjunction with
.Fl bits .
.It Fl hex
Output in hex format.
.It Fl safe
Generate only
.Qq safe
prime numbers
(i.e. a prime p so that (p-1)/2 is also prime).
.It Ar p
Test if number
.Ar p
is prime.
.El
.Sh RAND
.nr nS 1
.Nm "openssl rand"
.Op Fl base64
.Op Fl hex
.Op Fl out Ar file
.Ar num
.nr nS 0
.Pp
The
.Nm rand
command outputs
.Ar num
pseudo-random bytes.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl base64
Perform
.Em base64
encoding on the output.
.It Fl hex
Specify hexadecimal output.
.It Fl out Ar file
The output file to write to,
or standard output if not specified.
.El
.Sh REQ
.nr nS 1
.Nm "openssl req"
.Op Fl asn1-kludge
.Op Fl batch
.Op Fl config Ar file
.Op Fl days Ar n
.Op Fl extensions Ar section
.Op Fl in Ar file
.Op Fl inform Cm der | pem
.Op Fl key Ar keyfile
.Op Fl keyform Cm der | pem
.Op Fl keyout Ar file
.Op Fl md4 | md5 | sha1
.Op Fl modulus
.Op Fl nameopt Ar option
.Op Fl new
.Op Fl newhdr
.Op Fl newkey Ar arg
.Op Fl no-asn1-kludge
.Op Fl nodes
.Op Fl noout
.Op Fl out Ar file
.Op Fl outform Cm der | pem
.Op Fl passin Ar arg
.Op Fl passout Ar arg
.Op Fl pubkey
.Op Fl reqexts Ar section
.Op Fl reqopt Ar option
.Op Fl set_serial Ar n
.Op Fl subj Ar arg
.Op Fl subject
.Op Fl text
.Op Fl utf8
.Op Fl verbose
.Op Fl verify
.Op Fl x509
.nr nS 0
.Pp
The
.Nm req
command primarily creates and processes certificate requests
in PKCS#10 format.
It can additionally create self-signed certificates,
for use as root CAs, for example.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl asn1-kludge
Produce requests in an invalid format for certain picky CAs.
Very few CAs still require the use of this option.
.It Fl batch
Non-interactive mode.
.It Fl config Ar file
Specify an alternative configuration file.
.It Fl days Ar n
Specify the number of days to certify the certificate for.
The default is 30 days.
Used with the
.Fl x509
option.
.It Fl extensions Ar section , Fl reqexts Ar section
Specify alternative sections to include certificate
extensions (with
.Fl x509 )
or certificate request extensions,
allowing several different sections to be used in the same configuration file.
.It Fl in Ar file
The input file to read a request from,
or standard input if not specified.
A request is only read if the creation options
.Fl new
and
.Fl newkey
are not specified.
.It Fl inform Cm der | pem
The input format.
.It Fl key Ar keyfile
The file to read the private key from.
It also accepts PKCS#8 format private keys for PEM format files.
.It Fl keyform Cm der | pem
The format of the private key file specified in the
.Fl key
argument.
The default is PEM.
.It Fl keyout Ar file
The file to write the newly created private key to.
If this option is not specified,
the filename present in the configuration file is used.
.It Fl md5 | sha1 | sha256
The message digest to sign the request with.
This overrides the digest algorithm specified in the configuration file.
.Pp
Some public key algorithms may override this choice.
For instance, DSA signatures always use SHA1.
.It Fl modulus
Print the value of the modulus of the public key contained in the request.
.It Fl nameopt Ar option , Fl reqopt Ar option
Determine how the subject or issuer names are displayed.
.Ar option
can be a single option or multiple options separated by commas.
Alternatively, these options may be used more than once to set multiple options.
See the
.Sx X509
section below for details.
.It Fl new
Generate a new certificate request.
The user is prompted for the relevant field values.
The actual fields prompted for and their maximum and minimum sizes
are specified in the configuration file and any requested extensions.
.Pp
If the
.Fl key
option is not used, it will generate a new RSA private
key using information specified in the configuration file.
.It Fl newhdr
Add the word NEW to the PEM file header and footer lines
on the outputed request.
Some software and CAs need this.
.It Fl newkey Ar arg
Create a new certificate request and a new private key.
The argument takes one of several forms.
.Pp
.No rsa : Ns Ar nbits
generates an RSA key
.Ar nbits
in size.
If
.Ar nbits
is omitted
the default key size is used.
.Pp
.No dsa : Ns Ar file
generates a DSA key using the parameters in
.Ar file .
.Pp
.No param : Ns Ar file
generates a key using the parameters or certificate in
.Ar file .
.Pp
All other algorithms support the form
.Ar algorithm : Ns Ar file ,
where file may be an algorithm parameter file,
created by the
.Cm genpkey -genparam
command or an X.509 certificate for a key with appropriate algorithm.
.Ar file
can be omitted,
in which case any parameters can be specified via the
.Fl pkeyopt
option.
.It Fl no-asn1-kludge
Reverse the effect of
.Fl asn1-kludge .
.It Fl nodes
Do not encrypt the private key.
.It Fl noout
Do not output the encoded version of the request.
.It Fl out Ar file
The output file to write to,
or standard output if not spceified.
.It Fl outform Cm der | pem
The output format.
.It Fl passin Ar arg
The key password source.
.It Fl passout Ar arg
The output file password source.
.It Fl pubkey
Output the public key.
.It Fl reqopt Ar option
Customise the output format used with
.Fl text .
The
.Ar option
argument can be a single option or multiple options separated by commas.
See also the discussion of
.Fl certopt
in the
.Nm x509
command.
.It Fl set_serial Ar n
Serial number to use when outputting a self-signed certificate.
This may be specified as a decimal value or a hex value if preceded by
.Sq 0x .
It is possible to use negative serial numbers but this is not recommended.
.It Fl subj Ar arg
Replaces the subject field of an input request
with the specified data and output the modified request.
.Ar arg
must be formatted as /type0=value0/type1=value1/type2=...;
characters may be escaped by
.Sq \e
(backslash);
no spaces are skipped.
.It Fl subject
Print the request subject (or certificate subject if
.Fl x509
is specified).
.It Fl text
Print the certificate request in plain text.
.It Fl utf8
Interpret field values as UTF8 strings, not ASCII.
.It Fl verbose
Print extra details about the operations being performed.
.It Fl verify
Verify the signature on the request.
.It Fl x509
Output a self-signed certificate instead of a certificate request.
This is typically used to generate a test certificate or a self-signed root CA.
The extensions added to the certificate (if any)
are specified in the configuration file.
Unless specified using the
.Fl set_serial
option, 0 is used for the serial number.
.El
.Pp
The configuration options are specified in the
.Qq req
section of the configuration file.
The options available are as follows:
.Bl -tag -width "XXXX"
.It Cm attributes
The section containing any request attributes: its format
is the same as
.Cm distinguished_name .
Typically these may contain the challengePassword or unstructuredName types.
They are currently ignored by the
.Nm openssl
request signing utilities, but some CAs might want them.
.It Cm default_bits
The default key size, in bits.
The default is 2048.
It is used if the
.Fl new
option is used and can be overridden by using the
.Fl newkey
option.
.It Cm default_keyfile
The default file to write a private key to,
or standard output if not specified.
It can be overridden by the
.Fl keyout
option.
.It Cm default_md
The digest algorithm to use.
Possible values include
.Cm md5 ,
.Cm sha1
and
.Cm sha256
(the default).
It can be overridden on the command line.
.It Cm distinguished_name
The section containing the distinguished name fields to
prompt for when generating a certificate or certificate request.
The format is described below.
.It Cm encrypt_key
If set to
.Qq no
and a private key is generated, it is not encrypted.
It is equivalent to the
.Fl nodes
option.
For compatibility,
.Cm encrypt_rsa_key
is an equivalent option.
.It Cm input_password | output_password
The passwords for the input private key file (if present)
and the output private key file (if one will be created).
The command line options
.Fl passin
and
.Fl passout
override the configuration file values.
.It Cm oid_file
A file containing additional OBJECT IDENTIFIERS.
Each line of the file should consist of the numerical form of the
object identifier, followed by whitespace, then the short name followed
by whitespace and finally the long name.
.It Cm oid_section
Specify a section in the configuration file containing extra
object identifiers.
Each line should consist of the short name of the
object identifier followed by
.Sq =
and the numerical form.
The short and long names are the same when this option is used.
.It Cm prompt
If set to
.Qq no ,
it disables prompting of certificate fields
and just takes values from the config file directly.
It also changes the expected format of the
.Cm distinguished_name
and
.Cm attributes
sections.
.It Cm req_extensions
The configuration file section containing a list of
extensions to add to the certificate request.
It can be overridden by the
.Fl reqexts
option.
.It Cm string_mask
Limit the string types for encoding certain fields.
The following values may be used, limiting strings to the indicated types:
.Bl -tag -width "MASK:number"
.It Cm utf8only
UTF8String.
This is the default, as recommended by PKIX in RFC 2459.
.It Cm default
PrintableString, IA5String, T61String, BMPString, UTF8String.
.It Cm pkix
PrintableString, IA5String, BMPString, UTF8String.
Inspired by the PKIX recommendation in RFC 2459 for certificates
generated before 2004, but differs by also permitting IA5String.
.It Cm nombstr
PrintableString, IA5String, T61String, UniversalString.
A workaround for some ancient software that had problems
with the variable-sized BMPString and UTF8String types.
.It Cm MASK : Ns Ar number
An explicit bitmask of permitted types, where
.Ar number
is a C-style hex, decimal, or octal number that's a bit-wise OR of
.Dv B_ASN1_*
values from
.In openssl/asn1.h .
.El
.It Cm utf8
If set to
.Qq yes ,
field values are interpreted as UTF8 strings.
.It Cm x509_extensions
The configuration file section containing a list of
extensions to add to a certificate generated when the
.Fl x509
switch is used.
It can be overridden by the
.Fl extensions
command line switch.
.El
.Pp
There are two separate formats for the distinguished name and attribute
sections.
If the
.Fl prompt
option is set to
.Qq no ,
then these sections just consist of field names and values.
If the
.Fl prompt
option is absent or not set to
.Qq no ,
then the file contains field prompting information of the form:
.Bd -unfilled -offset indent
fieldName="prompt"
fieldName_default="default field value"
fieldName_min= 2
fieldName_max= 4
.Ed
.Pp
.Qq fieldName
is the field name being used, for example
.Cm commonName
(or CN).
The
.Qq prompt
string is used to ask the user to enter the relevant details.
If the user enters nothing, the default value is used;
if no default value is present, the field is omitted.
A field can still be omitted if a default value is present,
if the user just enters the
.Sq \&.
character.
.Pp
The number of characters entered must be between the
fieldName_min and fieldName_max limits:
there may be additional restrictions based on the field being used
(for example
.Cm countryName
can only ever be two characters long and must fit in a
.Cm PrintableString ) .
.Pp
Some fields (such as
.Cm organizationName )
can be used more than once in a DN.
This presents a problem because configuration files will
not recognize the same name occurring twice.
To avoid this problem, if the
.Cm fieldName
contains some characters followed by a full stop, they will be ignored.
So, for example, a second
.Cm organizationName
can be input by calling it
.Qq 1.organizationName .
.Pp
The actual permitted field names are any object identifier short or
long names.
These are compiled into
.Nm openssl
and include the usual values such as
.Cm commonName , countryName , localityName , organizationName ,
.Cm organizationUnitName , stateOrProvinceName .
Additionally,
.Cm emailAddress
is included as well as
.Cm name , surname , givenName , initials
and
.Cm dnQualifier .
.Pp
Additional object identifiers can be defined with the
.Cm oid_file
or
.Cm oid_section
options in the configuration file.
Any additional fields will be treated as though they were a
.Cm DirectoryString .
.Sh RSA
.nr nS 1
.Nm "openssl rsa"
.Op Fl aes128 | aes192 | aes256 | des | des3
.Op Fl check
.Op Fl in Ar file
.Op Fl inform Cm der | net | pem
.Op Fl modulus
.Op Fl noout
.Op Fl out Ar file
.Op Fl outform Cm der | net | pem
.Op Fl passin Ar arg
.Op Fl passout Ar arg
.Op Fl pubin
.Op Fl pubout
.Op Fl sgckey
.Op Fl text
.nr nS 0
.Pp
The
.Nm rsa
command processes RSA keys.
They can be converted between various forms and their components printed out.
.Nm rsa
uses the traditional
.Nm SSLeay
compatible format for private key encryption:
newer applications should use the more secure PKCS#8 format using the
.Nm pkcs8
utility.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl aes128 | aes192 | aes256 | des | des3
Encrypt the private key with the AES, DES,
or the triple DES ciphers, respectively, before outputting it.
A pass phrase is prompted for.
If none of these options are specified, the key is written in plain text.
This means that using the
.Nm rsa
utility to read in an encrypted key with no encryption option can be used
to remove the pass phrase from a key, or by setting the encryption options
it can be used to add or change the pass phrase.
These options can only be used with PEM format output files.
.It Fl check
Check the consistency of an RSA private key.
.It Fl in Ar file
The input file to read from,
or standard input if not specified.
If the key is encrypted, a pass phrase will be prompted for.
.It Fl inform Cm der | net | pem
The input format.
.It Fl noout
Do not output the encoded version of the key.
.It Fl modulus
Print the value of the modulus of the key.
.It Fl out Ar file
The output file to write to,
or standard output if not specified.
.It Fl outform Cm der | net | pem
The output format.
.It Fl passin Ar arg
The key password source.
.It Fl passout Ar arg
The output file password source.
.It Fl pubin
Read in a public key,
not a private key.
.It Fl pubout
Output a public key,
not a private key.
Automatically set if the input is a public key.
.It Fl sgckey
Use the modified NET algorithm used with some versions of Microsoft IIS
and SGC keys.
.It Fl text
Print the public/private key components in plain text.
.El
.Sh RSAUTL
.nr nS 1
.Nm "openssl rsautl"
.Op Fl asn1parse
.Op Fl certin
.Op Fl decrypt
.Op Fl encrypt
.Op Fl hexdump
.Op Fl in Ar file
.Op Fl inkey Ar file
.Op Fl keyform Cm der | pem
.Op Fl oaep | pkcs | raw | ssl
.Op Fl out Ar file
.Op Fl pubin
.Op Fl sign
.Op Fl verify
.nr nS 0
.Pp
The
.Nm rsautl
command can be used to sign, verify, encrypt and decrypt
data using the RSA algorithm.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl asn1parse
Asn1parse the output data; this is useful when combined with the
.Fl verify
option.
.It Fl certin
The input is a certificate containing an RSA public key.
.It Fl decrypt
Decrypt the input data using an RSA private key.
.It Fl encrypt
Encrypt the input data using an RSA public key.
.It Fl hexdump
Hex dump the output data.
.It Fl in Ar file
The input to read from,
or standard input if not specified.
.It Fl inkey Ar file
The input key file; by default an RSA private key.
.It Fl keyform Cm der | pem
The private ket format.
The default is
.Cm pem .
.It Fl oaep | pkcs | raw | ssl
The padding to use:
PKCS#1 OAEP, PKCS#1 v1.5 (the default), or no padding, respectively.
For signatures, only
.Fl pkcs
and
.Fl raw
can be used.
.It Fl out Ar file
The output file to write to,
or standard output if not specified.
.It Fl pubin
The input file is an RSA public key.
.It Fl sign
Sign the input data and output the signed result.
This requires an RSA private key.
.It Fl verify
Verify the input data and output the recovered data.
.El
.Sh S_CLIENT
.nr nS 1
.Nm "openssl s_client"
.Op Fl 4 | 6
.Op Fl bugs
.Op Fl CAfile Ar file
.Op Fl CApath Ar directory
.Op Fl cert Ar file
.Op Fl check_ss_sig
.Op Fl cipher Ar cipherlist
.Op Fl connect Ar host Ns Op : Ns Ar port
.Op Fl crl_check
.Op Fl crl_check_all
.Op Fl crlf
.Op Fl debug
.Op Fl extended_crl
.Op Fl ign_eof
.Op Fl ignore_critical
.Op Fl issuer_checks
.Op Fl key Ar keyfile
.Op Fl msg
.Op Fl nbio
.Op Fl nbio_test
.Op Fl no_ticket
.Op Fl no_tls1
.Op Fl no_tls1_1
.Op Fl no_tls1_2
.Op Fl pause
.Op Fl policy_check
.Op Fl prexit
.Op Fl proxy Ar host : Ns Ar port
.Op Fl psk Ar key
.Op Fl psk_identity Ar identity
.Op Fl quiet
.Op Fl reconnect
.Op Fl servername Ar name
.Op Fl showcerts
.Op Fl starttls Ar protocol
.Op Fl state
.Op Fl tls1
.Op Fl tls1_1
.Op Fl tls1_2
.Op Fl tlsextdebug
.Op Fl verify Ar depth
.Op Fl x509_strict
.Op Fl xmpphost Ar host
.nr nS 0
.Pp
The
.Nm s_client
command implements a generic SSL/TLS client which connects
to a remote host using SSL/TLS.
.Pp
If a connection is established with an SSL server, any data received
from the server is displayed and any key presses will be sent to the
server.
When used interactively (which means neither
.Fl quiet
nor
.Fl ign_eof
have been given), the session will be renegotiated if the line begins with an
.Cm R ;
if the line begins with a
.Cm Q
or if end of file is reached, the connection will be closed down.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl 4
Attempt connections using IPv4 only.
.It Fl 6
Attempt connections using IPv6 only.
.It Fl bugs
Enable various workarounds for buggy implementations.
.It Fl CAfile Ar file
A
.Ar file
containing trusted certificates to use during server authentication
and to use when attempting to build the client certificate chain.
.It Fl CApath Ar directory
The
.Ar directory
to use for server certificate verification.
This directory must be in
.Qq hash format ;
see
.Fl verify
for more information.
These are also used when building the client certificate chain.
.It Fl cert Ar file
The certificate to use, if one is requested by the server.
The default is not to use a certificate.
.It Xo
.Fl check_ss_sig ,
.Fl crl_check ,
.Fl crl_check_all ,
.Fl extended_crl ,
.Fl ignore_critical ,
.Fl issuer_checks ,
.Fl policy_check ,
.Fl x509_strict
.Xc
Set various certificate chain validation options.
See the
.Nm verify
command for details.
.It Fl cipher Ar cipherlist
Modify the cipher list sent by the client.
Although the server determines which cipher suite is used, it should take
the first supported cipher in the list sent by the client.
See the
.Nm ciphers
command for more information.
.It Fl connect Ar host Ns Op : Ns Ar port
The
.Ar host
and
.Ar port
to connect to.
If not specified, an attempt is made to connect to the local host
on port 4433.
Alternatively, the host and port pair may be separated using a forward-slash
character,
which is useful for numeric IPv6 addresses.
.It Fl crlf
Translate a line feed from the terminal into CR+LF,
as required by some servers.
.It Fl debug
Print extensive debugging information, including a hex dump of all traffic.
.It Fl ign_eof
Inhibit shutting down the connection when end of file is reached in the input.
.It Fl key Ar keyfile
The private key to use.
If not specified, the certificate file will be used.
.It Fl msg
Show all protocol messages with hex dump.
.It Fl nbio
Turn on non-blocking I/O.
.It Fl nbio_test
Test non-blocking I/O.
.It Fl no_tls1 | no_tls1_1 | no_tls1_2
Disable the use of TLS1.0, 1.1, and 1.2, respectively.
.It Fl no_ticket
Disable RFC 4507 session ticket support.
.It Fl pause
Pause 1 second between each read and write call.
.It Fl prexit
Print session information when the program exits.
This will always attempt
to print out information even if the connection fails.
Normally, information will only be printed out once if the connection succeeds.
This option is useful because the cipher in use may be renegotiated
or the connection may fail because a client certificate is required or is
requested only after an attempt is made to access a certain URL.
Note that the output produced by this option is not always accurate
because a connection might never have been established.
.It Fl proxy Ar host : Ns Ar port
Use the HTTP proxy at
.Ar host
and
.Ar port .
The connection to the proxy is done in cleartext and the
.Fl connect
argument is given to the proxy.
If not specified, localhost is used as final destination.
After that, switch the connection through the proxy to the destination
to TLS.
.It Fl psk Ar key
Use the PSK key
.Ar key
when using a PSK cipher suite.
The key is given as a hexadecimal number without the leading 0x,
for example -psk 1a2b3c4d.
.It Fl psk_identity Ar identity
Use the PSK
.Ar identity
when using a PSK cipher suite.
.It Fl quiet
Inhibit printing of session and certificate information.
This implicitly turns on
.Fl ign_eof
as well.
.It Fl reconnect
Reconnect to the same server 5 times using the same session ID; this can
be used as a test that session caching is working.
.It Fl servername Ar name
Include the TLS Server Name Indication (SNI) extension in the ClientHello
message, using the specified server
.Ar name .
.It Fl showcerts
Display the whole server certificate chain: normally only the server
certificate itself is displayed.
.It Fl starttls Ar protocol
Send the protocol-specific messages to switch to TLS for communication.
.Ar protocol
is a keyword for the intended protocol.
Currently, the supported keywords are
.Qq ftp ,
.Qq imap ,
.Qq smtp ,
.Qq pop3 ,
and
.Qq xmpp .
.It Fl state
Print the SSL session states.
.It Fl tls1 | tls1_1 | tls1_2
Permit only TLS1.0, 1.1, or 1.2, respectively.
.It Fl tlsextdebug
Print a hex dump of any TLS extensions received from the server.
.It Fl verify Ar depth
Turn on server certificate verification,
with a maximum length of
.Ar depth .
Currently the verify operation continues after errors so all the problems
with a certificate chain can be seen.
As a side effect the connection will never fail due to a server
certificate verify failure.
.It Fl xmpphost Ar hostname
When used with
.Fl starttls Ar xmpp ,
specify the host for the "to" attribute of the stream element.
If this option is not specified then the host specified with
.Fl connect
will be used.
.El
.Sh S_SERVER
.nr nS 1
.Nm "openssl s_server"
.Op Fl accept Ar port
.Op Fl bugs
.Op Fl CAfile Ar file
.Op Fl CApath Ar directory
.Op Fl cert Ar file
.Op Fl cipher Ar cipherlist
.Op Fl context Ar id
.Op Fl crl_check
.Op Fl crl_check_all
.Op Fl crlf
.Op Fl dcert Ar file
.Op Fl debug
.Op Fl dhparam Ar file
.Op Fl dkey Ar file
.Op Fl hack
.Op Fl HTTP
.Op Fl id_prefix Ar arg
.Op Fl key Ar keyfile
.Op Fl msg
.Op Fl nbio
.Op Fl nbio_test
.Op Fl no_dhe
.Op Fl no_tls1
.Op Fl no_tls1_1
.Op Fl no_tls1_2
.Op Fl no_tmp_rsa
.Op Fl nocert
.Op Fl psk Ar key
.Op Fl psk_hint Ar hint
.Op Fl quiet
.Op Fl serverpref
.Op Fl state
.Op Fl tls1
.Op Fl tls1_1
.Op Fl tls1_2
.Op Fl Verify Ar depth
.Op Fl verify Ar depth
.Op Fl WWW
.Op Fl www
.nr nS 0
.Pp
The
.Nm s_server
command implements a generic SSL/TLS server which listens
for connections on a given port using SSL/TLS.
.Pp
If a connection request is established with a client and neither the
.Fl www
nor the
.Fl WWW
option has been used, then any data received
from the client is displayed and any key presses are sent to the client.
Certain single letter commands perform special operations:
.Pp
.Bl -tag -width "XXXX" -compact
.It Ic P
Send plain text, which should cause the client to disconnect.
.It Ic Q
End the current SSL connection and exit.
.It Ic q
End the current SSL connection, but still accept new connections.
.It Ic R
Renegotiate the SSL session and request a client certificate.
.It Ic r
Renegotiate the SSL session.
.It Ic S
Print out some session cache status information.
.El
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl accept Ar port
Listen on TCP
.Ar port
for connections.
The default is port 4433.
.It Fl bugs
Enable various workarounds for buggy implementations.
.It Fl CAfile Ar file
A
.Ar file
containing trusted certificates to use during client authentication
and to use when attempting to build the server certificate chain.
The list is also used in the list of acceptable client CAs passed to the
client when a certificate is requested.
.It Fl CApath Ar directory
The
.Ar directory
to use for client certificate verification.
This directory must be in
.Qq hash format ;
see
.Fl verify
for more information.
These are also used when building the server certificate chain.
.It Fl cert Ar file
The certificate to use: most server's cipher suites require the use of a
certificate and some require a certificate with a certain public key type.
For example, the DSS cipher suites require a certificate containing a DSS
(DSA) key.
If not specified, the file
.Pa server.pem
will be used.
.It Fl cipher Ar cipherlist
Modify the cipher list used by the server.
This allows the cipher list used by the server to be modified.
When the client sends a list of supported ciphers, the first client cipher
also included in the server list is used.
Because the client specifies the preference order, the order of the server
cipherlist is irrelevant.
See the
.Nm ciphers
command for more information.
.It Fl context Ar id
Set the SSL context ID.
It can be given any string value.
.It Fl crl_check , crl_check_all
Check the peer certificate has not been revoked by its CA.
The CRLs are appended to the certificate file.
.Fl crl_check_all
checks all CRLs of all CAs in the chain.
.It Fl crlf
Translate a line feed from the terminal into CR+LF.
.It Fl dcert Ar file , Fl dkey Ar file
Specify an additional certificate and private key; these behave in the
same manner as the
.Fl cert
and
.Fl key
options except there is no default if they are not specified
(no additional certificate or key is used).
By using RSA and DSS certificates and keys,
a server can support clients which only support RSA or DSS cipher suites
by using an appropriate certificate.
.It Fl debug
Print extensive debugging information, including a hex dump of all traffic.
.It Fl dhparam Ar file
The DH parameter file to use.
The ephemeral DH cipher suites generate keys
using a set of DH parameters.
If not specified, an attempt is made to
load the parameters from the server certificate file.
If this fails, a static set of parameters hard coded into the
.Nm s_server
program will be used.
.It Fl hack
Enables a further workaround for some early Netscape SSL code.
.It Fl HTTP
Emulate a simple web server.
Pages are resolved relative to the current directory.
For example if the URL
.Pa https://myhost/page.html
is requested, the file
.Pa ./page.html
will be loaded.
The files loaded are assumed to contain a complete and correct HTTP
response (lines that are part of the HTTP response line and headers
must end with CRLF).
.It Fl id_prefix Ar arg
Generate SSL/TLS session IDs prefixed by
.Ar arg .
This is mostly useful for testing any SSL/TLS code
(e.g. proxies)
that wish to deal with multiple servers, when each of which might be
generating a unique range of session IDs
(e.g. with a certain prefix).
.It Fl key Ar keyfile
The private key to use.
If not specified, the certificate file will be used.
.It Fl msg
Show all protocol messages with hex dump.
.It Fl nbio
Turn on non-blocking I/O.
.It Fl nbio_test
Test non-blocking I/O.
.It Fl no_dhe
Disable ephemeral DH cipher suites.
.It Fl no_tls1 | no_tls1_1 | no_tls1_2
Disable the use of TLS1.0, 1.1, and 1.2, respectively.
.It Fl no_tmp_rsa
Disable temporary RSA key generation.
.It Fl nocert
Do not use a certificate.
This restricts the cipher suites available to the anonymous ones
(currently just anonymous DH).
.It Fl psk Ar key
Use the PSK key
.Ar key
when using a PSK cipher suite.
The key is given as a hexadecimal number without the leading 0x,
for example -psk 1a2b3c4d.
.It Fl psk_hint Ar hint
Use the PSK identity hint
.Ar hint
when using a PSK cipher suite.
.It Fl quiet
Inhibit printing of session and certificate information.
.It Fl serverpref
Use server's cipher preferences.
.It Fl state
Print the SSL session states.
.It Fl tls1 | tls1_1 | tls1_2
Permit only TLS1.0, 1.1, or 1.2, respectively.
.It Fl WWW
Emulate a simple web server.
Pages are resolved relative to the current directory.
For example if the URL
.Pa https://myhost/page.html
is requested, the file
.Pa ./page.html
will be loaded.
.It Fl www
Send a status message to the client when it connects,
including information about the ciphers used and various session parameters.
The output is in HTML format so this option will normally be used with a
web browser.
.It Fl Verify Ar depth , Fl verify Ar depth
Request a certificate chain from the client,
with a maximum length of
.Ar depth .
With
.Fl Verify ,
the client must supply a certificate or an error occurs;
with
.Fl verify ,
a certificate is requested but the client does not have to send one.
.El
.Sh S_TIME
.nr nS 1
.Nm "openssl s_time"
.Op Fl bugs
.Op Fl CAfile Ar file
.Op Fl CApath Ar directory
.Op Fl cert Ar file
.Op Fl cipher Ar cipherlist
.Op Fl connect Ar host Ns Op : Ns Ar port
.Op Fl key Ar keyfile
.Op Fl nbio
.Op Fl new
.Op Fl no_shutdown
.Op Fl reuse
.Op Fl time Ar seconds
.Op Fl verify Ar depth
.Op Fl www Ar page
.nr nS 0
.Pp
The
.Nm s_time
command implements a generic SSL/TLS client which connects to a
remote host using SSL/TLS.
It can request a page from the server and includes
the time to transfer the payload data in its timing measurements.
It measures the number of connections within a given timeframe,
the amount of data transferred
.Pq if any ,
and calculates the average time spent for one connection.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl bugs
Enable various workarounds for buggy implementations.
.It Fl CAfile Ar file
A
.Ar file
containing trusted certificates to use during server authentication
and to use when attempting to build the client certificate chain.
.It Fl CApath Ar directory
The directory to use for server certificate verification.
This directory must be in
.Qq hash format ;
see
.Nm verify
for more information.
These are also used when building the client certificate chain.
.It Fl cert Ar file
The certificate to use, if one is requested by the server.
The default is not to use a certificate.
.It Fl cipher Ar cipherlist
Modify the cipher list sent by the client.
Although the server determines which cipher suite is used,
it should take the first supported cipher in the list sent by the client.
See the
.Nm ciphers
command for more information.
.It Fl connect Ar host Ns Op : Ns Ar port
The host and port to connect to.
.It Fl key Ar keyfile
The private key to use.
If not specified, the certificate file will be used.
.It Fl nbio
Turn on non-blocking I/O.
.It Fl new
Perform the timing test using a new session ID for each connection.
If neither
.Fl new
nor
.Fl reuse
are specified,
they are both on by default and executed in sequence.
.It Fl no_shutdown
Shut down the connection without sending a
.Qq close notify
shutdown alert to the server.
.It Fl reuse
Perform the timing test using the same session ID for each connection.
If neither
.Fl new
nor
.Fl reuse
are specified,
they are both on by default and executed in sequence.
.It Fl time Ar seconds
Limit
.Nm s_time
benchmarks to the number of
.Ar seconds .
The default is 30 seconds.
.It Fl verify Ar depth
Turn on server certificate verification,
with a maximum length of
.Ar depth .
Currently the verify operation continues after errors, so all the problems
with a certificate chain can be seen.
As a side effect,
the connection will never fail due to a server certificate verify failure.
.It Fl www Ar page
The page to GET from the server.
A value of
.Sq /
gets the index.htm[l] page.
If this parameter is not specified,
.Nm s_time
will only perform the handshake to establish SSL connections
but not transfer any payload data.
.El
.Sh SESS_ID
.nr nS 1
.Nm "openssl sess_id"
.Op Fl cert
.Op Fl context Ar ID
.Op Fl in Ar file
.Op Fl inform Cm der | pem
.Op Fl noout
.Op Fl out Ar file
.Op Fl outform Cm der | pem
.Op Fl text
.nr nS 0
.Pp
The
.Nm sess_id
program processes the encoded version of the SSL session structure and
optionally prints out SSL session details
(for example the SSL session master key)
in human-readable format.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl cert
If a certificate is present in the session,
it will be output using this option;
if the
.Fl text
option is also present, then it will be printed out in text form.
.It Fl context Ar ID
Set the session
.Ar ID .
The ID can be any string of characters.
.It Fl in Ar file
The input file to read from,
or standard input if not specified.
.It Fl inform Cm der | pem
The input format.
.Cm der
uses an ASN1 DER-encoded format containing session details.
The precise format can vary from one version to the next.
.Cm pem
is the default format: it consists of the DER
format base64-encoded with additional header and footer lines.
.It Fl noout
Do not output the encoded version of the session.
.It Fl out Ar file
The output file to write to,
or standard output if not specified.
.It Fl outform Cm der | pem
The output format.
.It Fl text
Print the various public or private key components in plain text,
in addition to the encoded version.
.El
.Pp
The output of
.Nm sess_id
is composed as follows:
.Pp
.Bl -tag -width "Verify return code " -offset 3n -compact
.It Protocol
The protocol in use.
.It Cipher
The actual raw SSL or TLS cipher code.
.It Session-ID
The SSL session ID, in hex format.
.It Session-ID-ctx
The session ID context, in hex format.
.It Master-Key
The SSL session master key.
.It Key-Arg
The key argument; this is only used in SSL v2.
.It Start Time
The session start time.
.Ux
format.
.It Timeout
The timeout, in seconds.
.It Verify return code
The return code when a certificate is verified.
.El
.Pp
Since the SSL session output contains the master key, it is possible to read
the contents of an encrypted session using this information.
Therefore appropriate security precautions
should be taken if the information is being output by a
.Qq real
application.
This is, however, strongly discouraged and should only be used for
debugging purposes.
.Sh SMIME
.nr nS 1
.Nm "openssl smime"
.Oo
.Fl aes128 | aes192 | aes256 | des |
.Fl des3 | rc2-40 | rc2-64 | rc2-128
.Oc
.Op Fl binary
.Op Fl CAfile Ar file
.Op Fl CApath Ar directory
.Op Fl certfile Ar file
.Op Fl check_ss_sig
.Op Fl content Ar file
.Op Fl crl_check
.Op Fl crl_check_all
.Op Fl decrypt
.Op Fl encrypt
.Op Fl extended_crl
.Op Fl from Ar addr
.Op Fl ignore_critical
.Op Fl in Ar file
.Op Fl indef
.Op Fl inform Cm der | pem | smime
.Op Fl inkey Ar file
.Op Fl issuer_checks
.Op Fl keyform Cm pem
.Op Fl md Ar digest
.Op Fl noattr
.Op Fl nocerts
.Op Fl nochain
.Op Fl nodetach
.Op Fl noindef
.Op Fl nointern
.Op Fl nosigs
.Op Fl noverify
.Op Fl out Ar file
.Op Fl outform Cm der | pem | smime
.Op Fl passin Ar arg
.Op Fl pk7out
.Op Fl policy_check
.Op Fl recip Ar file
.Op Fl resign
.Op Fl sign
.Op Fl signer Ar file
.Op Fl stream
.Op Fl subject Ar s
.Op Fl text
.Op Fl to Ar addr
.Op Fl verify
.Op Fl x509_strict
.Op Ar cert.pem ...
.nr nS 0
.Pp
The
.Nm smime
command handles S/MIME mail.
It can encrypt, decrypt, sign, and verify S/MIME messages.
.Pp
The MIME message must be sent without any blank lines between the
headers and the output.
Some mail programs will automatically add a blank line.
Piping the mail directly to an MTA is one way to
achieve the correct format.
.Pp
The supplied message to be signed or encrypted must include the necessary
MIME headers or many S/MIME clients won't display it properly (if at all).
Use the
.Fl text
option to automatically add plain text headers.
.Pp
A
.Qq signed and encrypted
message is one where a signed message is then encrypted.
This can be produced by encrypting an already signed message.
.Pp
There are a number of operations that can be performed, as follows:
.Bl -tag -width "XXXX"
.It Fl decrypt
Decrypt mail using the supplied certificate and private key.
The input file is an encrypted mail message in MIME format.
The decrypted mail is written to the output file.
.It Fl encrypt
Encrypt mail for the given recipient certificates.
The input is the message to be encrypted.
The output file is the encrypted mail, in MIME format.
.It Fl pk7out
Take an input message and write out a PEM-encoded PKCS#7 structure.
.It Fl resign
Resign a message: take an existing message and one or more new signers.
.It Fl sign
Sign mail using the supplied certificate and private key.
The input file is the message to be signed.
The signed message, in MIME format, is written to the output file.
.It Fl verify
Verify signed mail.
The input is a signed mail message and the output is the signed data.
Both clear text and opaque signing is supported.
.El
.Pp
The remaining options are as follows:
.Bl -tag -width "XXXX"
.It Xo
.Fl aes128 | aes192 | aes256 | des |
.Fl des3 | rc2-40 | rc2-64 | rc2-128
.Xc
The encryption algorithm to use.
128-, 192-, or 256-bit AES, DES (56 bits), triple DES (168 bits),
or 40-, 64-, or 128-bit RC2, respectively;
if not specified, 40-bit RC2 is
used.
Only used with
.Fl encrypt .
.It Fl binary
Normally, the input message is converted to
.Qq canonical
format which uses CR/LF as end of line,
as required by the S/MIME specification.
When this option is present no translation occurs.
This is useful when handling binary data which may not be in MIME format.
.It Fl CAfile Ar file
A
.Ar file
containing trusted CA certificates; only used with
.Fl verify .
.It Fl CApath Ar directory
A
.Ar directory
containing trusted CA certificates; only used with
.Fl verify .
This directory must be a standard certificate directory:
that is, a hash of each subject name (using
.Nm x509 -hash )
should be linked to each certificate.
.It Ar cert.pem ...
One or more certificates of message recipients: used when encrypting
a message.
.It Fl certfile Ar file
Allows additional certificates to be specified.
When signing, these will be included with the message.
When verifying, these will be searched for the signers' certificates.
The certificates should be in PEM format.
.It Xo
.Fl check_ss_sig ,
.Fl crl_check ,
.Fl crl_check_all ,
.Fl extended_crl ,
.Fl ignore_critical ,
.Fl issuer_checks ,
.Fl policy_check ,
.Fl x509_strict
.Xc
Set various certificate chain validation options.
See the
.Nm verify
command for details.
.It Fl content Ar file
A file containing the detached content.
This is only useful with the
.Fl verify
option,
and only usable if the PKCS#7 structure is using the detached
signature form where the content is not included.
This option will override any content if the input format is S/MIME
and it uses the multipart/signed MIME content type.
.It Xo
.Fl from Ar addr ,
.Fl subject Ar s ,
.Fl to Ar addr
.Xc
The relevant mail headers.
These are included outside the signed
portion of a message so they may be included manually.
When signing, many S/MIME
mail clients check that the signer's certificate email
address matches the From: address.
.It Fl in Ar file
The input file to read from.
.It Fl indef
Enable streaming I/O for encoding operations.
This permits single pass processing of data without
the need to hold the entire contents in memory,
potentially supporting very large files.
Streaming is automatically set for S/MIME signing with detached
data if the output format is SMIME;
it is currently off by default for all other operations.
.It Fl inform Cm der | pem | smime
The input format.
.It Fl inkey Ar file
The private key to use when signing or decrypting,
which must match the corresponding certificate.
If this option is not specified, the private key must be included
in the certificate file specified with
the
.Fl recip
or
.Fl signer
file.
When signing,
this option can be used multiple times to specify successive keys.
.It Fl keyform Cm pem
Input private key format.
.It Fl md Ar digest
The digest algorithm to use when signing or resigning.
If not present then the default digest algorithm for the signing key is used
(usually SHA1).
.It Fl noattr
Do not include attributes.
.It Fl nocerts
Do not include the signer's certificate.
This will reduce the size of the signed message but the verifier must
have a copy of the signer's certificate available locally (passed using the
.Fl certfile
option, for example).
.It Fl nochain
Do not do chain verification of signers' certificates: that is,
don't use the certificates in the signed message as untrusted CAs.
.It Fl nodetach
When signing a message use opaque signing: this form is more resistant
to translation by mail relays but it cannot be read by mail agents that
do not support S/MIME.
Without this option cleartext signing with the MIME type
multipart/signed is used.
.It Fl noindef
Disable streaming I/O where it would produce an encoding of indefinite length
(currently has no effect).
.It Fl nointern
Only use certificates specified in the
.Fl certfile .
The supplied certificates can still be used as untrusted CAs.
.It Fl nosigs
Do not try to verify the signatures on the message.
.It Fl noverify
Do not verify the signer's certificate of a signed message.
.It Fl out Ar file
The output file to write to.
.It Fl outform Cm der | pem | smime
The output format.
The default is smime, which writes an S/MIME format message.
.Cm pem
and
.Cm der
change this to write PEM and DER format PKCS#7 structures instead.
This currently only affects the output format of the PKCS#7
structure; if no PKCS#7 structure is being output (for example with
.Fl verify
or
.Fl decrypt )
this option has no effect.
.It Fl passin Ar arg
The key password source.
.It Fl recip Ar file
The recipients certificate when decrypting a message.
This certificate
must match one of the recipients of the message or an error occurs.
.It Fl signer Ar file
A signing certificate when signing or resigning a message;
this option can be used multiple times if more than one signer is required.
If a message is being verified, the signer's certificates will be
written to this file if the verification was successful.
.It Fl stream
The same as
.Fl indef .
.It Fl text
Add plain text (text/plain) MIME
headers to the supplied message if encrypting or signing.
If decrypting or verifying, it strips off text headers:
if the decrypted or verified message is not of MIME type text/plain
then an error occurs.
.El
.Pp
The exit codes for
.Nm smime
are as follows:
.Pp
.Bl -tag -width "XXXX"  -offset 3n -compact
.It 0
The operation was completely successful.
.It 1
An error occurred parsing the command options.
.It 2
One of the input files could not be read.
.It 3
An error occurred creating the file or when reading the message.
.It 4
An error occurred decrypting or verifying the message.
.It 5
An error occurred writing certificates.
.El
.Sh SPEED
.nr nS 1
.Nm "openssl speed"
.Op Ar algorithm
.Op Fl decrypt
.Op Fl elapsed
.Op Fl evp Ar algorithm
.Op Fl mr
.Op Fl multi Ar number
.nr nS 0
.Pp
The
.Nm speed
command is used to test the performance of cryptographic algorithms.
.Bl -tag -width "XXXX"
.It Ar algorithm
Perform the test using
.Ar algorithm .
The default is to test all algorithms.
.It Fl decrypt
Time decryption instead of encryption;
must be used with
.Fl evp .
.It Fl elapsed
Measure time in real time instead of CPU user time.
.It Fl evp Ar algorithm
Perform the test using one of the algorithms accepted by
.Xr EVP_get_cipherbyname 3 .
.It Fl mr
Produce machine readable output.
.It Fl multi Ar number
Run
.Ar number
benchmarks in parallel.
.El
.Sh SPKAC
.nr nS 1
.Nm "openssl spkac"
.Op Fl challenge Ar string
.Op Fl in Ar file
.Op Fl key Ar keyfile
.Op Fl noout
.Op Fl out Ar file
.Op Fl passin Ar arg
.Op Fl pubkey
.Op Fl spkac Ar spkacname
.Op Fl spksect Ar section
.Op Fl verify
.nr nS 0
.Pp
The
.Nm spkac
command processes signed public key and challenge (SPKAC) files.
It can print out their contents, verify the signature,
and produce its own SPKACs from a supplied private key.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl challenge Ar string
The challenge string, if an SPKAC is being created.
.It Fl in Ar file
The input file to read from,
or standard input if not specified.
Ignored if the
.Fl key
option is used.
.It Fl key Ar keyfile
Create an SPKAC file using the private key in
.Ar keyfile .
The
.Fl in , noout , spksect ,
and
.Fl verify
options are ignored, if present.
.It Fl noout
Do not output the text version of the SPKAC.
.It Fl out Ar file
The output file to write to,
or standard output if not specified.
.It Fl passin Ar arg
The key password source.
.It Fl pubkey
Output the public key of an SPKAC.
.It Fl spkac Ar spkacname
An alternative name for the variable containing the SPKAC.
The default is "SPKAC".
This option affects both generated and input SPKAC files.
.It Fl spksect Ar section
An alternative name for the
.Ar section
containing the SPKAC.
.It Fl verify
Verify the digital signature on the supplied SPKAC.
.El
.Sh TS
.nr nS 1
.Nm "openssl ts"
.Fl query
.Op Fl md4 | md5 | ripemd160 | sha1
.Op Fl cert
.Op Fl config Ar configfile
.Op Fl data Ar file_to_hash
.Op Fl digest Ar digest_bytes
.Op Fl in Ar request.tsq
.Op Fl no_nonce
.Op Fl out Ar request.tsq
.Op Fl policy Ar object_id
.Op Fl text
.nr nS 0
.Pp
.nr nS 1
.Nm "openssl ts"
.Fl reply
.Op Fl chain Ar certs_file.pem
.Op Fl config Ar configfile
.Op Fl in Ar response.tsr
.Op Fl inkey Ar private.pem
.Op Fl out Ar response.tsr
.Op Fl passin Ar arg
.Op Fl policy Ar object_id
.Op Fl queryfile Ar request.tsq
.Op Fl section Ar tsa_section
.Op Fl signer Ar tsa_cert.pem
.Op Fl text
.Op Fl token_in
.Op Fl token_out
.nr nS 0
.Pp
.nr nS 1
.Nm "openssl ts"
.Fl verify
.Op Fl CAfile Ar trusted_certs.pem
.Op Fl CApath Ar trusted_cert_path
.Op Fl data Ar file_to_hash
.Op Fl digest Ar digest_bytes
.Op Fl in Ar response.tsr
.Op Fl queryfile Ar request.tsq
.Op Fl token_in
.Op Fl untrusted Ar cert_file.pem
.nr nS 0
.Pp
The
.Nm ts
command is a basic Time Stamping Authority (TSA) client and server
application as specified in RFC 3161 (Time-Stamp Protocol, TSP).
A TSA can be part of a PKI deployment and its role is to provide long
term proof of the existence of specific data.
Here is a brief description of the protocol:
.Bl -enum
.It
The TSA client computes a one-way hash value for a data file and sends
the hash to the TSA.
.It
The TSA attaches the current date and time to the received hash value,
signs them and sends the time stamp token back to the client.
By creating this token the TSA certifies the existence of the original
data file at the time of response generation.
.It
The TSA client receives the time stamp token and verifies the
signature on it.
It also checks if the token contains the same hash
value that it had sent to the TSA.
.El
.Pp
There is one DER-encoded protocol data unit defined for transporting a time
stamp request to the TSA and one for sending the time stamp response
back to the client.
The
.Nm ts
command has three main functions:
creating a time stamp request based on a data file;
creating a time stamp response based on a request;
and verifying if a response corresponds
to a particular request or a data file.
.Pp
There is no support for sending the requests/responses automatically
over HTTP or TCP yet as suggested in RFC 3161.
Users must send the requests either by FTP or email.
.Pp
The
.Fl query
switch can be used for creating and printing a time stamp
request with the following options:
.Bl -tag -width Ds
.It Fl cert
Expect the TSA to include its signing certificate in the response.
.It Fl config Ar configfile
Specify an alternative configuration file.
Only the OID section is used.
.It Fl data Ar file_to_hash
The data file for which the time stamp request needs to be created.
The default is standard input.
.It Fl digest Ar digest_bytes
Specify the message imprint explicitly without the data file.
The imprint must be specified in a hexadecimal format,
two characters per byte,
the bytes optionally separated by colons.
The number of bytes must match the message digest algorithm in use.
.It Fl in Ar request.tsq
A previously created time stamp request in DER
format that will be printed into the output file.
Useful for examining the content of a request in human-readable format.
.It Fl md4 | md5 | ripemd160 | sha | sha1
The message digest to apply to the data file.
It supports all the message digest algorithms that are supported by the
.Nm dgst
command.
The default is SHA-1.
.It Fl no_nonce
Specify no nonce in the request.
The default, to include a 64-bit long pseudo-random nonce,
is recommended to protect against replay attacks.
.It Fl out Ar request.tsq
The output file to write to,
or standard output if not specified.
.It Fl policy Ar object_id
The policy that the client expects the TSA to use for creating the
time stamp token.
Either dotted OID notation or OID names defined
in the config file can be used.
If no policy is requested the TSA uses its own default policy.
.It Fl text
Output in human-readable text format instead of DER.
.El
.Pp
A time stamp response (TimeStampResp) consists of a response status
and the time stamp token itself (ContentInfo),
if the token generation was successful.
The
.Fl reply
command is for creating a time stamp
response or time stamp token based on a request and printing the
response/token in human-readable format.
If
.Fl token_out
is not specified the output is always a time stamp response (TimeStampResp),
otherwise it is a time stamp token (ContentInfo).
.Bl -tag -width Ds
.It Fl chain Ar certs_file.pem
The collection of PEM certificates
that will be included in the response
in addition to the signer certificate if the
.Fl cert
option was used for the request.
This file is supposed to contain the certificate chain
for the signer certificate from its issuer upwards.
The
.Fl reply
command does not build a certificate chain automatically.
.It Fl config Ar configfile
Specify an alternative configuration file.
.It Fl in Ar response.tsr
Specify a previously created time stamp response (or time stamp token, if
.Fl token_in
is also specified)
in DER format that will be written to the output file.
This option does not require a request;
it is useful, for example,
to examine the content of a response or token
or to extract the time stamp token from a response.
If the input is a token and the output is a time stamp response a default
.Qq granted
status info is added to the token.
.It Fl inkey Ar private.pem
The signer private key of the TSA in PEM format.
Overrides the
.Cm signer_key
config file option.
.It Fl out Ar response.tsr
The response is written to this file.
The format and content of the file depends on other options (see
.Fl text
and
.Fl token_out ) .
The default is stdout.
.It Fl passin Ar arg
The key password source.
.It Fl policy Ar object_id
The default policy to use for the response.
Either dotted OID notation or OID names defined
in the config file can be used.
If no policy is requested the TSA uses its own default policy.
.It Fl queryfile Ar request.tsq
The file containing a DER-encoded time stamp request.
.It Fl section Ar tsa_section
The config file section containing the settings for response generation.
.It Fl signer Ar tsa_cert.pem
The PEM signer certificate of the TSA.
The TSA signing certificate must have exactly one extended key usage
assigned to it: timeStamping.
The extended key usage must also be critical,
otherwise the certificate is going to be refused.
Overrides the
.Cm signer_cert
variable of the config file.
.It Fl text
Output in human-readable text format instead of DER.
.It Fl token_in
The input is a DER-encoded time stamp token (ContentInfo)
instead of a time stamp response (TimeStampResp).
.It Fl token_out
The output is a time stamp token (ContentInfo)
instead of a time stamp response (TimeStampResp).
.El
.Pp
The
.Fl verify
command is for verifying if a time stamp response or time stamp token
is valid and matches a particular time stamp request or data file.
The
.Fl verify
command does not use the configuration file.
.Bl -tag -width Ds
.It Fl CAfile Ar trusted_certs.pem
The file containing a set of trusted self-signed PEM CA certificates.
See
.Nm verify
for additional details.
Either this option or
.Fl CApath
must be specified.
.It Fl CApath Ar trusted_cert_path
The directory containing the trused CA certificates of the client.
See
.Nm verify
for additional details.
Either this option or
.Fl CAfile
must be specified.
.It Fl data Ar file_to_hash
The response or token must be verified against
.Ar file_to_hash .
The file is hashed with the message digest algorithm specified in the token.
The
.Fl digest
and
.Fl queryfile
options must not be specified with this one.
.It Fl digest Ar digest_bytes
The response or token must be verified against the message digest specified
with this option.
The number of bytes must match the message digest algorithm
specified in the token.
The
.Fl data
and
.Fl queryfile
options must not be specified with this one.
.It Fl in Ar response.tsr
The time stamp response that needs to be verified, in DER format.
This option in mandatory.
.It Fl queryfile Ar request.tsq
The original time stamp request, in DER format.
The
.Fl data
and
.Fl digest
options must not be specified with this one.
.It Fl token_in
The input is a DER-encoded time stamp token (ContentInfo)
instead of a time stamp response (TimeStampResp).
.It Fl untrusted Ar cert_file.pem
Additional untrusted PEM certificates which may be needed
when building the certificate chain for the TSA's signing certificate.
This file must contain the TSA signing certificate and
all intermediate CA certificates unless the response includes them.
.El
.Pp
Options specified on the command line always override
the settings in the config file:
.Bl -tag -width Ds
.It Cm tsa Ar section , Cm default_tsa
This is the main section and it specifies the name of another section
that contains all the options for the
.Fl reply
option.
This section can be overridden with the
.Fl section
command line switch.
.It Cm oid_file
See
.Nm ca
for a description.
.It Cm oid_section
See
.Nm ca
for a description.
.It Cm serial
The file containing the hexadecimal serial number of the
last time stamp response created.
This number is incremented by 1 for each response.
If the file does not exist at the time of response generation
a new file is created with serial number 1.
This parameter is mandatory.
.It Cm signer_cert
TSA signing certificate, in PEM format.
The same as the
.Fl signer
command line option.
.It Cm certs
A set of PEM-encoded certificates that need to be
included in the response.
The same as the
.Fl chain
command line option.
.It Cm signer_key
The private key of the TSA, in PEM format.
The same as the
.Fl inkey
command line option.
.It Cm default_policy
The default policy to use when the request does not mandate any policy.
The same as the
.Fl policy
command line option.
.It Cm other_policies
Comma separated list of policies that are also acceptable by the TSA
and used only if the request explicitly specifies one of them.
.It Cm digests
The list of message digest algorithms that the TSA accepts.
At least one algorithm must be specified.
This parameter is mandatory.
.It Cm accuracy
The accuracy of the time source of the TSA in seconds, milliseconds
and microseconds.
For example, secs:1, millisecs:500, microsecs:100.
If any of the components is missing,
zero is assumed for that field.
.It Cm clock_precision_digits
The maximum number of digits, which represent the fraction of seconds,
that need to be included in the time field.
The trailing zeroes must be removed from the time,
so there might actually be fewer digits
or no fraction of seconds at all.
The maximum value is 6;
the default is 0.
.It Cm ordering
If this option is yes,
the responses generated by this TSA can always be ordered,
even if the time difference between two responses is less
than the sum of their accuracies.
The default is no.
.It Cm tsa_name
Set this option to yes if the subject name of the TSA must be included in
the TSA name field of the response.
The default is no.
.It Cm ess_cert_id_chain
The SignedData objects created by the TSA always contain the
certificate identifier of the signing certificate in a signed
attribute (see RFC 2634, Enhanced Security Services).
If this option is set to yes and either the
.Cm certs
variable or the
.Fl chain
option is specified then the certificate identifiers of the chain will also
be included in the SigningCertificate signed attribute.
If this variable is set to no,
only the signing certificate identifier is included.
The default is no.
.El
.Sh VERIFY
.nr nS 1
.Nm "openssl verify"
.Op Fl CAfile Ar file
.Op Fl CApath Ar directory
.Op Fl check_ss_sig
.Op Fl crl_check
.Op Fl crl_check_all
.Op Fl explicit_policy
.Op Fl extended_crl
.Op Fl help
.Op Fl ignore_critical
.Op Fl inhibit_any
.Op Fl inhibit_map
.Op Fl issuer_checks
.Op Fl policy_check
.Op Fl purpose Ar purpose
.Op Fl untrusted Ar file
.Op Fl verbose
.Op Fl x509_strict
.Op Ar certificates
.nr nS 0
.Pp
The
.Nm verify
command verifies certificate chains.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl check_ss_sig
Verify the signature on the self-signed root CA.
This is disabled by default
because it doesn't add any security.
.It Fl CAfile Ar file
A
.Ar file
of trusted certificates.
The
.Ar file
should contain multiple certificates in PEM format, concatenated together.
.It Fl CApath Ar directory
A
.Ar directory
of trusted certificates.
The certificates, or symbolic links to them,
should have names of the form
.Ar hash Ns .0 ,
where
.Ar hash
is the hashed certificate subject name
(see the
.Fl hash
option of the
.Nm x509
utility).
.It Fl crl_check
Check end entity certificate validity by attempting to look up a valid CRL.
If a valid CRL cannot be found an error occurs.
.It Fl crl_check_all
Check the validity of all certificates in the chain by attempting
to look up valid CRLs.
.It Fl explicit_policy
Set policy variable require-explicit-policy (RFC 3280).
.It Fl extended_crl
Enable extended CRL features such as indirect CRLs and alternate CRL
signing keys.
.It Fl help
Print a usage message.
.It Fl ignore_critical
Ignore critical extensions instead of rejecting the certificate.
.It Fl inhibit_any
Set policy variable inhibit-any-policy (RFC 3280).
.It Fl inhibit_map
Set policy variable inhibit-policy-mapping (RFC 3280).
.It Fl issuer_checks
Print diagnostics relating to searches for the issuer certificate
of the current certificate
showing why each candidate issuer certificate was rejected.
The presence of rejection messages
does not itself imply that anything is wrong:
during the normal verify process several rejections may take place.
.It Fl policy_check
Enable certificate policy processing.
.It Fl purpose Ar purpose
The intended use for the certificate.
Without this option no chain verification will be done.
Currently accepted uses are
.Cm sslclient , sslserver ,
.Cm nssslserver , smimesign ,
.Cm smimeencrypt , crlsign ,
.Cm any ,
and
.Cm ocsphelper .
.It Fl untrusted Ar file
A
.Ar file
of untrusted certificates.
The
.Ar file
should contain multiple certificates.
.It Fl verbose
Print extra information about the operations being performed.
.It Fl x509_strict
Disable workarounds for broken certificates which have to be disabled
for strict X.509 compliance.
.It Ar certificates
One or more PEM
.Ar certificates
to verify.
If no certificate files are included, an attempt is made to read
a certificate from standard input.
If the first certificate filename begins with a dash,
use a lone dash to mark the last option.
.El
.Pp
The
.Nm verify
program uses the same functions as the internal SSL and S/MIME verification,
with one crucial difference:
wherever possible an attempt is made to continue after an error,
whereas normally the verify operation would halt on the first error.
This allows all the problems with a certificate chain to be determined.
.Pp
The verify operation consists of a number of separate steps.
Firstly a certificate chain is built up starting from the supplied certificate
and ending in the root CA.
It is an error if the whole chain cannot be built up.
The chain is built up by looking up the issuer's certificate of the current
certificate.
If a certificate is found which is its own issuer, it is assumed
to be the root CA.
.Pp
All certificates whose subject name matches the issuer name
of the current certificate are subject to further tests.
The relevant authority key identifier components of the current certificate
(if present) must match the subject key identifier (if present)
and issuer and serial number of the candidate issuer;
in addition the
.Cm keyUsage
extension of the candidate issuer (if present) must permit certificate signing.
.Pp
The lookup first looks in the list of untrusted certificates and if no match
is found the remaining lookups are from the trusted certificates.
The root CA is always looked up in the trusted certificate list:
if the certificate to verify is a root certificate,
then an exact match must be found in the trusted list.
.Pp
The second operation is to check every untrusted certificate's extensions for
consistency with the supplied purpose.
If the
.Fl purpose
option is not included, then no checks are done.
The supplied or
.Qq leaf
certificate must have extensions compatible with the supplied purpose
and all other certificates must also be valid CA certificates.
The precise extensions required are described in more detail in
the
.Nm X509
section below.
.Pp
The third operation is to check the trust settings on the root CA.
The root CA should be trusted for the supplied purpose.
A certificate with no trust settings is considered to be valid for
all purposes.
.Pp
The final operation is to check the validity of the certificate chain.
The validity period is checked against the current system time and the
.Cm notBefore
and
.Cm notAfter
dates in the certificate.
The certificate signatures are also checked at this point.
.Pp
If all operations complete successfully, the certificate is considered
valid.
If any operation fails then the certificate is not valid.
When a verify operation fails, the output messages can be somewhat cryptic.
The general form of the error message is:
.Bd -literal
server.pem: /C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test CA (1024-bit)
error 24 at 1 depth lookup:invalid CA certificate
.Ed
.Pp
The first line contains the name of the certificate being verified, followed by
the subject name of the certificate.
The second line contains the error number and the depth.
The depth is the number of the certificate being verified when a
problem was detected starting with zero for the certificate being verified
itself, then 1 for the CA that signed the certificate and so on.
Finally a text version of the error number is presented.
.Pp
An exhaustive list of the error codes and messages is shown below; this also
includes the name of the error code as defined in the header file
.In openssl/x509_vfy.h .
Some of the error codes are defined but never returned: these are described as
.Qq unused .
.Bl -tag -width "XXXX"
.It 0 X509_V_OK
The operation was successful.
.It 2 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT
The issuer certificate of an untrusted certificate could not be found.
.It 3 X509_V_ERR_UNABLE_TO_GET_CRL
The CRL of a certificate could not be found.
.It 4 X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE
The certificate signature could not be decrypted.
This means that the actual signature value could not be determined
rather than it not matching the expected value.
This is only meaningful for RSA keys.
.It 5 X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE
The CRL signature could not be decrypted.
This means that the actual signature value could not be determined
rather than it not matching the expected value.
Unused.
.It 6 X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY
The public key in the certificate
.Cm SubjectPublicKeyInfo
could not be read.
.It 7 X509_V_ERR_CERT_SIGNATURE_FAILURE
The signature of the certificate is invalid.
.It 8 X509_V_ERR_CRL_SIGNATURE_FAILURE
The signature of the certificate is invalid.
.It 9 X509_V_ERR_CERT_NOT_YET_VALID
The certificate is not yet valid: the
.Cm notBefore
date is after the current time.
.It 10 X509_V_ERR_CERT_HAS_EXPIRED
The certificate has expired; that is, the
.Cm notAfter
date is before the current time.
.It 11 X509_V_ERR_CRL_NOT_YET_VALID
The CRL is not yet valid.
.It 12 X509_V_ERR_CRL_HAS_EXPIRED
The CRL has expired.
.It 13 X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD
The certificate
.Cm notBefore
field contains an invalid time.
.It 14 X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD
The certificate
.Cm notAfter
field contains an invalid time.
.It 15 X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD
The CRL
.Cm lastUpdate
field contains an invalid time.
.It 16 X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD
The CRL
.Cm nextUpdate
field contains an invalid time.
.It 17 X509_V_ERR_OUT_OF_MEM
An error occurred trying to allocate memory.
This should never happen.
.It 18 X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT
The passed certificate is self-signed and the same certificate cannot be
found in the list of trusted certificates.
.It 19 X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN
The certificate chain could be built up using the untrusted certificates but
the root could not be found locally.
.It 20 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY
The issuer certificate of a locally looked up certificate could not be found.
This normally means the list of trusted certificates is not complete.
.It 21 X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE
No signatures could be verified because the chain contains only one
certificate and it is not self-signed.
.It 22 X509_V_ERR_CERT_CHAIN_TOO_LONG
The certificate chain length is greater than the supplied maximum depth.
Unused.
.It 23 X509_V_ERR_CERT_REVOKED
The certificate has been revoked.
.It 24 X509_V_ERR_INVALID_CA
A CA certificate is invalid.
Either it is not a CA or its extensions are not consistent
with the supplied purpose.
.It 25 X509_V_ERR_PATH_LENGTH_EXCEEDED
The
.Cm basicConstraints
pathlength parameter has been exceeded.
.It 26 X509_V_ERR_INVALID_PURPOSE
The supplied certificate cannot be used for the specified purpose.
.It 27 X509_V_ERR_CERT_UNTRUSTED
The root CA is not marked as trusted for the specified purpose.
.It 28 X509_V_ERR_CERT_REJECTED
The root CA is marked to reject the specified purpose.
.It 29 X509_V_ERR_SUBJECT_ISSUER_MISMATCH
The current candidate issuer certificate was rejected because its subject name
did not match the issuer name of the current certificate.
Only displayed when the
.Fl issuer_checks
option is set.
.It 30 X509_V_ERR_AKID_SKID_MISMATCH
The current candidate issuer certificate was rejected because its subject key
identifier was present and did not match the authority key identifier current
certificate.
Only displayed when the
.Fl issuer_checks
option is set.
.It 31 X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH
The current candidate issuer certificate was rejected because its issuer name
and serial number were present and did not match the authority key identifier
of the current certificate.
Only displayed when the
.Fl issuer_checks
option is set.
.It 32 X509_V_ERR_KEYUSAGE_NO_CERTSIGN
The current candidate issuer certificate was rejected because its
.Cm keyUsage
extension does not permit certificate signing.
.It 50 X509_V_ERR_APPLICATION_VERIFICATION
An application specific error.
Unused.
.El
.\"
.\" VERSION
.\"
.Sh VERSION
.Nm openssl version
.Op Fl abdfopv
.Pp
The
.Nm version
command is used to print out version information about
.Nm OpenSSL .
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl a
All information: this is the same as setting all the other flags.
.It Fl b
The date the current version of
.Nm OpenSSL
was built.
.It Fl d
.Ev OPENSSLDIR
setting.
.It Fl f
Compilation flags.
.It Fl o
Option information: various options set when the library was built.
.It Fl p
Platform setting.
.It Fl v
The current
.Nm OpenSSL
version.
.El
.Sh VERSION NOTES
The output of
.Nm openssl version -a
would typically be used when sending in a bug report.
.Sh VERSION HISTORY
The
.Fl d
option was added in
.Nm OpenSSL
0.9.7.
.\"
.\" X509
.\"
.Sh X509
.nr nS 1
.Nm "openssl x509"
.Bk -words
.Op Fl C
.Op Fl addreject Ar arg
.Op Fl addtrust Ar arg
.Op Fl alias
.Op Fl CA Ar file
.Op Fl CAcreateserial
.Op Fl CAform Ar DER | PEM
.Op Fl CAkey Ar file
.Op Fl CAkeyform Ar DER | PEM
.Op Fl CAserial Ar file
.Op Fl certopt Ar option
.Op Fl checkend Ar arg
.Op Fl clrext
.Op Fl clrreject
.Op Fl clrtrust
.Op Fl dates
.Op Fl days Ar arg
.Op Fl email
.Op Fl enddate
.Op Fl extensions Ar section
.Op Fl extfile Ar file
.Op Fl fingerprint
.Op Fl hash
.Op Fl in Ar file
.Op Fl inform Ar DER | NET | PEM
.Op Fl issuer
.Op Fl issuer_hash
.Op Fl issuer_hash_old
.Op Fl keyform Ar DER | PEM
.Op Fl md5 | sha1
.Op Fl modulus
.Op Fl nameopt Ar option
.Op Fl noout
.Op Fl ocsp_uri
.Op Fl ocspid
.Op Fl out Ar file
.Op Fl outform Ar DER | NET | PEM
.Op Fl passin Ar arg
.Op Fl pubkey
.Op Fl purpose
.Op Fl req
.Op Fl serial
.Op Fl set_serial Ar n
.Op Fl setalias Ar arg
.Op Fl signkey Ar file
.Op Fl startdate
.Op Fl subject
.Op Fl subject_hash
.Op Fl subject_hash_old
.Op Fl text
.Op Fl trustout
.Op Fl x509toreq
.Ek
.nr nS 0
.Pp
The
.Nm x509
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
.Qq mini CA ,
or edit certificate trust settings.
.Pp
Since there are a large number of options, they are split up into
various sections.
.Sh X509 INPUT, OUTPUT, AND GENERAL PURPOSE OPTIONS
.Bl -tag -width "XXXX"
.It Fl in Ar file
This specifies the input
.Ar file
to read a certificate from, or standard input if this option is not specified.
.It Fl inform Ar DER | NET | PEM
This specifies the input format.
Normally, the command will expect an X.509 certificate,
but this can change if other options such as
.Fl req
are present.
The
.Ar DER
format is the DER encoding of the certificate and
.Ar PEM
is the base64 encoding of the DER encoding with header and footer lines added.
The
.Ar NET
option is an obscure Netscape server format that is now
obsolete.
.It Fl md5 | sha1
The digest to use.
This affects any signing or display option that uses a message digest,
such as the
.Fl fingerprint , signkey ,
and
.Fl CA
options.
If not specified, MD5 is used.
If the key being used to sign with is a DSA key,
this option has no effect: SHA1 is always used with DSA keys.
.It Fl out Ar file
This specifies the output
.Ar file
to write to, or standard output by default.
.It Fl outform Ar DER | NET | PEM
This specifies the output format; the options have the same meaning as the
.Fl inform
option.
.It Fl passin Ar arg
The key password source.
.El
.Sh X509 DISPLAY OPTIONS
.Sy Note :
The
.Fl alias
and
.Fl purpose
options are also display options but are described in the
.Sx X509 TRUST SETTINGS
section.
.Bl -tag -width "XXXX"
.It Fl C
This outputs the certificate in the form of a C source file.
.It Fl certopt Ar option
Customise the output format used with
.Fl text .
The
.Ar option
argument can be a single option or multiple options separated by commas.
The
.Fl certopt
switch may also be used more than once to set multiple options.
See the
.Sx X509 TEXT OPTIONS
section for more information.
.It Fl dates
Prints out the start and expiry dates of a certificate.
.It Fl email
Outputs the email address(es), if any.
.It Fl enddate
Prints out the expiry date of the certificate; that is, the
.Em notAfter
date.
.It Fl fingerprint
Prints out the digest of the DER-encoded version of the whole certificate
(see
.Sx DIGEST OPTIONS ) .
.It Fl hash
A synonym for
.Fl subject_hash ,
for backwards compatibility.
.It Fl issuer
Outputs the issuer name.
.It Fl issuer_hash
Outputs the
.Qq hash
of the certificate issuer name.
.It Fl issuer_hash_old
Outputs the
.Qq hash
of the certificate issuer name using the older algorithm
as used by
.Nm OpenSSL
versions before 1.0.0.
.It Fl modulus
This option prints out the value of the modulus of the public key
contained in the certificate.
.It Fl nameopt Ar option
Option which determines how the subject or issuer names are displayed.
The
.Ar option
argument can be a single option or multiple options separated by commas.
Alternatively, the
.Fl nameopt
switch may be used more than once to set multiple options.
See the
.Sx X509 NAME OPTIONS
section for more information.
.It Fl noout
This option prevents output of the encoded version of the request.
.It Fl ocsp_uri
Outputs the OCSP responder addresses, if any.
.It Fl ocspid
Print OCSP hash values for the subject name and public key.
.It Fl pubkey
Output the public key.
.It Fl serial
Outputs the certificate serial number.
.It Fl startdate
Prints out the start date of the certificate; that is, the
.Em notBefore
date.
.It Fl subject
Outputs the subject name.
.It Fl subject_hash
Outputs the
.Qq hash
of the certificate subject name.
This is used in
.Nm OpenSSL
to form an index to allow certificates in a directory to be looked up
by subject name.
.It Fl subject_hash_old
Outputs the
.Qq hash
of the certificate subject name using the older algorithm
as used by
.Nm OpenSSL
versions before 1.0.0.
.It Fl text
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.
.El
.Sh X509 TRUST SETTINGS
Please note these options are currently experimental and may well change.
.Pp
A
.Em trusted certificate
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
.Qq alias .
.Pp
Normally, when a certificate is being verified at least one certificate
must be
.Qq trusted .
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.
.Pp
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 an SSL client but not for
SSL server use.
.Pp
See the description of the
.Nm verify
utility for more information on the meaning of trust settings.
.Pp
Future versions of
.Nm OpenSSL
will recognize trust settings on any certificate: not just root CAs.
.Bl -tag -width "XXXX"
.It Fl addreject Ar arg
Adds a prohibited use.
It accepts the same values as the
.Fl addtrust
option.
.It Fl addtrust Ar arg
Adds a trusted certificate use.
Any object name can be used here, but currently only
.Ar clientAuth
.Pq SSL client use ,
.Ar serverAuth
.Pq SSL server use ,
and
.Ar emailProtection
.Pq S/MIME email
are used.
Other
.Nm OpenSSL
applications may define additional uses.
.It Fl alias
Outputs the certificate alias, if any.
.It Fl clrreject
Clears all the prohibited or rejected uses of the certificate.
.It Fl clrtrust
Clears all the permitted or trusted uses of the certificate.
.It Fl purpose
This option performs tests on the certificate extensions and outputs
the results.
For a more complete description, see the
.Sx X.509 CERTIFICATE EXTENSIONS
section.
.It Fl setalias Ar arg
Sets the alias of the certificate.
This will allow the certificate to be referred to using a nickname,
for example
.Qq Steve's Certificate .
.It Fl trustout
This causes
.Nm x509
to output a
.Em trusted certificate .
An ordinary or trusted certificate can be input, but by default an ordinary
certificate is output and any trust settings are discarded.
With the
.Fl trustout
option a trusted certificate is output.
A trusted certificate is automatically output if any trust settings
are modified.
.El
.Sh X509 SIGNING OPTIONS
The
.Nm x509
utility can be used to sign certificates and requests: it
can thus behave like a
.Qq mini CA .
.Bl -tag -width "XXXX"
.It Fl CA Ar file
Specifies the CA certificate to be used for signing.
When this option is present,
.Nm x509
behaves like a
.Qq mini CA .
The input file is signed by the 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 CA's private key.
.Pp
This option is normally combined with the
.Fl req
option.
Without the
.Fl req
option, the input is a certificate which must be self-signed.
.It Fl CAcreateserial
With this option the CA serial number file is created if it does not exist:
it will contain the serial number
.Sq 02
and the certificate being signed will have
.Sq 1
as its serial number.
Normally, if the
.Fl CA
option is specified and the serial number file does not exist, it is an error.
.It Fl CAform Ar DER | PEM
The format of the CA certificate file.
The default is
.Ar PEM .
.It Fl CAkey Ar file
Sets the CA private key to sign a certificate with.
If this option is not specified, it is assumed that the CA private key
is present in the CA certificate file.
.It Fl CAkeyform Ar DER | PEM
The format of the CA private key.
The default is
.Ar PEM .
.It Fl CAserial Ar file
Sets the CA serial number file to use.
.Pp
When the
.Fl CA
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.
.Pp
The default filename consists of the CA certificate file base name with
.Pa .srl
appended.
For example, if the CA certificate file is called
.Pa mycacert.pem ,
it expects to find a serial number file called
.Pa mycacert.srl .
.It Fl checkend Ar arg
Check whether the certificate expires in the next
.Ar arg
seconds.
If so, exit with return value 1;
otherwise exit with return value 0.
.It Fl clrext
Delete any extensions from a certificate.
This option is used when a certificate is being created from another
certificate (for example with the
.Fl signkey
or the
.Fl CA
options).
Normally, all extensions are retained.
.It Fl days Ar arg
Specifies the number of days to make a certificate valid for.
The default is 30 days.
.It Fl extensions Ar section
The section to add certificate extensions from.
If this option is not specified, the extensions should either be
contained in the unnamed
.Pq default
section or the default section should contain a variable called
.Qq extensions
which contains the section to use.
.It Fl extfile Ar file
File containing certificate extensions to use.
If not specified, no extensions are added to the certificate.
.It Fl keyform Ar DER | PEM
Specifies the format
.Pq DER or PEM
of the private key file used in the
.Fl signkey
option.
.It Fl req
By default, a certificate is expected on input.
With this option a certificate request is expected instead.
.It Fl set_serial Ar n
Specifies the serial number to use.
This option can be used with either the
.Fl signkey
or
.Fl CA
options.
If used in conjunction with the
.Fl CA
option, the serial number file (as specified by the
.Fl CAserial
or
.Fl CAcreateserial
options) is not used.
.Pp
The serial number can be decimal or hex (if preceded by
.Sq 0x ) .
Negative serial numbers can also be specified but their use is not recommended.
.It Fl signkey Ar file
This option causes the input file to be self-signed using the supplied
private key.
.Pp
If the input file is a certificate, it sets the issuer name to the
subject name
.Pq i.e. makes it self-signed ,
changes the public key to the supplied value,
and changes the start and end dates.
The start date is set to the current time and the end date is set to
a value determined by the
.Fl days
option.
Any certificate extensions are retained unless the
.Fl clrext
option is supplied.
.Pp
If the input is a certificate request, a self-signed certificate
is created using the supplied private key using the subject name in
the request.
.It Fl x509toreq
Converts a certificate into a certificate request.
The
.Fl signkey
option is used to pass the required private key.
.El
.Sh X509 NAME OPTIONS
The
.Fl nameopt
command line switch determines how the subject and issuer
names are displayed.
If no
.Fl nameopt
switch is present, the default
.Qq oneline
format is used which is compatible with previous versions of
.Nm OpenSSL .
Each option is described in detail below; all options can be preceded by a
.Sq -
to turn the option off.
Only
.Ar compat ,
.Ar RFC2253 ,
.Ar oneline ,
and
.Ar multiline
will normally be used.
.Bl -tag -width "XXXX"
.It Ar align
Align field values for a more readable output.
Only usable with
.Ar sep_multiline .
.It Ar compat
Use the old format.
This is equivalent to specifying no name options at all.
.It Ar dn_rev
Reverse the fields of the DN.
This is required by RFC 2253.
As a side effect, this also reverses the order of multiple AVAs but this is
permissible.
.It Ar dump_all
Dump all fields.
This option, when used with
.Ar dump_der ,
allows the DER encoding of the structure to be unambiguously determined.
.It Ar dump_der
When this option is set, any fields that need to be hexdumped will
be dumped using the DER encoding of the field.
Otherwise just the content octets will be displayed.
Both options use the RFC 2253 #XXXX... format.
.It Ar dump_nostr
Dump non-character string types
.Pq for example OCTET STRING ;
if this option is not set, non-character string types will be displayed
as though each content octet represents a single character.
.It Ar dump_unknown
Dump any field whose OID is not recognised by
.Nm OpenSSL .
.It Ar esc_2253
Escape the
.Qq special
characters required by RFC 2253 in a field that is
.Dq \& ,+"\*(Lt\*(Gt; .
Additionally,
.Sq #
is escaped at the beginning of a string
and a space character at the beginning or end of a string.
.It Ar esc_ctrl
Escape control characters.
That is, those with ASCII values less than 0x20
.Pq space
and the delete
.Pq 0x7f
character.
They are escaped using the RFC 2253 \eXX notation (where XX are two hex
digits representing the character value).
.It Ar esc_msb
Escape characters with the MSB set; that is, with ASCII values larger than
127.
.It Ar multiline
A multiline format.
It is equivalent to
.Ar esc_ctrl , esc_msb , sep_multiline ,
.Ar space_eq , lname ,
and
.Ar align .
.It Ar no_type
This option does not attempt to interpret multibyte characters in any
way.
That is, their content octets are merely dumped as though one octet
represents each character.
This is useful for diagnostic purposes but will result in rather odd
looking output.
.It Ar nofname , sname , lname , oid
These options alter how the field name is displayed.
.Ar nofname
does not display the field at all.
.Ar sname
uses the
.Qq short name
form (CN for
.Ar commonName ,
for example).
.Ar lname
uses the long form.
.Ar oid
represents the OID in numerical form and is useful for diagnostic purpose.
.It Ar oneline
A oneline format which is more readable than
.Ar RFC2253 .
It is equivalent to specifying the
.Ar esc_2253 , esc_ctrl , esc_msb , utf8 ,
.Ar dump_nostr , dump_der , use_quote , sep_comma_plus_spc ,
.Ar space_eq ,
and
.Ar sname
options.
.It Ar RFC2253
Displays names compatible with RFC 2253; equivalent to
.Ar esc_2253 , esc_ctrl ,
.Ar esc_msb , utf8 , dump_nostr , dump_unknown ,
.Ar dump_der , sep_comma_plus , dn_rev ,
and
.Ar sname .
.It Ar sep_comma_plus , sep_comma_plus_space , sep_semi_plus_space , sep_multiline
These options determine the field separators.
The first character is between RDNs and the second between multiple AVAs
(multiple AVAs are very rare and their use is discouraged).
The options ending in
.Qq space
additionally place a space after the separator to make it more readable.
The
.Ar sep_multiline
uses a linefeed character for the RDN separator and a spaced
.Sq +
for the AVA separator.
It also indents the fields by four characters.
.It Ar show_type
Show the type of the ASN1 character string.
The type precedes the field contents.
For example
.Qq BMPSTRING: Hello World .
.It Ar space_eq
Places spaces round the
.Sq =
character which follows the field name.
.It Ar use_quote
Escapes some characters by surrounding the whole string with
.Sq \&"
characters.
Without the option, all escaping is done with the
.Sq \e
character.
.It Ar utf8
Convert all strings to UTF8 format first.
This is required by RFC 2253.
If you are lucky enough to have a UTF8 compatible terminal,
the use of this option (and
.Em not
setting
.Ar esc_msb )
may result in the correct display of multibyte
.Pq international
characters.
If this option is not present, multibyte characters larger than 0xff
will be represented using the format \eUXXXX for 16 bits and \eWXXXXXXXX
for 32 bits.
Also, if this option is off, any UTF8Strings will be converted to their
character form first.
.El
.Sh X509 TEXT OPTIONS
As well as customising the name output format, it is also possible to
customise the actual fields printed using the
.Fl certopt
options when the
.Fl text
option is present.
The default behaviour is to print all fields.
.Bl -tag -width "XXXX"
.It Ar ca_default
The value used by the
.Nm ca
utility; equivalent to
.Ar no_issuer , no_pubkey , no_header ,
.Ar no_version , no_sigdump ,
and
.Ar no_signame .
.It Ar compatible
Use the old format.
This is equivalent to specifying no output options at all.
.It Ar ext_default
Retain default extension behaviour: attempt to print out unsupported
certificate extensions.
.It Ar ext_dump
Hex dump unsupported extensions.
.It Ar ext_error
Print an error message for unsupported certificate extensions.
.It Ar ext_parse
ASN1 parse unsupported extensions.
.It Ar no_aux
Don't print out certificate trust information.
.It Ar no_extensions
Don't print out any X509V3 extensions.
.It Ar no_header
Don't print header information: that is, the lines saying
.Qq Certificate
and
.Qq Data .
.It Ar no_issuer
Don't print out the issuer name.
.It Ar no_pubkey
Don't print out the public key.
.It Ar no_serial
Don't print out the serial number.
.It Ar no_sigdump
Don't give a hexadecimal dump of the certificate signature.
.It Ar no_signame
Don't print out the signature algorithm used.
.It Ar no_subject
Don't print out the subject name.
.It Ar no_validity
Don't print the validity; that is, the
.Em notBefore
and
.Em notAfter
fields.
.It Ar no_version
Don't print out the version number.
.El
.Sh X509 EXAMPLES
Display the contents of a certificate:
.Pp
.Dl $ openssl x509 -in cert.pem -noout -text
.Pp
Display the certificate serial number:
.Pp
.Dl $ openssl x509 -in cert.pem -noout -serial
.Pp
Display the certificate subject name:
.Pp
.Dl $ openssl x509 -in cert.pem -noout -subject
.Pp
Display the certificate subject name in RFC 2253 form:
.Pp
.Dl $ openssl x509 -in cert.pem -noout -subject -nameopt RFC2253
.Pp
Display the certificate subject name in oneline form on a terminal
supporting UTF8:
.Bd -literal -offset indent
$ openssl x509 -in cert.pem -noout -subject \e
	-nameopt oneline,-esc_msb
.Ed
.Pp
Display the certificate MD5 fingerprint:
.Pp
.Dl $ openssl x509 -in cert.pem -noout -fingerprint
.Pp
Display the certificate SHA1 fingerprint:
.Pp
.Dl $ openssl x509 -sha1 -in cert.pem -noout -fingerprint
.Pp
Convert a certificate from PEM to DER format:
.Pp
.Dl "$ openssl x509 -in cert.pem -inform PEM -out cert.der -outform DER"
.Pp
Convert a certificate to a certificate request:
.Bd -literal -offset indent
$ openssl x509 -x509toreq -in cert.pem -out req.pem \e
	-signkey key.pem
.Ed
.Pp
Convert a certificate request into a self-signed certificate using
extensions for a CA:
.Bd -literal -offset indent
$ openssl x509 -req -in careq.pem -extfile openssl.cnf -extensions \e
	v3_ca -signkey key.pem -out cacert.pem
.Ed
.Pp
Sign a certificate request using the CA certificate above and add user
certificate extensions:
.Bd -literal -offset indent
$ openssl x509 -req -in req.pem -extfile openssl.cnf -extensions \e
	v3_usr -CA cacert.pem -CAkey key.pem -CAcreateserial
.Ed
.Pp
Set a certificate to be trusted for SSL
client use and set its alias to
.Qq Steve's Class 1 CA :
.Bd -literal -offset indent
$ openssl x509 -in cert.pem -addtrust clientAuth \e
	-setalias "Steve's Class 1 CA" -out trust.pem
.Ed
.Sh X509 NOTES
The PEM format uses the header and footer lines:
.Bd -unfilled -offset indent
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----
.Ed
.Pp
It will also handle files containing:
.Bd -unfilled -offset indent
-----BEGIN X509 CERTIFICATE-----
-----END X509 CERTIFICATE-----
.Ed
.Pp
Trusted certificates have the lines:
.Bd -unfilled -offset indent
-----BEGIN TRUSTED CERTIFICATE-----
-----END TRUSTED CERTIFICATE-----
.Ed
.Pp
The conversion to UTF8 format used with the name options assumes that
T61Strings use the ISO 8859-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.
.Pp
The
.Fl fingerprint
option takes the digest of the DER-encoded certificate.
This is commonly called a
.Qq fingerprint .
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.
.Pp
The Netscape fingerprint uses MD5, whereas MSIE uses SHA1.
.Pp
The
.Fl email
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.
.Sh X.509 CERTIFICATE EXTENSIONS
The
.Fl purpose
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.
.Pp
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.
.Pp
The
.Em basicConstraints
extension CA flag is used to determine whether the
certificate can be used as a CA.
If the CA flag is true, it is a CA;
if the CA flag is false, it is not a CA.
.Em All
CAs should have the CA flag set to true.
.Pp
If the
.Em basicConstraints
extension is absent, then the certificate is
considered to be a
.Qq possible CA ;
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.
.Pp
If the certificate is a V1 certificate
.Pq 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.
.Pp
If the
.Em keyUsage
extension is present, then additional restraints are
made on the uses of the certificate.
A CA certificate
.Em must
have the
.Em keyCertSign
bit set if the
.Em keyUsage
extension is present.
.Pp
The extended key usage extension places additional restrictions on the
certificate uses.
If this extension is present
.Pq whether critical or not ,
the key can only be used for the purposes specified.
.Pp
A complete description of each test is given below.
The comments about
.Em basicConstraints
and
.Em keyUsage
and V1 certificates above apply to
.Em all
CA certificates.
.Bl -tag -width "XXXX"
.It Ar SSL Client
The extended key usage extension must be absent or include the
.Qq web client authentication
OID.
.Ar keyUsage
must be absent or it must have the
.Em digitalSignature
bit set.
Netscape certificate type must be absent or it must have the SSL
client bit set.
.It Ar SSL Client CA
The extended key usage extension must be absent or include the
.Qq web client authentication
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
.Em basicConstraints
extension is absent.
.It Ar SSL Server
The extended key usage extension must be absent or include the
.Qq web server authentication
and/or one of the SGC OIDs.
.Em keyUsage
must be absent or it must have the
.Em digitalSignature
set, the
.Em keyEncipherment
set, or both bits set.
Netscape certificate type must be absent or have the SSL server bit set.
.It Ar SSL Server CA
The extended key usage extension must be absent or include the
.Qq web server authentication
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
.Em basicConstraints
extension is absent.
.It Ar Netscape SSL Server
For Netscape SSL clients to connect to an SSL server; it must have the
.Em keyEncipherment
bit set if the
.Em 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.
.It Ar Common S/MIME Client Tests
The extended key usage extension must be absent or include the
.Qq email protection
OID.
Netscape certificate type must be absent or should have the
.Em S/MIME
bit set.
If the
.Em 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
.Em S/MIME
bit.
.It Ar S/MIME Signing
In addition to the common
.Em S/MIME
client tests, the
.Em digitalSignature
bit must be set if the
.Em keyUsage
extension is present.
.It Ar S/MIME Encryption
In addition to the common
.Em S/MIME
tests, the
.Em keyEncipherment
bit must be set if the
.Em keyUsage
extension is present.
.It Ar S/MIME CA
The extended key usage extension must be absent or include the
.Qq email protection
OID.
Netscape certificate type must be absent or must have the
.Em S/MIME CA
bit set: this is used as a work around if the
.Em basicConstraints
extension is absent.
.It Ar CRL Signing
The
.Em keyUsage
extension must be absent or it must have the
.Em CRL
signing bit set.
.It Ar CRL Signing CA
The normal CA tests apply.
Except in this case the
.Em basicConstraints
extension must be present.
.El
.Sh X509 BUGS
Extensions in certificates are not transferred to certificate requests and
vice versa.
.Pp
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.
.Pp
There should be options to explicitly set such things as start and end dates,
rather than an offset from the current time.
.Pp
The code to implement the verify behaviour described in the
.Sx X509 TRUST SETTINGS
is currently being developed.
It thus describes the intended behaviour rather than the current behaviour.
It is hoped that it will represent reality in
.Nm OpenSSL
0.9.5 and later.
.Sh X509 HISTORY
Before
.Nm OpenSSL
0.9.8,
the default digest for RSA keys was MD5.
.Pp
The hash algorithm used in the
.Fl subject_hash
and
.Fl issuer_hash
options before
.Nm OpenSSL
1.0.0 was based on the deprecated MD5 algorithm and the encoding
of the distinguished name.
In
.Nm 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
.Ar c_rehash
or similar.
.Sh COMMON NOTATION
Several commands share a common syntax,
as detailed below.
.Pp
Password arguments, typically specified using
.Fl passin
and
.Fl passout
for input and output passwords,
allow passwords to be obtained from a variety of sources.
Both of these options take a single argument, described below.
If no password argument is given and a password is required,
then the user is prompted to enter one:
this will typically be read from the current terminal with echoing turned off.
.Bl -tag -width "pass:password" -offset indent
.It Cm pass : Ns Ar password
The actual password is
.Ar password .
Since the password is visible to utilities,
this form should only be used where security is not important.
.It Cm env : Ns Ar var
Obtain the password from the environment variable
.Ar var .
Since the environment of other processes is visible,
this option should be used with caution.
.It Cm file : Ns Ar path
The first line of
.Ar path
is the password.
If the same
.Ar path
argument is supplied to
.Fl passin
and
.Fl passout ,
then the first line will be used for the input password and the next line
for the output password.
.Ar path
need not refer to a regular file:
it could, for example, refer to a device or named pipe.
.It Cm fd : Ns Ar number
Read the password from the file descriptor
.Ar number .
This can be used to send the data via a pipe, for example.
.It Cm stdin
Read the password from standard input.
.El
.Pp
Input/output formats,
typically specified using
.Fl inform
and
.Fl outform ,
indicate the format being read from or written to.
The argument is case insensitive.
.Pp
.Bl -tag -width Ds -offset indent -compact
.It Cm der
Distinguished Encoding Rules (DER)
is a binary format.
.It Cm net
Insecure legacy format.
.It Cm pem
Privacy Enhanced Mail (PEM)
is base64-encoded.
.It Cm smime
An SMIME format message.
.It Cm txt
Plain ASCII text.
.El
.Sh ENVIRONMENT
The following environment variables affect the execution of
.Nm openssl :
.Bl -tag -width "/etc/ssl/openssl.cnf"
.It Ev OPENSSL_CONF
The location of the master configuration file.
.El
.\"
.\" FILES
.\"
.Sh FILES
.Bl -tag -width "/etc/ssl/openssl.cnf" -compact
.It Pa /etc/ssl/
Default config directory for
.Nm openssl .
.It Pa /etc/ssl/lib/
Unused.
.It Pa /etc/ssl/private/
Default private key directory.
.It Pa /etc/ssl/openssl.cnf
Default configuration file for
.Nm openssl .
.It Pa /etc/ssl/x509v3.cnf
Default configuration file for
.Nm x509
certificates.
.El
.\"
.\" SEE ALSO
.\"
.Sh SEE ALSO
.Xr acme-client 1 ,
.Xr nc 1 ,
.Xr ssl 8 ,
.Xr starttls 8
.Sh STANDARDS
.Rs
.%D February 1995
.%Q Netscape Communications Corp.
.%T The SSL Protocol
.Re
.Pp
.Rs
.%D November 1996
.%Q Netscape Communications Corp.
.%T The SSL 3.0 Protocol
.Re
.Pp
.Rs
.%A T. Dierks
.%A C. Allen
.%D January 1999
.%R RFC 2246
.%T The TLS Protocol Version 1.0
.Re
.Pp
.Rs
.%A M. Wahl
.%A S. Killie
.%A T. Howes
.%D December 1997
.%R RFC 2253
.%T Lightweight Directory Access Protocol (v3): UTF-8 String Representation of Distinguished Names
.Re
.Pp
.Rs
.%A B. Kaliski
.%D March 1998
.%R RFC 2315
.%T PKCS #7: Cryptographic Message Syntax Version 1.5
.Re
.Pp
.Rs
.%A R. Housley
.%A W. Ford
.%A W. Polk
.%A D. Solo
.%D January 1999
.%R RFC 2459
.%T Internet X.509 Public Key Infrastructure Certificate and CRL Profile
.Re
.Pp
.Rs
.%A M. Myers
.%A R. Ankney
.%A A. Malpani
.%A S. Galperin
.%A C. Adams
.%D June 1999
.%R RFC 2560
.%T X.509 Internet Public Key Infrastructure Online Certificate Status Protocol \(en OCSP
.Re
.Pp
.Rs
.%A R. Housley
.%D June 1999
.%R RFC 2630
.%T Cryptographic Message Syntax
.Re
.Pp
.Rs
.%A P. Chown
.%D June 2002
.%R RFC 3268
.%T Advanced Encryption Standard (AES) Ciphersuites for Transport Layer Security (TLS)
.Re