$OpenBSD: openssl.1,v 1.39 2016/07/21 18:40:26 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: July 21 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

p .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

p .Nm .Cm no- Ns Ar command .Sh DESCRIPTION .Nm OpenSSL is a cryptography toolkit implementing the Transport Layer Security

q TLS v1 network protocol, as well as related cryptography standards.

p The .Nm program is a command line tool for using the various cryptography functions of .Nm openssl Ns 's crypto library from the shell.

p The pseudo-commands .Cm list-standard-commands , list-message-digest-commands , and .Cm list-cipher-commands output a list

q 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.

p 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:

p .D1 from => to

p The pseudo-command .Cm list-public-key-algorithms lists all supported public key algorithms.

p 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.

p .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

p 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.

p The options are as follows: l -tag -width Ds t Fl dlimit Ar number Dump the first .Ar number bytes of unknown data in hex form. t Fl dump Dump unknown data in hex form. t 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. t Fl i Indent the output according to the .Qq depth of the structures. t Fl in Ar file The input file; the default is standard input. t Fl inform Cm der | pem | txt The input format. t Fl length Ar number Number of bytes to parse; the default is until end of file. t Fl noout Don't output the parsed version of the input file. t Fl offset Ar number Starting offset to begin parsing; the default is start of file. t Fl oid Ar file A file containing additional object identifiers

q OIDs . If an OID

q object identifier is not part of .Nm openssl Ns 's internal table it will be represented in numerical form

q for example 1.2.3.4 .

p 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. t Fl out Ar file The DER-encoded output file; the default is no encoded output (useful when combined with .Fl strparse ) . t 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

p 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.

p The options relevant to CAs are as follows: l -tag -width "XXXX" t Fl batch This sets the batch mode. In this mode no questions will be asked and all certificates will be certified automatically. t Fl cert Ar file The CA certificate file. t Fl config Ar file Specifies the configuration file to use. t Fl days Ar arg The number of days to certify the certificate for. t Fl enddate Ar date This allows the expiry date to be explicitly set. The format of the date is YYMMDDHHMMSSZ

q the same as an ASN1 UTCTime structure . t 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

q even if it is empty , then a V3 certificate is created. t 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). t Fl in Ar file An input .Ar file containing a single certificate request to be signed by the CA. t Fl infiles If present, this should be the last option; all subsequent arguments are assumed to be the names of files containing certificate requests. t 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. t Fl keyfile Ar file The private key to sign requests with. t Fl keyform Ar PEM Private key file format. t Fl md Ar alg The message digest to use. Possible values include .Ar md5 and .Ar sha1 . This option also applies to CRLs. t 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. t Fl name Ar section Specifies the configuration file .Ar section to use (overrides .Cm default_ca in the .Cm ca section). t 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. t Fl notext Don't output the text form of a certificate to the output file. t 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. t 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. t Fl passin Ar arg The key password source. t Fl policy Ar arg This option defines 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. t 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. t 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.

p 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 . . t Fl ss_cert Ar file A single self-signed certificate to be signed by the CA. t Fl startdate Ar date This allows the start date to be explicitly set. The format of the date is YYMMDDHHMMSSZ

q the same as an ASN1 UTCTime structure . t Fl status Ar serial Show the status of the certificate with serial number .Ar serial . t Fl updatedb Update database for expired certificates. t Fl verbose This prints extra details about the operations being performed. .El

p The options relevant to CRLs are as follows: l -tag -width "XXXX" t Fl crl_CA_compromise Ar time This is the same as .Fl crl_compromise , except the revocation reason is set to CACompromise. t Fl crl_compromise Ar time This sets the revocation reason to keyCompromise and the compromise time to .Ar time . .Ar time should be in GeneralizedTime format, i.e. YYYYMMDDHHMMSSZ. t Fl crl_hold Ar instruction This sets 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. t 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. t 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. t 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

q 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

q for example Netscape can't handle V2 CRLs. t Fl crlhours Ar num The number of hours before the next CRL is due. t Fl gencrl This option generates a CRL based on information in the index file. t Fl revoke Ar file A .Ar file containing a certificate to revoke. t 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

q backslash , no spaces are skipped. .El

p 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.

p 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

q if any used. l -tag -width "XXXX" t Cm certificate The same as .Fl cert . It gives the file containing the CA certificate. Mandatory. t 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.

p 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.

p 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.

p The main use of this option is to allow a certificate request to supply values for certain extensions such as .Cm subjectAltName . t Cm crl_extensions The same as .Fl crlexts . t 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. t Cm database The text database file to use. Mandatory. This file must be present, though initially it will be empty. t 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. t Cm default_days The same as the .Fl days option. The number of days to certify a certificate for. t Cm default_enddate The same as the .Fl enddate option. Either this option or .Cm default_days

q or the command line equivalents must be present. t Cm default_md The same as the .Fl md option. The message digest to use. Mandatory. t 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. t 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. t Cm msie_hack The same as .Fl msie_hack . t 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).

p For convenience, the value .Cm ca_default is accepted by both to produce a reasonable output.

p 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. t Cm new_certs_dir The same as the .Fl outdir command line option. It specifies the directory where new certificates will be placed. Mandatory. t 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. t 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. t Cm policy The same as .Fl policy . Mandatory. t Cm preserve The same as .Fl preserveDN . t Cm private_key Same as the .Fl keyfile option. The file containing the CA private key. Mandatory. t 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. t 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 . t Cm x509_extensions The same as .Fl extensions . .El .Sh CIPHERS .Nm openssl ciphers .Op Fl hVv .Op Fl tls1 .Op Ar cipherlist

p The .Nm ciphers command converts .Nm openssl cipher lists into ordered SSL cipher preference lists. It can be used as a test tool to determine the appropriate cipherlist.

p The options are as follows: l -tag -width Ds t Fl h , ? Print a brief usage message. t Fl tls1 Only include TLS v1 ciphers. t 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). t Fl v Like .Fl V , but without cipher suite codes. t Ar cipherlist A cipher list to convert to a cipher preference list. If it is not included, the default cipher list will be used.

p 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.

p The actual cipher string can take several different forms:

p It can consist of a single cipher suite, such as RC4-SHA.

p 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.

p 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.

p 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.

p 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.

p 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

p The following is a list of all permitted cipher strings and their meanings. l -tag -width "XXXX" t 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. t 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). t Cm ALL All cipher suites except the .Cm eNULL ciphers, which must be explicitly enabled. t Cm COMPLEMENTOFALL The cipher suites not enabled by .Cm ALL , currently being .Cm eNULL . t Cm HIGH .Qq High encryption cipher suites. This currently means those with key lengths larger than 128 bits. t Cm MEDIUM .Qq Medium encryption cipher suites, currently those using 128-bit encryption. t Cm LOW .Qq Low encryption cipher suites, currently those using 64- or 56-bit encryption algorithms. t 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. t 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. t Cm kRSA , RSA Cipher suites using RSA key exchange. t Cm kEDH Cipher suites using ephemeral DH key agreement. t Cm aRSA Cipher suites using RSA authentication, i.e. the certificates carry RSA keys. t Cm aDSS , DSS Cipher suites using DSS authentication, i.e. the certificates carry DSS keys. t Cm TLSv1 TLS v1.0 cipher suites. t Cm DH Cipher suites using DH, including anonymous DH. t Cm ADH Anonymous DH cipher suites. t Cm AES Cipher suites using AES. t Cm 3DES Cipher suites using triple DES. t Cm DES Cipher suites using DES

q not triple DES . t Cm RC4 Cipher suites using RC4. t Cm CAMELLIA Cipher suites using Camellia. t Cm CHACHA20 Cipher suites using ChaCha20. t Cm IDEA Cipher suites using IDEA. t Cm MD5 Cipher suites using MD5. t 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

p The .Nm crl command processes CRL files in DER or PEM format. The PEM CRL format uses the header and footer lines: d -unfilled -offset indent -----BEGIN X509 CRL----- -----END X509 CRL----- .Ed

p The options are as follows: l -tag -width Ds t Fl CAfile Ar file Verify the signature on a CRL by looking up the issuing certificate in .Ar file . t 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. t Fl fingerprint Print the CRL fingerprint. t Fl hash Output a hash of the issuer name. This can be used to look up CRLs in a directory by issuer name. t Fl in Ar file The input file to read from, or standard input if not specified. t Fl inform Cm der | pem The input format. t Fl issuer Output the issuer name. t Fl lastupdate Output the .Cm lastUpdate field. t Fl nextupdate Output the .Cm nextUpdate field. t Fl noout Don't output the encoded version of the CRL. t Fl out Ar file The output file to write to, or standard output if not specified. t Fl outform Cm der | pem The output format. t Fl text Print out the CRL in text form. .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

p 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.

p The options are as follows: l -tag -width Ds t 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. t Fl in Ar file Read the CRL from .Ar file , or standard input if not specified. t Fl inform Cm der | pem Specify the CRL input format. t 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. t Fl out Ar file Write the PKCS#7 structure to .Ar file , or standard output if not specified. t Fl outform Cm der | pem Specify the PKCS#7 structure output format. .El
DGST

.Sh DGST .nr nS 1 .Nm "openssl dgst" k -words .Oo .Fl gost-mac | streebog256 | streebog512 | md_gost94 | .Fl md4 | md5 | ripemd160 | sha1 | .Fl sha224 | sha256 | sha384 | sha512 | whirlpool .Oc .Op Fl binary .Op Fl cd .Op Fl hex .Op Fl hmac Ar key .Op Fl keyform Ar 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 .Ek .nr nS 0

p .Nm openssl .Cm gost-mac | streebog256 | streebog512 | md_gost94 | .Cm md4 | md5 | ripemd160 | sha1 | .Cm sha224 | sha256 | sha384 | sha512 | whirlpool .Op Fl c .Op Fl d .Op Ar

p 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.

p The options are as follows: l -tag -width Ds t Fl binary Output the digest or signature in binary form. t Fl c Print out the digest in two-digit groups separated by colons; only relevant if .Em hex format output is used. t Fl d Print out BIO debugging information. t 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. t Fl hmac Ar key Create a hashed MAC using .Ar key . t Fl keyform Ar PEM Specifies the key format to sign the digest with. t 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. t Fl macopt Ar nm : Ns Ar v Passes options to the MAC algorithm, specified by .Fl mac . The following options are supported by HMAC: l -tag -width Ds t Ar 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. t Ar 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 t Fl out Ar file The file to output to, or standard output by default. t Fl passin Ar arg The key password source. t 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 . t Fl sign Ar file Digitally sign the digest using the private key in .Ar file . t Fl signature Ar file The actual signature to verify. t 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. t 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 . t Ar File or files to digest. If no files are specified then standard input is used. .El .Sh DGST NOTES The digest of choice for all new applications is SHA1. Other digests are, however, still widely used.

p If you wish to sign or verify data using the DSA algorithm, the dss1 digest must be used.

p A source of random numbers is required for certain signing algorithms, in particular DSA.

p The signing and verify options should only be used if a single file is being signed or verified.
DH

.Sh DH Diffie-Hellman Parameter Management. The .Nm dh command has been replaced by .Nm dhparam . See .Sx DHPARAM below.
DHPARAM

.Sh DHPARAM .nr nS 1 .Nm "openssl dhparam" k -words .Op Fl 2 | 5 .Op Fl C .Op Fl check .Op Fl dsaparam .Op Fl in Ar file .Op Fl inform Ar DER | PEM .Op Fl noout .Op Fl out Ar file .Op Fl outform Ar DER | PEM .Op Fl text .Op Ar numbits .Ek .nr nS 0

p The .Nm dhparam command is used to manipulate DH parameter files.

p The options are as follows: l -tag -width Ds t Fl 2 , 5 The generator to use, either 2 or 5. 2 is the default. If present, the input file is ignored and parameters are generated instead. t Fl C This option converts the parameters into C code. The parameters can then be loaded by calling the .Cm get_dh Ns Ar numbits Ns Li () function. t Fl check Check the DH parameters. t Fl dsaparam If this option is used, DSA rather than DH parameters are read or created; they are converted to DH format. Otherwise, .Qq strong primes

q such that (p-1)/2 is also prime will be used for DH parameter generation.

p 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. t Fl in Ar file This specifies the input .Ar file to read parameters from, or standard input if this option is not specified. t Fl inform Ar DER | PEM This specifies the input format. The argument .Ar DER uses an ASN1 DER-encoded form compatible with the PKCS#3 DHparameter structure. The .Ar PEM form is the default format: it consists of the DER format base64-encoded with additional header and footer lines. t Fl noout This option inhibits the output of the encoded version of the parameters. t Ar numbits This argument specifies that a parameter set should be generated 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. t Fl out Ar file This specifies the output .Ar file to write parameters to. Standard output is used if this option is not present. The output filename should .Em not be the same as the input filename. t Fl outform Ar DER | PEM This specifies the output format; the options have the same meaning as the .Fl inform option. t Fl text This option prints out the DH parameters in human readable form. .El .Sh DHPARAM WARNINGS The program .Nm dhparam combines the functionality of the programs .Nm dh and .Nm gendh in previous versions of .Nm OpenSSL and .Nm SSLeay . The .Nm dh and .Nm gendh programs are retained for now, but may have different purposes in future versions of .Nm OpenSSL . .Sh DHPARAM NOTES PEM format DH parameters use the header and footer lines: d -unfilled -offset indent -----BEGIN DH PARAMETERS----- -----END DH PARAMETERS----- .Ed

p .Nm OpenSSL currently only supports the older PKCS#3 DH, not the newer X9.42 DH.

p This program manipulates DH parameters not keys. .Sh DHPARAM BUGS There should be a way to generate and manipulate DH keys. .Sh DHPARAM HISTORY The .Nm dhparam command was added in .Nm OpenSSL 0.9.5. The .Fl dsaparam option was added in .Nm OpenSSL 0.9.6.
DSA

.Sh DSA .nr nS 1 .Nm "openssl dsa" k -words .Oo .Fl aes128 | aes192 | aes256 | .Fl des | des3 .Oc .Op Fl in Ar file .Op Fl inform Ar DER | PEM .Op Fl modulus .Op Fl noout .Op Fl out Ar file .Op Fl outform Ar DER | PEM .Op Fl passin Ar arg .Op Fl passout Ar arg .Op Fl pubin .Op Fl pubout .Op Fl text .Ek .nr nS 0

p The .Nm dsa command processes DSA keys. They can be converted between various forms and their components printed out.

p .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.

p The options are as follows: l -tag -width Ds t Xo .Fl aes128 | aes192 | aes256 | .Fl des | des3 .Xc These options 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 is specified, the key is written in plain text. This means that using the .Nm dsa 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. t Fl in Ar file This specifies the input .Ar file to read a key from, or standard input if this option is not specified. If the key is encrypted, a pass phrase will be prompted for. t Fl inform Ar DER | PEM This specifies the input format. The .Ar DER argument with a private key uses an ASN1 DER-encoded form of an ASN.1 SEQUENCE consisting of the values of version

q currently zero , P, Q, G, and the public and private key components, respectively, as ASN.1 INTEGERs. When used with a public key it uses a .Em SubjectPublicKeyInfo structure: it is an error if the key is not DSA.

p The .Ar PEM form is the default format: it consists of the DER format base64-encoded with additional header and footer lines. In the case of a private key, PKCS#8 format is also accepted. t Fl modulus This option prints out the value of the public key component of the key. t Fl noout This option prevents output of the encoded version of the key. t Fl out Ar file This specifies the output .Ar file to write a key to, or standard output if not specified. If any encryption options are set then a pass phrase will be prompted for. The output filename should .Em not be the same as the input filename. t Fl outform Ar DER | PEM This specifies the output format; the options have the same meaning as the .Fl inform option. t Fl passin Ar arg The key password source. t Fl passout Ar arg The output file password source. t Fl pubin By default, a private key is read from the input file. With this option a public key is read instead. t Fl pubout By default, a private key is output. With this option a public key will be output instead. This option is automatically set if the input is a public key. t Fl text Prints out the public/private key components and parameters. .El .Sh DSA NOTES The PEM private key format uses the header and footer lines: d -unfilled -offset indent -----BEGIN DSA PRIVATE KEY----- -----END DSA PRIVATE KEY----- .Ed

p The PEM public key format uses the header and footer lines: d -unfilled -offset indent -----BEGIN PUBLIC KEY----- -----END PUBLIC KEY----- .Ed .Sh DSA EXAMPLES To remove the pass phrase on a DSA private key:

p .Dl $ openssl dsa -in key.pem -out keyout.pem

p To encrypt a private key using triple DES:

p .Dl $ openssl dsa -in key.pem -des3 -out keyout.pem

p To convert a private key from PEM to DER format:

p .Dl $ openssl dsa -in key.pem -outform DER -out keyout.der

p To print out the components of a private key to standard output:

p .Dl $ openssl dsa -in key.pem -text -noout

p To just output the public part of a private key:

p .Dl $ openssl dsa -in key.pem -pubout -out pubkey.pem
DSAPARAM

.Sh DSAPARAM .nr nS 1 .Nm "openssl dsaparam" k -words .Op Fl C .Op Fl genkey .Op Fl in Ar file .Op Fl inform Ar DER | PEM .Op Fl noout .Op Fl out Ar file .Op Fl outform Ar DER | PEM .Op Fl text .Op Ar numbits .Ek .nr nS 0

p The .Nm dsaparam command is used to manipulate or generate DSA parameter files.

p The options are as follows: l -tag -width Ds t Fl C This option converts the parameters into C code. The parameters can then be loaded by calling the .Cm get_dsa Ns Ar XXX Ns Li () function. t Fl genkey This option will generate a DSA either using the specified or generated parameters. t Fl in Ar file This specifies the input .Ar file to read parameters from, or standard input if this option is not specified. If the .Ar numbits parameter is included, then this option will be ignored. t Fl inform Ar DER | PEM This specifies the input format. The .Ar DER argument uses an ASN1 DER-encoded form compatible with RFC 2459

q PKIX DSS-Parms that is a SEQUENCE consisting of p, q and g, respectively. The .Ar PEM form is the default format: it consists of the DER format base64-encoded with additional header and footer lines. t Fl noout This option inhibits the output of the encoded version of the parameters. t Ar numbits This option specifies that a parameter set should be generated of size .Ar numbits . If this option is included, the input file

q if any is ignored. t Fl out Ar file This specifies the output .Ar file to write parameters to. Standard output is used if this option is not present. The output filename should .Em not be the same as the input filename. t Fl outform Ar DER | PEM This specifies the output format; the options have the same meaning as the .Fl inform option. t Fl text This option prints out the DSA parameters in human readable form. .El .Sh DSAPARAM NOTES PEM format DSA parameters use the header and footer lines: d -unfilled -offset indent -----BEGIN DSA PARAMETERS----- -----END DSA PARAMETERS----- .Ed

p DSA parameter generation is a slow process and as a result the same set of DSA parameters is often used to generate several distinct keys.
EC

.Sh EC .nr nS 1 .Nm "openssl ec" k -words .Op Fl conv_form Ar arg .Op Fl des .Op Fl des3 .Op Fl in Ar file .Op Fl inform Ar DER | PEM .Op Fl noout .Op Fl out Ar file .Op Fl outform Ar 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 .Ek .nr nS 0

p The .Nm ec command processes EC keys. They can be converted between various forms and their components printed out. Note: .Nm OpenSSL uses the private key format specified in .Dq SEC 1: Elliptic Curve Cryptography

q Lk http://www.secg.org/ . To convert an .Nm OpenSSL EC private key into the PKCS#8 private key format use the .Nm pkcs8 command.

p The options are as follows: l -tag -width Ds t Fl conv_form Ar arg This specifies how the points on the elliptic curve are converted into octet strings. Possible values are: .Cm compressed (the default value), .Cm uncompressed , and .Cm hybrid . For more information regarding the point conversion forms please read 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 .Ar OPENSSL_EC_BIN_PT_COMP at compile time. t Fl des | des3 These options encrypt the private key with the DES, triple DES, or any other cipher supported by .Nm OpenSSL before outputting it. 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. t Fl in Ar file This specifies the input filename to read a key from, or standard input if this option is not specified. If the key is encrypted a pass phrase will be prompted for. t Fl inform Ar DER | PEM This specifies the input format. DER with a private key uses an ASN.1 DER-encoded SEC1 private key. When used with a public key it uses the SubjectPublicKeyInfo structure as specified in RFC 3280. PEM is the default format: it consists of the DER format base64 encoded with additional header and footer lines. In the case of a private key PKCS#8 format is also accepted. t Fl noout Prevents output of the encoded version of the key. t Fl out Ar file Specifies the output filename to write a key to, or standard output if none is specified. If any encryption options are set then a pass phrase will be prompted for. The output filename should .Em not be the same as the input filename. t Fl outform Ar DER | PEM This specifies the output format. The options have the same meaning as the .Fl inform option. t Fl param_enc Ar arg This specifies 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 in .Nm OpenSSL . t Fl passin Ar arg The key password source. t Fl passout Ar arg The output file password source. t Fl pubin By default a private key is read from the input file; with this option a public key is read instead. t Fl pubout By default a private key is output; with this option a public key is output instead. This option is automatically set if the input is a public key. t Fl text Prints out the public/private key components and parameters. .El .Sh EC NOTES The PEM private key format uses the header and footer lines: d -literal -offset indent -----BEGIN EC PRIVATE KEY----- -----END EC PRIVATE KEY----- .Ed

p The PEM public key format uses the header and footer lines: d -literal -offset indent -----BEGIN PUBLIC KEY----- -----END PUBLIC KEY----- .Ed .Sh EC EXAMPLES To encrypt a private key using triple DES: d -literal -offset indent $ openssl ec -in key.pem -des3 -out keyout.pem .Ed

p To convert a private key from PEM to DER format: d -literal -offset indent $ openssl ec -in key.pem -outform DER -out keyout.der .Ed

p To print out the components of a private key to standard output: d -literal -offset indent $ openssl ec -in key.pem -text -noout .Ed

p To just output the public part of a private key: d -literal -offset indent $ openssl ec -in key.pem -pubout -out pubkey.pem .Ed

p To change the parameter encoding to .Cm explicit : d -literal -offset indent $ openssl ec -in key.pem -param_enc explicit -out keyout.pem .Ed

p To change the point conversion form to .Cm compressed : d -literal -offset indent $ openssl ec -in key.pem -conv_form compressed -out keyout.pem .Ed .Sh EC HISTORY The .Nm ec command was first introduced in .Nm OpenSSL 0.9.8. .Sh EC AUTHORS .An Nils Larsch .
ECPARAM

.Sh ECPARAM .nr nS 1 .Nm "openssl ecparam" k -words .Op Fl C .Op Fl check .Op Fl conv_form Ar arg .Op Fl genkey .Op Fl in Ar file .Op Fl inform Ar 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 Ar DER | PEM .Op Fl param_enc Ar arg .Op Fl text .Ek .nr nS 0

p This command is used to manipulate or generate EC parameter files.

p The options are as follows: l -tag -width Ds t Fl C Convert the EC parameters into C code. The parameters can then be loaded by calling the .Fn get_ec_group_XXX function. t Fl check Validate the elliptic curve parameters. t 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 value), .Cm uncompressed , and .Cm hybrid . For more information regarding the point conversion forms please read 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 .Ar OPENSSL_EC_BIN_PT_COMP at compile time. t Fl genkey Generate an EC private key using the specified parameters. t Fl in Ar file Specify the input filename to read parameters from or standard input if this option is not specified. t Fl inform Ar DER | PEM Specify the input format. DER uses an ASN.1 DER-encoded form compatible with RFC 3279 EcpkParameters. PEM is the default format: it consists of the DER format base64 encoded with additional header and footer lines. t Fl list_curves Print out a list of all currently implemented EC parameter names and exit. t Fl name Ar arg Use the EC parameters with the specified 'short' name. Use .Fl list_curves to get a list of all currently implemented EC parameters. t Fl no_seed Inhibit that the 'seed' for the parameter generation is included in the ECParameters structure (see RFC 3279). t Fl noout Inhibit the output of the encoded version of the parameters. t Fl out Ar file Specify the output filename parameters are written to. Standard output is used if this option is not present. The output filename should .Em not be the same as the input filename. t Fl outform Ar DER | PEM Specify the output format; the parameters have the same meaning as the .Fl inform option. t Fl param_enc Ar arg This specifies 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 in .Nm OpenSSL . t Fl text Print out the EC parameters in human readable form. .El .Sh ECPARAM NOTES PEM format EC parameters use the header and footer lines: d -literal -offset indent -----BEGIN EC PARAMETERS----- -----END EC PARAMETERS----- .Ed

p .Nm OpenSSL is currently not able to generate new groups and therefore .Nm ecparam can only create EC parameters from known (named) curves. .Sh ECPARAM EXAMPLES To create EC parameters with the group 'prime192v1': d -literal -offset indent $ openssl ecparam -out ec_param.pem -name prime192v1 .Ed

p To create EC parameters with explicit parameters: d -literal -offset indent $ openssl ecparam -out ec_param.pem -name prime192v1 \e -param_enc explicit .Ed

p To validate given EC parameters: d -literal -offset indent $ openssl ecparam -in ec_param.pem -check .Ed

p To create EC parameters and a private key: d -literal -offset indent $ openssl ecparam -out ec_key.pem -name prime192v1 -genkey .Ed

p To change the point encoding to 'compressed': d -literal -offset indent $ openssl ecparam -in ec_in.pem -out ec_out.pem \e -conv_form compressed .Ed

p To print out the EC parameters to standard output: d -literal -offset indent $ openssl ecparam -in ec_param.pem -noout -text .Ed .Sh ECPARAM HISTORY The .Nm ecparam command was first introduced in .Nm OpenSSL 0.9.8. .Sh ECPARAM AUTHORS .An Nils Larsch .
ENC

.Sh ENC .nr nS 1 .Nm "openssl enc" k -words .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 .Ek .nr nS 0

p 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.

p The options are as follows: l -tag -width Ds t Fl A If the .Fl a option is set, then base64 process the data on one line. t 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. t Fl bufsize Ar number Set the buffer size for I/O. t Fl d Decrypt the input data. t Fl debug Debug the BIOs used for I/O. t Fl e Encrypt the input data: this is the default. t Fl in Ar file The input .Ar file ; standard input by default. t Fl iv Ar IV The actual .Ar IV

q 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 .Ar IV must explicitly be defined. When a password is being specified using one of the other options, the .Ar IV is generated from this password. t 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 .Ar IV must be additionally 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 .Ar IV generated from the password will be taken. It probably does not make much sense to specify both .Ar key and .Ar password . t Fl k Ar password The .Ar password to derive the key from. This is for compatibility with previous versions of .Nm OpenSSL . Superseded by the .Fl pass option. t Fl kfile Ar file Read the password to derive the key from the first line of .Ar file . This is for compatibility with previous versions of .Nm OpenSSL . Superseded by the .Fl pass option. t Fl md Ar digest Use .Ar digest to create a key from a pass phrase. .Ar digest may be one of .Dq md5 or .Dq sha1 . t Fl none Use NULL cipher (no encryption or decryption of input). t Fl nopad Disable standard block padding. t Fl nosalt Don't use a .Ar salt in the key derivation routines. This option should .Em NEVER be used unless compatibility with previous versions of .Nm OpenSSL or .Nm SSLeay is required. t Fl out Ar file The output .Ar file , standard output by default. t Fl P Print out the .Ar salt , .Ar key , and .Ar IV used, then immediately exit; don't do any encryption or decryption. t Fl p Print out the .Ar salt , .Ar key , and .Ar IV used. t Fl pass Ar arg The password source. t Fl S Ar salt The actual .Ar salt to use: this must be represented as a string comprised only of hex digits. t Fl salt Use a .Ar salt in the key derivation routines. This is the default. .El .Sh ENC NOTES The program can be called either as .Nm openssl ciphername or .Nm openssl enc -ciphername .

p A password will be prompted for to derive the .Ar key and .Ar IV if necessary.

p The .Fl nosalt option should .Em NEVER be used unless compatibility with previous versions of .Nm OpenSSL or .Nm SSLeay is required.

p With the .Fl nosalt option it is possible to perform efficient dictionary attacks on the password and to attack stream cipher encrypted data. The reason for this is that without the salt the same password always generates the same encryption key. When the salt is being used the first eight bytes of the encrypted data are reserved for the salt: it is generated at random when encrypting a file and read from the encrypted file when it is decrypted.

p Some of the ciphers do not have large keys and others have security implications if not used correctly. A beginner is advised to just use a strong block cipher in CBC mode such as bf or des3.

p All the block ciphers normally use PKCS#5 padding also known as standard block padding: this allows a rudimentary integrity or password check to be performed. However, since the chance of random data passing the test is better than 1 in 256, it isn't a very good test.

p If padding is disabled, the input data must be a multiple of the cipher block length.

p All RC2 ciphers have the same key and effective key length.

p Blowfish and RC5 algorithms use a 128-bit key. .Sh ENC SUPPORTED CIPHERS d -unfilled -offset indent aes-[128|192|256]-cbc 128/192/256 bit AES in CBC mode aes-[128|192|256] Alias for aes-[128|192|256]-cbc aes-[128|192|256]-cfb 128/192/256 bit AES in 128 bit CFB mode aes-[128|192|256]-cfb1 128/192/256 bit AES in 1 bit CFB mode aes-[128|192|256]-cfb8 128/192/256 bit AES in 8 bit CFB mode aes-[128|192|256]-ecb 128/192/256 bit AES in ECB mode aes-[128|192|256]-ofb 128/192/256 bit AES in OFB mode base64 Base 64 bf Alias for bf-cbc bf-cbc Blowfish in CBC mode bf-cfb Blowfish in CFB mode bf-ecb Blowfish in ECB mode bf-ofb Blowfish in OFB mode cast Alias for cast-cbc cast-cbc CAST in CBC mode cast5-cbc CAST5 in CBC mode cast5-cfb CAST5 in CFB mode cast5-ecb CAST5 in ECB mode cast5-ofb CAST5 in OFB mode des Alias for des-cbc des-cbc DES in CBC mode des-cfb DES in CBC mode des-ecb DES in ECB mode des-ofb DES in OFB mode des-ede Two key triple DES EDE in ECB mode des-ede-cbc Two key triple DES EDE in CBC mode des-ede-cfb Two key triple DES EDE in CFB mode des-ede-ofb Two key triple DES EDE in OFB mode des3 Alias for des-ede3-cbc des-ede3 Three key triple DES EDE in ECB mode des-ede3-cbc Three key triple DES EDE in CBC mode des-ede3-cfb Three key triple DES EDE CFB mode des-ede3-ofb Three key triple DES EDE in OFB mode desx DESX algorithm rc2 Alias for rc2-cbc rc2-cbc 128-bit RC2 in CBC mode rc2-cfb 128-bit RC2 in CFB mode rc2-ecb 128-bit RC2 in ECB mode rc2-ofb 128-bit RC2 in OFB mode rc2-64-cbc 64-bit RC2 in CBC mode rc2-40-cbc 40-bit RC2 in CBC mode rc4 128-bit RC4 rc4-40 40-bit RC4 .Ed .Sh ENC EXAMPLES Just base64 encode a binary file:

p .Dl $ openssl base64 -in file.bin -out file.b64

p Decode the same file:

p .Dl $ openssl base64 -d -in file.b64 -out file.bin

p Encrypt a file using triple DES in CBC mode using a prompted password:

p .Dl $ openssl des3 -salt -in file.txt -out file.des3

p Decrypt a file using a supplied password:

p .Dl "$ openssl des3 -d -in file.des3 -out file.txt -k mypassword"

p Encrypt a file then base64 encode it (so it can be sent via mail for example) using Blowfish in CBC mode:

p .Dl $ openssl bf -a -salt -in file.txt -out file.bf

p Base64 decode a file then decrypt it:

p .Dl "$ openssl bf -d -a -in file.bf -out file.txt" .Sh ENC BUGS The .Fl A option when used with large files doesn't work properly.

p There should be an option to allow an iteration count to be included.

p The .Nm enc program only supports a fixed number of algorithms with certain parameters. Therefore it is not possible to use RC2 with a 76-bit key or RC4 with an 84-bit key with this program.
ERRSTR

.Sh ERRSTR .Nm openssl errstr .Op Fl stats .Ar errno ...

p 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:

p .Dl error:[error code]:[library name]:[function name]:[reason string]

p q error code is an 8-digit hexadecimal number. The remaining fields q library name , q function name , and q reason string are all ASCII text.

p The options are as follows: l -tag -width Ds t Fl stats Print debugging statistics about various aspects of the hash table. .El .Sh ERRSTR EXAMPLES The following error code:

p .Dl 27594:error:2006D080:lib(32):func(109):reason(128):bss_file.c:107:

p ...can be displayed with:

p .Dl $ openssl errstr 2006D080

p ...to produce the error message:

p .Dl error:2006D080:BIO routines:BIO_new_file:no such file
GENDH

.Sh GENDH Generation of Diffie-Hellman Parameters. Replaced by .Nm dhparam . See .Sx DHPARAM above.
GENDSA

.Sh GENDSA .nr nS 1 .Nm "openssl gendsa" k -words .Oo .Fl aes128 | aes192 | aes256 | .Fl des | des3 .Oc .Op Fl out Ar file .Op Ar paramfile .Ek .nr nS 0

p The .Nm gendsa command generates a DSA private key from a DSA parameter file (which will typically be generated by the .Nm openssl dsaparam command).

p The options are as follows: l -tag -width Ds t Xo .Fl aes128 | aes192 | aes256 | .Fl des | des3 .Xc These options 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. t Fl out Ar file The output .Ar file . If this argument is not specified, standard output is used. t Ar paramfile This option specifies the DSA parameter file to use. The parameters in this file determine the size of the private key. DSA parameters can be generated and examined using the .Nm openssl dsaparam command. .El .Sh GENDSA NOTES DSA key generation is little more than random number generation so it is much quicker than RSA key generation, for example.
GENPKEY

.Sh GENPKEY .nr nS 1 .Nm "openssl genpkey" k -words .Op Fl algorithm Ar alg .Op Ar cipher .Op Fl genparam .Op Fl out Ar file .Op Fl outform Ar DER | PEM .Op Fl paramfile Ar file .Op Fl pass Ar arg .Op Fl pkeyopt Ar opt : Ns Ar value .Op Fl text .Ek .nr nS 0

p 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.

p The options are as follows: l -tag -width Ds t Fl algorithm Ar alg The public key algorithm to use, such as RSA, DSA, or DH. If used this option must precede any .Fl pkeyopt options. The options .Fl paramfile and .Fl algorithm are mutually exclusive. t Ar cipher Encrypt the private key with the supplied cipher. Any algorithm name accepted by .Fn EVP_get_cipherbyname is acceptable, such as .Cm des3 . t Fl genparam Generate a set of parameters instead of a private key. If used this option must precede any .Fl algorithm , .Fl paramfile , or .Fl pkeyopt options. t Fl out Ar file The output filename. If this argument is not specified then standard output is used. t Fl outform Ar DER | PEM This specifies the output format, DER or PEM. t Fl paramfile Ar file Some public key algorithms generate a private key based on a set of parameters. They can be supplied using this option. If this option is used the public key algorithm used is determined by the parameters. If used this option must precede any .Fl pkeyopt options. The options .Fl paramfile and .Fl algorithm are mutually exclusive. t Fl pass Ar arg The output file password source. t Fl pkeyopt Ar opt : Ns Ar value Set the public key algorithm option .Ar opt to .Ar value . The precise set of options supported depends on the public key algorithm used and its implementation. See .Sx GENPKEY KEY GENERATION OPTIONS below for more details. t Fl text Print an (unencrypted) text representation of private and public keys and parameters along with the DER or PEM structure. .El .Sh GENPKEY KEY GENERATION OPTIONS The options supported by each algorithm and indeed each implementation of an algorithm can vary. The options for the .Nm OpenSSL implementations are detailed below. l -tag -width Ds -offset indent t rsa_keygen_bits : Ns Ar numbits (RSA) The number of bits in the generated key. If not specified 2048 is used. t 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 value is 65537. t dsa_paramgen_bits : Ns Ar numbits (DSA) The number of bits in the generated parameters. If not specified 1024 is used. t dh_paramgen_prime_len : Ns Ar numbits (DH) The number of bits in the prime parameter .Ar p . t dh_paramgen_generator : Ns Ar value (DH) The value to use for the generator .Ar g . t ec_paramgen_curve : Ns Ar curve (EC) The EC curve to use. .El .Sh GENPKEY EXAMPLES Generate an RSA private key using default parameters: d -literal -offset indent $ openssl genpkey -algorithm RSA -out key.pem .Ed

p Encrypt and output a private key using 128-bit AES and the passphrase "hello": d -literal -offset indent $ openssl genpkey -algorithm RSA -out key.pem \e -aes-128-cbc -pass pass:hello .Ed

p Generate a 2048-bit RSA key using 3 as the public exponent: d -literal -offset indent $ openssl genpkey -algorithm RSA -out key.pem \e -pkeyopt rsa_keygen_bits:2048 -pkeyopt rsa_keygen_pubexp:3 .Ed

p Generate 1024-bit DSA parameters: d -literal -offset indent $ openssl genpkey -genparam -algorithm DSA \e -out dsap.pem -pkeyopt dsa_paramgen_bits:1024 .Ed

p Generate a DSA key from parameters: d -literal -offset indent $ openssl genpkey -paramfile dsap.pem -out dsakey.pem .Ed

p Generate 1024-bit DH parameters: d -literal -offset indent $ openssl genpkey -genparam -algorithm DH \e -out dhp.pem -pkeyopt dh_paramgen_prime_len:1024 .Ed

p Generate a DH key from parameters: d -literal -offset indent $ openssl genpkey -paramfile dhp.pem -out dhkey.pem .Ed
GENRSA

.Sh GENRSA .nr nS 1 .Nm "openssl genrsa" k -words .Op Fl 3 | f4 .Oo .Fl aes128 | aes192 | aes256 | .Fl des | des3 .Oc .Op Fl out Ar file .Op Fl passout Ar arg .Op Ar numbits .Ek .nr nS 0

p The .Nm genrsa command generates an RSA private key.

p The options are as follows: l -tag -width Ds t Fl 3 | f4 The public exponent to use, either 3 or 65537. The default is 65537. t Xo .Fl aes128 | aes192 | aes256 | .Fl des | des3 .Xc These options 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. t Fl out Ar file The output .Ar file . If this argument is not specified, standard output is used. t Fl passout Ar arg The output file password source. t 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 GENRSA NOTES RSA private key generation essentially involves the generation of two prime numbers. When generating a private 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

q the actual number depends on the key size .

p Because key generation is a random process, the time taken to generate a key may vary somewhat. .Sh GENRSA BUGS A quirk of the prime generation algorithm is that it cannot generate small primes. Therefore the number of bits should not be less that 64. For typical private keys this will not matter because for security reasons they will be much larger

q typically 2048 bits .
NSEQ

.Sh NSEQ .Nm openssl nseq .Op Fl in Ar file .Op Fl out Ar file .Op Fl toseq

p The .Nm nseq command takes a file containing a Netscape certificate sequence and prints out the certificates contained in it or takes a file of certificates and converts it into a Netscape certificate sequence.

p The options are as follows: l -tag -width Ds t Fl in Ar file This specifies the input .Ar file to read, or standard input if this option is not specified. t Fl out Ar file Specifies the output .Ar file , or standard output by default. t 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 NSEQ EXAMPLES Output the certificates in a Netscape certificate sequence: d -literal -offset indent $ openssl nseq -in nseq.pem -out certs.pem .Ed

p Create a Netscape certificate sequence: d -literal -offset indent $ openssl nseq -in certs.pem -toseq -out nseq.pem .Ed .Sh NSEQ NOTES The PEM-encoded form uses the same headers and footers as a certificate: d -unfilled -offset indent -----BEGIN CERTIFICATE----- -----END CERTIFICATE----- .Ed

p A Netscape certificate sequence is a Netscape specific form that can be sent to browsers as an alternative to the standard PKCS#7 format when several certificates are sent to the browser: for example during certificate enrollment. It is used by the Netscape certificate server, for example. .Sh NSEQ BUGS This program needs a few more options, like allowing DER or PEM input and output files and allowing multiple certificate files to be used.
OCSP

.Sh OCSP .nr nS 1 .Nm "openssl ocsp" k -words .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 .Oo .Fl host .Ar hostname : Ns Ar port .Oc .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 .Ek .nr nS 0

p The Online Certificate Status Protocol

q OCSP enables applications to determine the

q revocation state of an identified certificate

q RFC 2560 .

p 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.

p The options are as follows: l -tag -width Ds t Fl CAfile Ar file , Fl CApath Ar directory .Ar file or .Ar path containing trusted CA certificates. These are used to verify the signature on the OCSP response. t 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. t Fl dgst Ar alg Sets the digest algorithm to use for certificate identification in the OCSP request. By default SHA-1 is used. t Xo .Fl host Ar hostname : Ns Ar port , .Fl path Ar path .Xc If the .Fl host option is present, then the OCSP request is sent to the host .Ar hostname on port .Ar port . .Fl path specifies the HTTP path name to use, or .Sq / by default. t Fl issuer Ar file This specifies the current issuer certificate. This option can be used multiple times. The certificate specified in .Ar file must be in PEM format. This option .Em must come before any .Fl cert options. t 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. t 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. t Fl no_certs Don't include any certificates in signed request. t Fl no_chain Do not use certificates in the response as additional untrusted CA certificates. t Fl no_intern Ignore certificates contained in the OCSP response when searching for the signer's certificate. With this option, the signer's certificate must be specified with either the .Fl verify_other or .Fl VAfile options. t 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. t Fl nonce , no_nonce Add an OCSP .Em nonce extension to a request or disable an OCSP .Em nonce addition. Normally, if an OCSP request is input using the .Fl respin option no .Em nonce is added: using the .Fl nonce option will force addition of a .Em nonce . If an OCSP request is being created (using the .Fl cert and .Fl serial options) a .Em nonce is automatically added; specifying .Fl no_nonce overrides this. t Fl noverify Don't attempt to verify the OCSP response signature or the .Em nonce values. This option will normally only be used for debugging since it disables all verification of the responder's certificate. t Fl out Ar file Specify output .Ar file ; default is standard output. t Fl req_text , resp_text , text Print out the text form of the OCSP request, response, or both, respectively. t 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). t Fl reqout Ar file , Fl respout Ar file Write out the DER-encoded certificate request or response to .Ar file . t 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 .Sq - sign. t Fl sign_other Ar file Additional certificates to include in the signed request. t 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. t 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. t Fl url Ar responder_url Specify the responder URL. Both HTTP and HTTPS

q SSL/TLS URLs can be specified. t Fl VAfile Ar file .Ar file containing explicitly trusted responder certificates. Equivalent to the .Fl verify_other and .Fl trust_other options. t Fl validity_period Ar nsec , Fl status_age Ar age These options specify the range of times, in seconds, which will be tolerated in an OCSP response. Each certificate status response includes a .Em notBefore time and an optional .Em 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 is 5 minutes.

p If the .Em notAfter time is omitted from a response, then this means that new status information is immediately available. In this case the age of the .Em notBefore field is checked to see it is not older than .Ar age seconds old. By default, this additional check is not performed. t Fl verify_other Ar file .Ar 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; this option can be used to supply the necessary certificate in such cases. .El .Sh OCSP SERVER OPTIONS l -tag -width "XXXX" t Fl CA Ar file CA certificate corresponding to the revocation information in .Ar indexfile . t Fl index Ar indexfile .Ar indexfile is a text index file in .Nm ca format containing certificate revocation information.

p If the .Fl index option is specified, the .Nm ocsp utility is in .Em responder mode, otherwise it is in .Em client mode. The request(s) 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).

p If the .Fl index option is present, then the .Fl CA and .Fl rsigner options must also be present. t Fl nmin Ar minutes , Fl ndays Ar days Number of .Ar minutes or .Ar days when fresh revocation information is available: used in the .Ar nextUpdate field. If neither option is present, the .Em nextUpdate field is omitted, meaning fresh revocation information is immediately available. t Fl nrequest Ar number The OCSP server will exit after receiving .Ar number requests, default unlimited. t Fl port Ar portnum Port to listen for OCSP requests on. The port may also be specified using the .Fl url option. t Fl resp_key_id Identify the signer certificate using the key ID; default is to use the subject name. t Fl resp_no_certs Don't include any certificates in the OCSP response. t 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. t Fl rother Ar file Additional certificates to include in the OCSP response. t Fl rsigner Ar file The certificate to sign OCSP responses with. .El .Sh OCSP RESPONSE VERIFICATION OCSP Response follows the rules specified in RFC 2560.

p Initially the OCSP responder certificate is located and the signature on the OCSP request checked using the responder certificate's public key.

p 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.

p If the initial verify fails, the OCSP verify process halts with an error.

p 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.

p 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.

p 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.

p If none of these checks is successful, the OCSP verify fails.

p What this effectively means is that if the OCSP responder certificate is authorised directly by the CA it is issuing revocation information about

q and it is correctly configured , then verification will succeed.

p If the OCSP responder is a .Em 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: d -literal -offset indent $ openssl x509 -in ocspCA.pem -addtrust OCSPSigning \e -out trustedCA.pem .Ed

p Alternatively, the responder certificate itself can be explicitly trusted with the .Fl VAfile option. .Sh OCSP NOTES As noted, most of the verify options are for testing or debugging purposes. Normally, only the .Fl CApath , CAfile and

q if the responder is a `global VA' .Fl VAfile options need to be used.

p The OCSP server is only useful for test and demonstration purposes: it is not really usable as a full OCSP responder. It contains only a very simple HTTP request handling and can only handle the POST form of OCSP queries. It also handles requests serially, meaning it cannot respond to new requests until it has processed the current one. The text index file format of revocation is also inefficient for large quantities of revocation data.

p It is possible to run the .Nm ocsp application in .Em responder mode via a CGI script using the .Fl respin and .Fl respout options. .Sh OCSP EXAMPLES Create an OCSP request and write it to a file: d -literal -offset indent $ openssl ocsp -issuer issuer.pem -cert c1.pem -cert c2.pem \e -reqout req.der .Ed

p Send a query to an OCSP responder with URL

a http://ocsp.myhost.com/ , save the response to a file and print it out in text form: d -literal -offset indent $ openssl ocsp -issuer issuer.pem -cert c1.pem -cert c2.pem \e -url http://ocsp.myhost.com/ -resp_text -respout resp.der .Ed

p Read in an OCSP response and print out in text form:

p .Dl $ openssl ocsp -respin resp.der -text

p OCSP server on port 8888 using a standard .Nm ca configuration, and a separate responder certificate. All requests and responses are printed to a file: d -literal -offset indent $ openssl ocsp -index demoCA/index.txt -port 8888 -rsigner \e rcert.pem -CA demoCA/cacert.pem -text -out log.txt .Ed

p As above, but exit after processing one request: d -literal -offset indent $ openssl ocsp -index demoCA/index.txt -port 8888 -rsigner \e rcert.pem -CA demoCA/cacert.pem -nrequest 1 .Ed

p Query status information using internally generated request: d -literal -offset indent $ openssl ocsp -index demoCA/index.txt -rsigner rcert.pem -CA \e demoCA/cacert.pem -issuer demoCA/cacert.pem -serial 1 .Ed

p Query status information using request read from a file and write the response to a second file: d -literal -offset indent $ openssl ocsp -index demoCA/index.txt -rsigner rcert.pem -CA \e demoCA/cacert.pem -reqin req.der -respout resp.der .Ed
PASSWD

.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

p The .Nm passwd command computes the hash of a password typed at run-time or the hash of each password in a list. The password list is taken from the named .Ar file for option .Fl in , from stdin for option .Fl stdin , or from the command line, or from the terminal otherwise. The x standard algorithm .Em crypt and the MD5-based x password algorithm .Em 1 and its Apache variant .Em apr1 are available.

p The options are as follows: l -tag -width Ds t Fl 1 Use the MD5 based x password algorithm .Em 1 . t Fl apr1 Use the .Em apr1 algorithm

q Apache variant of the x algorithm. t Fl crypt Use the .Em crypt algorithm

q default . t Fl in Ar file Read passwords from .Ar file . t Fl noverify Don't verify when reading a password from the terminal. t Fl quiet Don't output warnings when passwords given on the command line are truncated. t Fl reverse Switch table columns. This only makes sense in conjunction with the .Fl table option. t Fl salt Ar string Use the specified .Ar salt . When reading a password from the terminal, this implies .Fl noverify . t Fl stdin Read passwords from .Em stdin . t Fl table In the output list, prepend the cleartext password and a TAB character to each password hash. .El .Sh PASSWD EXAMPLES .Dl $ openssl passwd -crypt -salt xx password prints .Qq xxj31ZMTZzkVA .

p .Dl $ openssl passwd -1 -salt xxxxxxxx password prints .Qq $1$xxxxxxxx$UYCIxa628.9qXjpQCjM4a. .

p .Dl $ openssl passwd -apr1 -salt xxxxxxxx password prints .Qq $apr1$xxxxxxxx$dxHfLAsjHkDRmG83UXe8K0 .
PKCS7

.Sh PKCS7 .nr nS 1 .Nm "openssl pkcs7" k -words .Op Fl in Ar file .Op Fl inform Ar DER | PEM .Op Fl noout .Op Fl out Ar file .Op Fl outform Ar DER | PEM .Op Fl print_certs .Op Fl text .Ek .nr nS 0

p The .Nm pkcs7 command processes PKCS#7 files in DER or PEM format.

p The options are as follows: l -tag -width Ds t Fl in Ar file This specifies the input .Ar file to read from, or standard input if this option is not specified. t Fl inform Ar DER | PEM This specifies the input format. .Ar DER format is a DER-encoded PKCS#7 v1.5 structure. .Ar PEM

q the default is a base64-encoded version of the DER form with header and footer lines. t Fl noout Don't output the encoded version of the PKCS#7 structure (or certificates if .Fl print_certs is set). t Fl out Ar file Specifies the output .Ar file to write to, or standard output by default. t Fl outform Ar DER | PEM This specifies the output format; the options have the same meaning as the .Fl inform option. t Fl print_certs Prints out any certificates or CRLs contained in the file. They are preceded by their subject and issuer names in a one-line format. t Fl text Prints out certificate details in full rather than just subject and issuer names. .El .Sh PKCS7 EXAMPLES Convert a PKCS#7 file from PEM to DER:

p .Dl $ openssl pkcs7 -in file.pem -outform DER -out file.der

p Output all certificates in a file:

p .Dl $ openssl pkcs7 -in file.pem -print_certs -out certs.pem .Sh PKCS7 NOTES The PEM PKCS#7 format uses the header and footer lines: d -unfilled -offset indent -----BEGIN PKCS7----- -----END PKCS7----- .Ed

p For compatibility with some CAs it will also accept: d -unfilled -offset indent -----BEGIN CERTIFICATE----- -----END CERTIFICATE----- .Ed .Sh PKCS7 RESTRICTIONS There is no option to print out all the fields of a PKCS#7 file.

p The PKCS#7 routines only understand PKCS#7 v 1.5 as specified in RFC 2315. They cannot currently parse, for example, the new CMS as described in RFC 2630.
PKCS8

.Sh PKCS8 .nr nS 1 .Nm "openssl pkcs8" k -words .Op Fl embed .Op Fl in Ar file .Op Fl inform Ar DER | PEM .Op Fl nocrypt .Op Fl noiter .Op Fl nooct .Op Fl nsdb .Op Fl out Ar file .Op Fl outform Ar 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 .Ek .nr nS 0

p The .Nm pkcs8 command processes private keys in PKCS#8 format. It can handle both unencrypted PKCS#8 PrivateKeyInfo format and EncryptedPrivateKeyInfo format with a variety of PKCS#5

q v1.5 and v2.0 and PKCS#12 algorithms.

p The options are as follows: l -tag -width Ds t Fl embed This option generates DSA keys in a broken format. The DSA parameters are embedded inside the .Em 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. t Fl in Ar file This specifies the input .Ar file to read a key from, or standard input if this option is not specified. If the key is encrypted, a pass phrase will be prompted for. t Fl inform Ar DER | PEM This specifies the input format. If a PKCS#8 format key is expected on input, then either a DER- or PEM-encoded version of a PKCS#8 key will be expected. Otherwise the DER or PEM format of the traditional format private key is used. t Fl nocrypt PKCS#8 keys generated or input are normally PKCS#8 .Em EncryptedPrivateKeyInfo structures using an appropriate password-based encryption algorithm. With this option, an unencrypted .Em PrivateKeyInfo structure is expected or output. This option does not encrypt private keys at all and should only be used when absolutely necessary. Certain software such as some versions of Java code signing software use unencrypted private keys. t Fl noiter Use an iteration count of 1. See the .Sx PKCS12 section below for a detailed explanation of this option. t Fl nooct This option generates 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. t Fl nsdb This option generates DSA keys in a broken format compatible with Netscape private key databases. The .Em PrivateKey contains a SEQUENCE consisting of the public and private keys, respectively. t Fl out Ar file This specifies the output .Ar file to write a key to, or standard output by default. If any encryption options are set, a pass phrase will be prompted for. The output filename should .Em not be the same as the input filename. t Fl outform Ar DER | PEM This specifies the output format; the options have the same meaning as the .Fl inform option. t Fl passin Ar arg The key password source. t Fl passout Ar arg The output file password source. t Fl topk8 Normally, a PKCS#8 private key is expected on input and a traditional format private key will be written. With the .Fl topk8 option the situation is reversed: it reads a traditional format private key and writes a PKCS#8 format key. t Fl v1 Ar alg This option specifies a PKCS#5 v1.5 or PKCS#12 algorithm to use. A complete list of possible algorithms is included below. t Fl v2 Ar alg This option enables the use of PKCS#5 v2.0 algorithms. Normally, PKCS#8 private keys are encrypted with the password-based encryption algorithm called .Em pbeWithMD5AndDES-CBC ; this uses 56-bit DES encryption but it was the strongest encryption algorithm supported in PKCS#5 v1.5. Using the .Fl v2 option PKCS#5 v2.0 algorithms are used which can use any encryption algorithm 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 then this doesn't matter.

p The .Ar alg argument is the encryption algorithm to use; valid values include .Ar des , des3 , and .Ar rc2 . It is recommended that .Ar des3 is used. .El .Sh PKCS8 NOTES The encrypted form of a PEM-encoded PKCS#8 file uses the following headers and footers: d -unfilled -offset indent -----BEGIN ENCRYPTED PRIVATE KEY----- -----END ENCRYPTED PRIVATE KEY----- .Ed

p The unencrypted form uses: d -unfilled -offset indent -----BEGIN PRIVATE KEY----- -----END PRIVATE KEY----- .Ed

p Private keys encrypted using PKCS#5 v2.0 algorithms and high iteration counts are more secure than those encrypted using the traditional .Nm SSLeay compatible formats. So if additional security is considered important, the keys should be converted.

p The default encryption is only 56 bits because this is the encryption that most current implementations of PKCS#8 support.

p Some software may use PKCS#12 password-based encryption algorithms with PKCS#8 format private keys: these are handled automatically but there is no option to produce them.

p It is possible to write out DER-encoded encrypted private keys in PKCS#8 format because the encryption details are included at an ASN1 level whereas the traditional format includes them at a PEM level. .Sh PKCS#5 V1.5 AND PKCS#12 ALGORITHMS Various algorithms can be used with the .Fl v1 command line option, including PKCS#5 v1.5 and PKCS#12. These are described in more detail below.

p l -tag -width "XXXX" -compact t Ar PBE-MD5-DES These algorithms were included in the original PKCS#5 v1.5 specification. They only offer 56 bits of protection since they both use DES.

p t Ar PBE-SHA1-RC2-64 | PBE-MD5-RC2-64 | PBE-SHA1-DES These algorithms are not mentioned in the original PKCS#5 v1.5 specification but they use the same key derivation algorithm and are supported by some software. They are mentioned in PKCS#5 v2.0. They use either 64-bit RC2 or 56-bit DES.

p t Ar PBE-SHA1-RC4-128 | PBE-SHA1-RC4-40 | PBE-SHA1-3DES | PBE-SHA1-2DES t Ar PBE-SHA1-RC2-128 | PBE-SHA1-RC2-40 These algorithms use the PKCS#12 password-based encryption algorithm and allow strong encryption algorithms like triple DES or 128-bit RC2 to be used. .El .Sh PKCS8 EXAMPLES Convert a private key from traditional to PKCS#5 v2.0 format using triple DES:

p .Dl "$ openssl pkcs8 -in key.pem -topk8 -v2 des3 -out enckey.pem"

p Convert a private key to PKCS#8 using a PKCS#5 1.5 compatible algorithm

q DES :

p .Dl $ openssl pkcs8 -in key.pem -topk8 -out enckey.pem

p Convert a private key to PKCS#8 using a PKCS#12 compatible algorithm

q 3DES : d -literal -offset indent $ openssl pkcs8 -in key.pem -topk8 -out enckey.pem \e -v1 PBE-SHA1-3DES .Ed

p Read a DER-unencrypted PKCS#8 format private key:

p .Dl "$ openssl pkcs8 -inform DER -nocrypt -in key.der -out key.pem"

p Convert a private key from any PKCS#8 format to traditional format:

p .Dl $ openssl pkcs8 -in pk8.pem -out key.pem .Sh PKCS8 STANDARDS Test vectors from this PKCS#5 v2.0 implementation were posted to the pkcs-tng mailing list using triple DES, DES and RC2 with high iteration counts; several people confirmed that they could decrypt the private keys produced and therefore it can be assumed that the PKCS#5 v2.0 implementation is reasonably accurate at least as far as these algorithms are concerned.

p The format of PKCS#8 DSA

q and other private keys is not well documented: it is hidden away in PKCS#11 v2.01, section 11.9; .Nm OpenSSL Ns Li 's default DSA PKCS#8 private key format complies with this standard. .Sh PKCS8 BUGS There should be an option that prints out the encryption algorithm in use and other details such as the iteration count.

p PKCS#8 using triple DES and PKCS#5 v2.0 should be the default private key format; for .Nm OpenSSL compatibility, several of the utilities use the old format at present.
PKCS12

.Sh PKCS12 .nr nS 1 .Nm "openssl pkcs12" k -words .Oo .Fl aes128 | aes192 | aes256 | .Fl des | des3 .Oc .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 .Ek .nr nS 0

p The .Nm pkcs12 command allows PKCS#12 files

q sometimes referred to as PFX files to be created and parsed. PKCS#12 files are used by several programs including Netscape, MSIE and MS Outlook.

p There are a lot of options; the meaning of some depends on whether a PKCS#12 file is being created or parsed. By default, a PKCS#12 file is parsed; a PKCS#12 file can be created by using the .Fl export option

q see below . .Sh PKCS12 PARSING OPTIONS l -tag -width "XXXX" t Xo .Fl aes128 | aes192 | aes256 | .Fl des | des3 .Xc Use AES, DES, or triple DES, respectively, to encrypt private keys before outputting. The default is triple DES. t Fl cacerts Only output CA certificates

q not client certificates . t Fl clcerts Only output client certificates

q not CA certificates . t Fl in Ar file This specifies the .Ar file of the PKCS#12 file to be parsed. Standard input is used by default. t Fl info Output additional information about the PKCS#12 file structure, algorithms used, and iteration counts. t Fl nocerts No certificates at all will be output. t Fl nodes Don't encrypt the private keys at all. t Fl nokeys No private keys will be output. t Fl nomacver Don't attempt to verify the integrity MAC before reading the file. t Fl noout This option inhibits output of the keys and certificates to the output file version of the PKCS#12 file. t Fl out Ar file The .Ar file to write certificates and private keys to, standard output by default. They are all written in PEM format. t Fl passin Ar arg The key password source. t Fl passout Ar arg The output file password source. t 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 .Sh PKCS12 FILE CREATION OPTIONS l -tag -width "XXXX" t Fl CAfile Ar file CA storage as a file. t Fl CApath Ar directory CA storage as a directory. This directory must be a standard certificate directory: that is, a hash of each subject name (using .Cm x509 -hash ) should be linked to each certificate. t Fl caname Ar name This specifies the .Qq friendly name for other certificates. This option may be used multiple times to specify names for all certificates in the order they appear. Netscape ignores friendly names on other certificates, whereas MSIE displays them. t Fl certfile Ar file A file to read additional certificates from. t Fl certpbe Ar alg , Fl keypbe Ar alg These options allow 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 (see the .Sx PKCS12 NOTES section for more information). 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. t Fl chain If this option is present, an attempt is made to 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. t Fl CSP Ar name Write .Ar name as a Microsoft CSP name. t 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. t Fl export This option specifies that a PKCS#12 file will be created rather than parsed. t Fl in Ar file The .Ar file to read certificates and private keys from, standard input by default. They must all be 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. t Fl inkey Ar file File to read private key from. If not present, a private key must be present in the input file. t Fl keyex | keysig Specifies that the private key is to be used for key exchange or just signing. This option is only interpreted by MSIE and similar MS software. 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

q ActiveX control signing and SSL client authentication; however, due to a bug only MSIE 5.0 and later support the use of signing only keys for SSL client authentication. t Fl macalg Ar alg Specify the MAC digest algorithm. If not included then SHA1 is used. t Fl maciter This option is included for compatibility with previous versions; it used to be needed to use MAC iterations counts but they are now used by default. t Fl name Ar name This specifies the .Qq friendly name for the certificate and private key. This name is typically displayed in list boxes by software importing the file. t Fl nomac Don't attempt to provide the MAC integrity. t Fl nomaciter , noiter These options 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.

p 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. t Fl out Ar file This specifies .Ar file to write the PKCS#12 file to. Standard output is used by default. t Fl passin Ar arg The key password source. t Fl passout Ar arg The output file password source. .El .Sh PKCS12 NOTES Although there are a large number of options, most of them are very rarely used. For PKCS#12 file parsing, only .Fl in and .Fl out need to be used for PKCS#12 file creation. .Fl export and .Fl name are also used.

p If none of the .Fl clcerts , cacerts , or .Fl nocerts options are present, then all certificates will be output in the order they appear in the input PKCS#12 files. There is no guarantee that the first certificate present is the one corresponding to the private key. Certain software which requires a private key and certificate and assumes the first certificate in the file is the one corresponding to the private key: this may not always be the case. Using the .Fl clcerts option will solve this problem by only outputting the certificate corresponding to the private key. If the CA certificates are required, they can be output to a separate file using the .Fl nokeys and .Fl cacerts options to just output CA certificates.

p The .Fl keypbe and .Fl certpbe algorithms allow the precise encryption algorithms for private keys and certificates to be specified. Normally, the defaults are fine but occasionally software can't handle triple DES encrypted private keys; then the option .Fl keypbe Ar PBE-SHA1-RC2-40 can be used to reduce the private key encryption to 40-bit RC2. A complete description of all algorithms is contained in the .Sx PKCS8 section above. .Sh PKCS12 EXAMPLES Parse a PKCS#12 file and output it to a file:

p .Dl $ openssl pkcs12 -in file.p12 -out file.pem

p Output only client certificates to a file:

p .Dl $ openssl pkcs12 -in file.p12 -clcerts -out file.pem

p Don't encrypt the private key:

p .Dl $ openssl pkcs12 -in file.p12 -out file.pem -nodes

p Print some info about a PKCS#12 file:

p .Dl $ openssl pkcs12 -in file.p12 -info -noout

p Create a PKCS#12 file: d -literal -offset indent $ openssl pkcs12 -export -in file.pem -out file.p12 \e -name "My Certificate" .Ed

p Include some extra certificates: d -literal -offset indent $ openssl pkcs12 -export -in file.pem -out file.p12 \e -name "My Certificate" -certfile othercerts.pem .Ed .Sh PKCS12 BUGS Some would argue that the PKCS#12 standard is one big bug :-)

p Versions of .Nm OpenSSL before 0.9.6a had a bug in the PKCS#12 key generation routines. Under rare circumstances this could produce a PKCS#12 file encrypted with an invalid key. As a result some PKCS#12 files which triggered this bug from other implementations

q MSIE or Netscape could not be decrypted by .Nm OpenSSL and similarly .Nm OpenSSL could produce PKCS#12 files which could not be decrypted by other implementations. The chances of producing such a file are relatively small: less than 1 in 256.

p A side effect of fixing this bug is that any old invalidly encrypted PKCS#12 files can no longer be parsed by the fixed version. Under such circumstances the .Nm pkcs12 utility will report that the MAC is OK but fail with a decryption error when extracting private keys.

p This problem can be resolved by extracting the private keys and certificates from the PKCS#12 file using an older version of .Nm OpenSSL and recreating the PKCS#12 file from the keys and certificates using a newer version of .Nm OpenSSL . For example: d -literal -offset indent $ old-openssl -in bad.p12 -out keycerts.pem $ openssl -in keycerts.pem -export -name "My PKCS#12 file" \e -out fixed.p12 .Ed
PKEY

.Sh PKEY .nr nS 1 .Nm "openssl pkey" k -words .Op Ar cipher .Op Fl in Ar file .Op Fl inform Ar DER | PEM .Op Fl noout .Op Fl out Ar file .Op Fl outform Ar 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 .Ek .nr nS 0

p The .Nm pkey command processes public or private keys. They can be converted between various forms and their components printed out.

p The options are as follows: l -tag -width Ds t Ar cipher These options encrypt the private key with the supplied cipher. Any algorithm name accepted by .Fn EVP_get_cipherbyname is acceptable, such as .Cm des3 . t Fl in Ar file This specifies the input filename to read a key from, or standard input if this option is not specified. If the key is encrypted a pass phrase will be prompted for. t Fl inform Ar DER | PEM This specifies the input format, DER or PEM. t Fl noout Do not output the encoded version of the key. t Fl out Ar file This specifies the output filename to write a key to, or standard output if this option is not specified. If any encryption options are set then a pass phrase will be prompted for. The output filename should .Em not be the same as the input filename. t Fl outform Ar DER | PEM This specifies the output format; the options have the same meaning as the .Fl inform option. t Fl passin Ar arg The key password source. t Fl passout Ar arg The output file password source. t Fl pubin By default a private key is read from the input file: with this option a public key is read instead. t Fl pubout By default a private key is output: with this option a public key will be output instead. This option is automatically set if the input is a public key. t Fl text Print out the various public or private key components in plain text in addition to the encoded version. t Fl text_pub Print out only public key components even if a private key is being processed. .El .Sh PKEY EXAMPLES To remove the pass phrase on an RSA private key: d -literal -offset indent $ openssl pkey -in key.pem -out keyout.pem .Ed

p To encrypt a private key using triple DES: d -literal -offset indent $ openssl pkey -in key.pem -des3 -out keyout.pem .Ed

p To convert a private key from PEM to DER format: d -literal -offset indent $ openssl pkey -in key.pem -outform DER -out keyout.der .Ed

p To print the components of a private key to standard output: d -literal -offset indent $ openssl pkey -in key.pem -text -noout .Ed

p To print the public components of a private key to standard output: d -literal -offset indent $ openssl pkey -in key.pem -text_pub -noout .Ed

p To just output the public part of a private key: d -literal -offset indent $ openssl pkey -in key.pem -pubout -out pubkey.pem .Ed
PKEYPARAM

.Sh PKEYPARAM .Cm openssl pkeyparam .Op Fl in Ar file .Op Fl noout .Op Fl out Ar file .Op Fl text

p The .Nm pkey command processes public or private keys. They can be converted between various forms and their components printed out.

p The options are as follows: l -tag -width Ds t Fl in Ar file This specifies the input filename to read parameters from, or standard input if this option is not specified. t Fl noout Do not output the encoded version of the parameters. t Fl out Ar file This specifies the output filename to write parameters to, or standard output if this option is not specified. t Fl text Prints out the parameters in plain text in addition to the encoded version. .El .Sh PKEYPARAM EXAMPLES Print out text version of parameters: d -literal -offset indent $ openssl pkeyparam -in param.pem -text .Ed .Sh PKEYPARAM NOTES There are no .Fl inform or .Fl outform options for this command because only PEM format is supported because the key type is determined by the PEM headers.
PKEYUTL

.Sh PKEYUTL .nr nS 1 .Nm "openssl pkeyutl" k -words .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 Ar DER | PEM .Op Fl out Ar file .Op Fl passin Ar arg .Op Fl peerform Ar 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 .Ek .nr nS 0

p The .Nm pkeyutl command can be used to perform public key operations using any supported algorithm.

p The options are as follows: l -tag -width Ds t Fl asn1parse ASN1parse the output data. This is useful when combined with the .Fl verifyrecover option when an ASN1 structure is signed. t Fl certin The input is a certificate containing a public key. t Fl decrypt Decrypt the input data using a private key. t Fl derive Derive a shared secret using the peer key. t Fl encrypt Encrypt the input data using a public key. t Fl hexdump Hex dump the output data. t Fl in Ar file Specify the input filename to read data from, or standard input if this option is not specified. t Fl inkey Ar file The input key file. By default it should be a private key. t Fl keyform Ar DER | PEM The key format DER or PEM. t Fl out Ar file Specify the output filename to write to, or standard output by default. t Fl passin Ar arg The key password source. t Fl peerform Ar DER | PEM The peer key format DER or PEM. t Fl peerkey Ar file The peer key file, used by key derivation (agreement) operations. t Fl pkeyopt Ar opt : Ns Ar value Public key options. t Fl pubin The input file is a public key. t Fl rev Reverse the order of the input buffer. This is useful for some libraries (such as CryptoAPI) which represent the buffer in little endian format. t Fl sigfile Ar file Signature file (verify operation only). t Fl sign Sign the input data and output the signed result. This requires a private key. t Fl verify Verify the input data against the signature file and indicate if the verification succeeded or failed. t Fl verifyrecover Verify the input data and output the recovered data. .El .Sh PKEYUTL NOTES The operations and options supported vary according to the key algorithm and its implementation. The .Nm OpenSSL operations and options are indicated below.

p Unless otherwise mentioned all algorithms support the .Ar digest : Ns Ar alg option which specifies the digest in use for sign, verify, and verifyrecover operations. The value .Ar alg should represent a digest name as used in the .Fn EVP_get_digestbyname function, for example .Cm sha1 . .Ss RSA algorithm The RSA algorithm supports the encrypt, decrypt, sign, verify, and verifyrecover operations in general. Some padding modes only support some of these operations however. l -tag -width Ds t 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.

p 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.

p For oeap mode only encryption and decryption is supported.

p 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.

p For pss mode only sign and verify are supported and the digest type must be specified. t 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 .Ss DSA algorithm 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. .Ss DH algorithm The DH algorithm supports the derive operation and no additional options. .Ss EC algorithm 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. .Sh PKEYUTL EXAMPLES Sign some data using a private key: d -literal -offset indent $ openssl pkeyutl -sign -in file -inkey key.pem -out sig .Ed

p Recover the signed data (e.g. if an RSA key is used): d -literal -offset indent $ openssl pkeyutl -verifyrecover -in sig -inkey key.pem .Ed

p Verify the signature (e.g. a DSA key): d -literal -offset indent $ openssl pkeyutl -verify -in file -sigfile sig \e -inkey key.pem .Ed

p Sign data using a message digest value (this is currently only valid for RSA): d -literal -offset indent $ openssl pkeyutl -sign -in file -inkey key.pem \e -out sig -pkeyopt digest:sha256 .Ed

p Derive a shared secret value: d -literal -offset indent $ openssl pkeyutl -derive -inkey key.pem \e -peerkey pubkey.pem -out secret .Ed
PRIME

.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

p 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.

p The options are as follows: l -tag -width Ds t Fl bits Ar n Specify the number of bits in the generated prime number. Must be used in conjunction with .Fl generate . t Fl checks Ar n Perform a Miller-Rabin probabilistic primality test with .Ar n iterations. The default is 20. t Fl generate Generate a pseudo-random prime number. Must be used in conjunction with .Fl bits . t Fl hex Output in hex format. t Fl safe Generate only .Qq safe prime numbers (i.e. a prime p so that (p-1)/2 is also prime). t Ar p Test if number .Ar p is prime. .El
RAND

.Sh RAND .nr nS 1 .Nm "openssl rand" .Op Fl base64 .Op Fl hex .Op Fl out Ar file .Ar num .nr nS 0

p The .Nm rand command outputs .Ar num pseudo-random bytes.

p The options are as follows: l -tag -width Ds t Fl base64 Perform .Em base64 encoding on the output. t Fl hex Specify hexadecimal output. t Fl out Ar file Write to .Ar file instead of standard output. .El
REQ

.Sh REQ .nr nS 1 .Nm "openssl req" k -words .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 Ar DER | PEM .Op Fl key Ar keyfile .Op Fl keyform Ar 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 Ar 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 .Ek .nr nS 0

p 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.

p The options are as follows: l -tag -width Ds t Fl asn1-kludge By default, the .Nm req command outputs certificate requests containing no attributes in the correct PKCS#10 format. However certain CAs will only accept requests containing no attributes in an invalid form: this option produces this invalid format.

p More precisely, the .Em Attributes in a PKCS#10 certificate request are defined as a SET OF Attribute. They are .Em not optional, so if no attributes are present then they should be encoded as an empty SET OF. The invalid form does not include the empty SET OF, whereas the correct form does.

p It should be noted that very few CAs still require the use of this option. t Fl batch Non-interactive mode. t Fl config Ar file This allows an alternative configuration file to be specified; this overrides the compile time filename or any specified in the .Ev OPENSSL_CONF environment variable. t Fl days Ar n When the .Fl x509 option is being used, this specifies the number of days to certify the certificate for. The default is 30 days. t Fl extensions Ar section , Fl reqexts Ar section These options specify alternative sections to include certificate extensions (if the .Fl x509 option is present) or certificate request extensions. This allows several different sections to be used in the same configuration file to specify requests for a variety of purposes. t Fl in Ar file This specifies the input .Ar file to read a request from, or standard input if this option is not specified. A request is only read if the creation options .Fl new and .Fl newkey are not specified. t Fl inform Ar DER | PEM This specifies the input format. The .Ar DER argument uses an ASN1 DER-encoded form compatible with the PKCS#10. The .Ar PEM form is the default format: it consists of the DER format base64-encoded with additional header and footer lines. t Fl key Ar keyfile This specifies the file to read the private key from. It also accepts PKCS#8 format private keys for PEM format files. t Fl keyform Ar DER | PEM The format of the private key file specified in the .Fl key argument. .Ar PEM is the default. t Fl keyout Ar file This gives the .Ar file to write the newly created private key to. If this option is not specified, the filename present in the configuration file is used. t Fl md5 | sha1 | sha256 This specifies the message digest to sign the request with. This overrides the digest algorithm specified in the configuration file.

p Some public key algorithms may override this choice. For instance, DSA signatures always use SHA1. t Fl modulus This option prints out the value of the modulus of the public key contained in the request. t Fl nameopt Ar option , Fl reqopt Ar option These options determine how the subject or issuer names are displayed. The .Ar option argument 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. t Fl new This option generates a new certificate request. It will prompt the user 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.

p If the .Fl key option is not used, it will generate a new RSA private key using information specified in the configuration file. t Fl newhdr Adds the word NEW to the PEM file header and footer lines on the outputed request. Some software

q Netscape certificate server and some CAs need this. t Fl newkey Ar arg This option creates a new certificate request and a new private key. The argument takes one of several forms. .Ar rsa : Ns Ar nbits , where .Ar nbits is the number of bits, generates an RSA key .Ar nbits in size. If .Ar nbits is omitted, i.e.\& .Cm -newkey rsa specified, the default key size, specified in the configuration file, is used.

p All other algorithms support the .Ar alg : Ns Ar file form, 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.

p .Ar param : Ns Ar file generates a key using the parameter file or certificate .Ar file ; the algorithm is determined by the parameters. .Ar algname : Ns Ar file use algorithm .Ar algname and parameter file .Ar file : the two algorithms must match or an error occurs. .Ar algname just uses algorithm .Ar algname , and parameters, if necessary, should be specified via the .Fl pkeyopt option.

p .Ar dsa : Ns Ar file generates a DSA key using the parameters in the file .Ar file . t Fl no-asn1-kludge Reverses the effect of .Fl asn1-kludge . t Fl nodes If this option is specified and a private key is created, it will not be encrypted. t Fl noout This option prevents output of the encoded version of the request. t Fl out Ar file This specifies the output .Ar file to write to, or standard output by default. t Fl outform Ar DER | PEM This specifies the output format; the options have the same meaning as the .Fl inform option. t Fl passin Ar arg The key password source. t Fl passout Ar arg The output file password source. t Fl pubkey Outputs the public key. t 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.

p See the discussion of the .Fl certopt option in the .Nm x509 command. t 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. t Fl subj Ar arg Replaces subject field of input request with specified data and outputs modified request. The arg must be formatted as .Em /type0=value0/type1=value1/type2=... ; characters may be escaped by .Sq \e

q backslash ; no spaces are skipped. t Fl subject Prints out the request subject (or certificate subject if .Fl x509 is specified. t Fl text Prints out the certificate request in text form. t Fl utf8 This option causes field values to be interpreted as UTF8 strings; by default they are interpreted as ASCII. This means that the field values, whether prompted from a terminal or obtained from a configuration file, must be valid UTF8 strings. t Fl verbose Print extra details about the operations being performed. t Fl verify Verifies the signature on the request. t Fl x509 This option outputs 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

q if any are specified in the configuration file. Unless specified using the .Fl set_serial option, 0 will be used for the serial number. .El .Sh REQ CONFIGURATION FILE FORMAT The configuration options are specified in the .Em req section of the configuration file. As with all configuration files, if no value is specified in the specific section (i.e.\& .Em req ) then the initial unnamed or .Em default section is searched too.

p The options available are described in detail below. l -tag -width "XXXX" t Ar attributes This specifies the section containing any request attributes: its format is the same as .Ar distinguished_name . Typically these may contain the .Em challengePassword or .Em unstructuredName types. They are currently ignored by .Nm OpenSSL Ns Li 's request signing utilities, but some CAs might want them. t Ar default_bits This specifies the default key size in bits. If not specified, 2048 is used. It is used if the .Fl new option is used. It can be overridden by using the .Fl newkey option. t Ar default_keyfile This is the default file to write a private key to. If not specified, the key is written to standard output. This can be overridden by the .Fl keyout option. t Ar default_md This option specifies the digest algorithm to use. Possible values include .Ar md5 , .Ar sha1 and .Ar sha256 . If not present, SHA256 is used. This option can be overridden on the command line. t Ar distinguished_name This specifies the section containing the distinguished name fields to prompt for when generating a certificate or certificate request. The format is described in the next section. t Ar encrypt_key If this is set to .Em no and a private key is generated, it is .Em not encrypted. This is equivalent to the .Fl nodes command line option. For compatibility, .Ar encrypt_rsa_key is an equivalent option. t Ar input_password | output_password The passwords for the input private key file

q if present and the output private key file

q if one will be created . The command line options .Fl passin and .Fl passout override the configuration file values. t Ar 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. t Ar 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. t Ar prompt If set to the value .Em no , this disables prompting of certificate fields and just takes values from the config file directly. It also changes the expected format of the .Em distinguished_name and .Em attributes sections. t Ar req_extensions This specifies the configuration file section containing a list of extensions to add to the certificate request. It can be overridden by the .Fl reqexts command line switch. t Ar string_mask This option limits the string types for encoding certain fields. The following values may be used, limiting strings to the indicated types: l -tag -width "MASK:number" t Ar utf8only .Em UTF8String. This is the default, as recommended by PKIX in RFC 2459. t Ar default .Em PrintableString , IA5String , T61String , BMPString , UTF8String . t Ar pkix .Em PrintableString , IA5String , BMPString , UTF8String . This was inspired by the PKIX recommendation in RFC 2459 for certificates generated before 2004, but differs by also permitting .Em IA5String . t Ar nombstr .Em PrintableString , IA5String , T61String , UniversalString . This was a workaround for some ancient software that had problems with the variable-sized .Em BMPString and .Em UTF8String types. t Cm MASK : Ns Ar number This is 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 n openssl/asn1.h . .El t Ar utf8 If set to the value .Em yes , then field values are interpreted as UTF8 strings; by default they are interpreted as ASCII. This means that the field values, whether prompted from a terminal or obtained from a configuration file, must be valid UTF8 strings. t Ar x509_extensions This specifies 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 .Sh REQ DISTINGUISHED NAME AND ATTRIBUTE SECTION FORMAT There are two separate formats for the distinguished name and attribute sections. If the .Fl prompt option is set to .Em no , then these sections just consist of field names and values: for example, d -unfilled -offset indent CN=My Name OU=My Organization emailAddress=someone@somewhere.org .Ed

p This allows external programs

q e.g. GUI based to generate a template file with all the field names and values and just pass it to .Nm req . An example of this kind of configuration file is contained in the .Sx REQ EXAMPLES section.

p Alternatively if the .Fl prompt option is absent or not set to .Em no , then the file contains field prompting information. It consists of lines of the form: d -unfilled -offset indent fieldName="prompt" fieldName_default="default field value" fieldName_min= 2 fieldName_max= 4 .Ed

p .Qq fieldName is the field name being used, for example .Em commonName

q 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.

p The number of characters entered must be between the .Em fieldName_min and .Em fieldName_max limits: there may be additional restrictions based on the field being used (for example .Em countryName can only ever be two characters long and must fit in a .Em PrintableString ) .

p Some fields (such as .Em 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 .Em fieldName contains some characters followed by a full stop, they will be ignored. So, for example, a second .Em organizationName can be input by calling it .Qq 1.organizationName .

p 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 .Em commonName , countryName , localityName , organizationName , .Em organizationUnitName , stateOrProvinceName . Additionally, .Em emailAddress is included as well as .Em name , surname , givenName initials and .Em dnQualifier .

p Additional object identifiers can be defined with the .Ar oid_file or .Ar oid_section options in the configuration file. Any additional fields will be treated as though they were a .Em DirectoryString . .Sh REQ EXAMPLES Examine and verify a certificate request:

p .Dl $ openssl req -in req.pem -text -verify -noout

p Create a private key and then generate a certificate request from it: d -literal -offset indent $ openssl genrsa -out key.pem 2048 $ openssl req -new -key key.pem -out req.pem .Ed

p The same but just using req:

p .Dl $ openssl req -newkey rsa:2048 -keyout key.pem -out req.pem

p Generate a self-signed root certificate:

p .Dl "$ openssl req -x509 -newkey rsa:2048 -keyout key.pem -out req.pem"

p Example of a file pointed to by the .Ar oid_file option: d -unfilled -offset indent 1.2.3.4 shortName A longer Name 1.2.3.6 otherName Other longer Name .Ed

p Example of a section pointed to by .Ar oid_section making use of variable expansion: d -unfilled -offset indent testoid1=1.2.3.5 testoid2=${testoid1}.6 .Ed

p Sample configuration file prompting for field values: d -literal [ req ] default_bits = 1024 default_keyfile = privkey.pem distinguished_name = req_distinguished_name attributes = req_attributes x509_extensions = v3_ca dirstring_type = nobmp [ req_distinguished_name ] countryName = Country Name (2 letter code) countryName_default = AU countryName_min = 2 countryName_max = 2 localityName = Locality Name (eg, city) organizationalUnitName = Organizational Unit Name (eg, section) commonName = Common Name (eg, YOUR name) commonName_max = 64 emailAddress = Email Address emailAddress_max = 40 [ req_attributes ] challengePassword = A challenge password challengePassword_min = 4 challengePassword_max = 20 [ v3_ca ] subjectKeyIdentifier=hash authorityKeyIdentifier=keyid:always,issuer:always basicConstraints = CA:true .Ed

p Sample configuration containing all field values: d -literal [ req ] default_bits = 1024 default_keyfile = keyfile.pem distinguished_name = req_distinguished_name attributes = req_attributes prompt = no output_password = mypass [ req_distinguished_name ] C = GB ST = Test State or Province L = Test Locality O = Organization Name OU = Organizational Unit Name CN = Common Name emailAddress = test@email.address [ req_attributes ] challengePassword = A challenge password .Ed .Sh REQ NOTES The header and footer lines in the PEM format are normally: d -unfilled -offset indent -----BEGIN CERTIFICATE REQUEST----- -----END CERTIFICATE REQUEST----- .Ed

p Some software

q some versions of Netscape certificate server instead needs: d -unfilled -offset indent -----BEGIN NEW CERTIFICATE REQUEST----- -----END NEW CERTIFICATE REQUEST----- .Ed

p which is produced with the .Fl newhdr option but is otherwise compatible. Either form is accepted transparently on input.

p The certificate requests generated by Xenroll with MSIE have extensions added. It includes the .Em keyUsage extension which determines the type of key

q signature only or general purpose and any additional OIDs entered by the script in an .Em extendedKeyUsage extension. .Sh REQ DIAGNOSTICS The following messages are frequently asked about: d -unfilled -offset indent Using configuration from /some/path/openssl.cnf Unable to load config info .Ed

p This is followed some time later by... d -unfilled -offset indent unable to find 'distinguished_name' in config problems making Certificate Request .Ed

p The first error message is the clue: it can't find the configuration file! Certain operations

q like examining a certificate request don't need a configuration file so its use isn't enforced. Generation of certificates or requests, however, do need a configuration file. This could be regarded as a bug.

p Another puzzling message is this: d -unfilled -offset indent Attributes: a0:00 .Ed

p This is displayed when no attributes are present and the request includes the correct empty SET OF structure

q the DER encoding of which is 0xa0 0x00 . If you just see:

p .D1 Attributes:

p then the SET OF is missing and the encoding is technically invalid

q but it is tolerated . See the description of the command line option .Fl asn1-kludge for more information. .Sh REQ ENVIRONMENT VARIABLES The variable .Ev OPENSSL_CONF , if defined, allows an alternative configuration file location to be specified; it will be overridden by the .Fl config command line switch if it is present. .Sh REQ BUGS .Nm OpenSSL Ns Li 's handling of T61Strings

q aka TeletexStrings is broken: it effectively treats them as ISO 8859-1

q Latin 1 ; Netscape and MSIE have similar behaviour. This can cause problems if you need characters that aren't available in .Em PrintableStrings and you don't want to or can't use .Em BMPStrings .

p As a consequence of the T61String handling, the only correct way to represent accented characters in .Nm OpenSSL is to use a .Em BMPString : unfortunately Netscape currently chokes on these. If you have to use accented characters with Netscape and MSIE then you currently need to use the invalid T61String form.

p The current prompting is not very friendly. It doesn't allow you to confirm what you've just entered. Other things, like extensions in certificate requests, are statically defined in the configuration file. Some of these, like an email address in .Em subjectAltName , should be input by the user.
RSA

.Sh RSA .nr nS 1 .Nm "openssl rsa" k -words .Oo .Fl aes128 | aes192 | aes256 | .Fl des | des3 .Oc .Op Fl check .Op Fl in Ar file .Op Fl inform Ar DER | NET | PEM .Op Fl modulus .Op Fl noout .Op Fl out Ar file .Op Fl outform Ar 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 .Ek

p The .Nm rsa command processes RSA keys. They can be converted between various forms and their components printed out.

p .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 utility.

p The options are as follows: l -tag -width Ds t Xo .Fl aes128 | aes192 | aes256 | .Fl des | des3 .Xc These options 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. t Fl check This option checks the consistency of an RSA private key. t Fl in Ar file This specifies the input .Ar file to read a key from, or standard input if this option is not specified. If the key is encrypted, a pass phrase will be prompted for. t Fl inform Ar DER | NET | PEM This specifies the input format. The .Ar DER argument uses an ASN1 DER-encoded form compatible with the PKCS#1 RSAPrivateKey or SubjectPublicKeyInfo format. The .Ar PEM form is the default format: it consists of the DER format base64-encoded with additional header and footer lines. On input PKCS#8 format private keys are also accepted. The .Ar NET form is a format described in the .Sx RSA NOTES section. t Fl noout This option prevents output of the encoded version of the key. t Fl modulus This option prints out the value of the modulus of the key. t Fl out Ar file This specifies the output .Ar file to write a key to, or standard output if this option is not specified. If any encryption options are set, a pass phrase will be prompted for. The output filename should .Em not be the same as the input filename. t Fl outform Ar DER | NET | PEM This specifies the output format; the options have the same meaning as the .Fl inform option. t Fl passin Ar arg The key password source. t Fl passout Ar arg The output file password source. t Fl pubin By default, a private key is read from the input file; with this option a public key is read instead. t Fl pubout By default, a private key is output; with this option a public key will be output instead. This option is automatically set if the input is a public key. t Fl sgckey Use the modified .Em NET algorithm used with some versions of Microsoft IIS and SGC keys. t Fl text Prints out the various public or private key components in plain text, in addition to the encoded version. .El .Sh RSA NOTES The PEM private key format uses the header and footer lines: d -unfilled -offset indent -----BEGIN RSA PRIVATE KEY----- -----END RSA PRIVATE KEY----- .Ed

p The PEM public key format uses the header and footer lines: d -unfilled -offset indent -----BEGIN PUBLIC KEY----- -----END PUBLIC KEY----- .Ed

p The .Em NET form is a format compatible with older Netscape servers and Microsoft IIS .key files; this uses unsalted RC4 for its encryption. It is not very secure and so should only be used when necessary.

p Some newer version of IIS have additional data in the exported .key files. To use these with the .Nm rsa utility, view the file with a binary editor and look for the string .Qq private-key , then trace back to the byte sequence 0x30, 0x82

q this is an ASN1 SEQUENCE . Copy all the data from this point onwards to another file and use that as the input to the .Nm rsa utility with the .Fl inform Ar NET option. If there is an error after entering the password, try the .Fl sgckey option. .Sh RSA EXAMPLES To remove the pass phrase on an RSA private key:

p .Dl $ openssl rsa -in key.pem -out keyout.pem

p To encrypt a private key using triple DES:

p .Dl $ openssl rsa -in key.pem -des3 -out keyout.pem

p To convert a private key from PEM to DER format:

p .Dl $ openssl rsa -in key.pem -outform DER -out keyout.der

p To print out the components of a private key to standard output:

p .Dl $ openssl rsa -in key.pem -text -noout

p To just output the public part of a private key:

p .Dl $ openssl rsa -in key.pem -pubout -out pubkey.pem .Sh RSA BUGS The command line password arguments don't currently work with .Em NET format.

p There should be an option that automatically handles .key files, without having to manually edit them.
RSAUTL

.Sh RSAUTL .nr nS 1 .Nm "openssl rsautl" k -words .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 Ar DER | PEM .Op Fl oaep | pkcs | raw | ssl .Op Fl out Ar file .Op Fl pubin .Op Fl sign .Op Fl verify .Ek .nr nS 0

p The .Nm rsautl command can be used to sign, verify, encrypt and decrypt data using the RSA algorithm.

p The options are as follows: l -tag -width Ds t Fl asn1parse Asn1parse the output data; this is useful when combined with the .Fl verify option. t Fl certin The input is a certificate containing an RSA public key. t Fl decrypt Decrypt the input data using an RSA private key. t Fl encrypt Encrypt the input data using an RSA public key. t Fl hexdump Hex dump the output data. t Fl in Ar file This specifies the input .Ar file to read data from, or standard input if this option is not specified. t Fl inkey Ar file The input key file, by default it should be an RSA private key. t Fl keyform Ar DER | PEM Private ket format. Default is .Ar PEM . t Fl oaep | pkcs | raw | ssl The padding to use: PKCS#1 OAEP, PKCS#1 v1.5

q the default , or no padding, respectively. For signatures, only .Fl pkcs and .Fl raw can be used. t Fl out Ar file Specifies the output .Ar file to write to, or standard output by default. t Fl pubin The input file is an RSA public key. t Fl sign Sign the input data and output the signed result. This requires an RSA private key. t Fl verify Verify the input data and output the recovered data. .El .Sh RSAUTL NOTES .Nm rsautl , because it uses the RSA algorithm directly, can only be used to sign or verify small pieces of data. .Sh RSAUTL EXAMPLES Sign some data using a private key:

p .Dl "$ openssl rsautl -sign -in file -inkey key.pem -out sig"

p Recover the signed data:

p .Dl $ openssl rsautl -verify -in sig -inkey key.pem

p Examine the raw signed data:

p .Li " $ openssl rsautl -verify -in file -inkey key.pem -raw -hexdump" d -unfilled 0000 - 00 01 ff ff ff ff ff ff-ff ff ff ff ff ff ff ff ................ 0010 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff ................ 0020 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff ................ 0030 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff ................ 0040 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff ................ 0050 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff ................ 0060 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff ................ 0070 - ff ff ff ff 00 68 65 6c-6c 6f 20 77 6f 72 6c 64 .....hello world .Ed

p The PKCS#1 block formatting is evident from this. If this was done using encrypt and decrypt, the block would have been of type 2

q the second byte and random padding data visible instead of the 0xff bytes.

p It is possible to analyse the signature of certificates using this utility in conjunction with .Nm asn1parse . Consider the self-signed example in

a certs/pca-cert.pem : running .Nm asn1parse as follows yields:

p .Li " $ openssl asn1parse -in pca-cert.pem" d -unfilled 0:d=0 hl=4 l= 742 cons: SEQUENCE 4:d=1 hl=4 l= 591 cons: SEQUENCE 8:d=2 hl=2 l= 3 cons: cont [ 0 ] 10:d=3 hl=2 l= 1 prim: INTEGER :02 13:d=2 hl=2 l= 1 prim: INTEGER :00 16:d=2 hl=2 l= 13 cons: SEQUENCE 18:d=3 hl=2 l= 9 prim: OBJECT :md5WithRSAEncryption 29:d=3 hl=2 l= 0 prim: NULL 31:d=2 hl=2 l= 92 cons: SEQUENCE 33:d=3 hl=2 l= 11 cons: SET 35:d=4 hl=2 l= 9 cons: SEQUENCE 37:d=5 hl=2 l= 3 prim: OBJECT :countryName 42:d=5 hl=2 l= 2 prim: PRINTABLESTRING :AU .... 599:d=1 hl=2 l= 13 cons: SEQUENCE 601:d=2 hl=2 l= 9 prim: OBJECT :md5WithRSAEncryption 612:d=2 hl=2 l= 0 prim: NULL 614:d=1 hl=3 l= 129 prim: BIT STRING .Ed

p The final BIT STRING contains the actual signature. It can be extracted with:

p .Dl "$ openssl asn1parse -in pca-cert.pem -out sig -noout -strparse 614"

p The certificate public key can be extracted with:

p .Dl $ openssl x509 -in test/testx509.pem -pubkey -noout \*(Gtpubkey.pem

p The signature can be analysed with:

p .Li " $ openssl rsautl -in sig -verify -asn1parse -inkey pubkey.pem -pubin" d -unfilled 0:d=0 hl=2 l= 32 cons: SEQUENCE 2:d=1 hl=2 l= 12 cons: SEQUENCE 4:d=2 hl=2 l= 8 prim: OBJECT :md5 14:d=2 hl=2 l= 0 prim: NULL 16:d=1 hl=2 l= 16 prim: OCTET STRING 0000 - f3 46 9e aa 1a 4a 73 c9-37 ea 93 00 48 25 08 b5 .F...Js.7...H%.. .Ed

p This is the parsed version of an ASN1 .Em DigestInfo structure. It can be seen that the digest used was MD5. The actual part of the certificate that was signed can be extracted with:

p .Dl "$ openssl asn1parse -in pca-cert.pem -out tbs -noout -strparse 4"

p and its digest computed with:

p .Dl $ openssl md5 -c tbs .D1 MD5(tbs)= f3:46:9e:aa:1a:4a:73:c9:37:ea:93:00:48:25:08:b5

p which it can be seen agrees with the recovered value above.
S_CLIENT

.Sh S_CLIENT .nr nS 1 .Nm "openssl s_client" k -words .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 .Oo .Fl connect Ar host : Ns Ar port | .Ar host Ns / Ns Ar port .Oc .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 .Ek .nr nS 0

p The .Nm s_client command implements a generic SSL/TLS client which connects to a remote host using SSL/TLS. It is a .Em very useful diagnostic tool for SSL servers.

p The options are as follows: l -tag -width Ds t Fl 4 Specify that .Nm s_client should attempt connections using IPv4 only. t Fl 6 Specify that .Nm s_client should attempt connections using IPv6 only. t Fl bugs There are several known bugs in SSL and TLS implementations. Adding this option enables various workarounds. t 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. t 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. t Fl cert Ar file The certificate to use, if one is requested by the server. The default is not to use a certificate. t 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. t Fl cipher Ar cipherlist This allows the cipher list sent by the client to be modified. 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 .Sx CIPHERS section above for more information. t Xo .Fl connect Ar host : Ns Ar port | .Ar host Ns / Ns Ar port .Xc This specifies the .Ar host and optional .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. This form is useful for numeric IPv6 addresses. t Fl crlf This option translates a line feed from the terminal into CR+LF as required by some servers. t Fl debug Print extensive debugging information including a hex dump of all traffic. t Fl ign_eof Inhibit shutting down the connection when end of file is reached in the input. t Fl key Ar keyfile The private key to use. If not specified, the certificate file will be used. t Fl msg Show all protocol messages with hex dump. t Fl nbio Turns on non-blocking I/O. t Fl nbio_test Tests non-blocking I/O. t Fl no_tls1 | no_tls1_1 | no_tls1_2 By default, the initial handshake uses a method which should be compatible with servers supporting any version of TLS. These options disable the use of TLS1.0, 1.1, and 1.2, respectively.

p Unfortunately there are a lot of ancient and broken servers in use which cannot handle this technique and will fail to connect. t Fl no_ticket Disable RFC 4507 session ticket support. t Fl pause Pauses 1 second between each read and write call. t 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. .Sy Note : the output produced by this option is not always accurate because a connection might never have been established. t 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. t 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. t Fl psk_identity Ar identity Use the PSK identity .Ar identity when using a PSK cipher suite. t Fl quiet Inhibit printing of session and certificate information. This implicitly turns on .Fl ign_eof as well. t Fl reconnect Reconnects to the same server 5 times using the same session ID; this can be used as a test that session caching is working. t Fl servername Ar name Include the TLS Server Name Indication (SNI) extension in the ClientHello message, using the specified server .Ar name . t Fl showcerts Display the whole server certificate chain: normally only the server certificate itself is displayed. t Fl starttls Ar protocol Send the protocol-specific message(s) 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 . t Fl state Prints out the SSL session states. t Fl tls1 | tls1_1 | tls1_2 Permit only TLS1.0, 1.1, or 1.2, respectively. t Fl tlsextdebug Print out a hex dump of any TLS extensions received from the server. t Fl verify Ar depth The verify .Ar depth to use. This specifies the maximum length of the server certificate chain and turns on server certificate verification. 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. t Fl xmpphost Ar hostname This option, when used with .Fl starttls Ar xmpp , specifies 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_CLIENT CONNECTED COMMANDS 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 .Em R ; if the line begins with a .Em Q or if end of file is reached, the connection will be closed down. .Sh S_CLIENT NOTES .Nm s_client can be used to debug SSL servers. To connect to an SSL HTTP server the command:

p .Dl $ openssl s_client -connect servername:443

p would typically be used

q HTTPS uses port 443 . If the connection succeeds, an HTTP command can be given such as .Qq GET to retrieve a web page.

p If the handshake fails, there are several possible causes; if it is nothing obvious like no client certificate, then the .Fl bugs , tls1 , tls1_1, tls1_2 , no_tls1 , no_tls1_1 , and .Fl no_tls1_2 options can be tried in case it is a buggy server.

p A frequent problem when attempting to get client certificates working is that a web client complains it has no certificates or gives an empty list to choose from. This is normally because the server is not sending the client's certificate authority in its .Qq acceptable CA list when it requests a certificate. By using .Nm s_client the CA list can be viewed and checked. However some servers only request client authentication after a specific URL is requested. To obtain the list in this case it is necessary to use the .Fl prexit option and send an HTTP request for an appropriate page.

p If a certificate is specified on the command line using the .Fl cert option, it will not be used unless the server specifically requests a client certificate. Therefore merely including a client certificate on the command line is no guarantee that the certificate works.

p If there are problems verifying a server certificate, the .Fl showcerts option can be used to show the whole chain.

p Compression methods are only supported for .Fl tls1 . .Sh S_CLIENT BUGS Because this program has a lot of options and also because some of the techniques used are rather old, the C source of .Nm s_client is rather hard to read and not a model of how things should be done. A typical SSL client program would be much simpler.

p The .Fl verify option should really exit if the server verification fails.

p The .Fl prexit option is a bit of a hack. We should really report information whenever a session is renegotiated.
S_SERVER

.Sh S_SERVER .nr nS 1 .Nm "openssl s_server" k -words .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 .Ek .nr nS 0

p The .Nm s_server command implements a generic SSL/TLS server which listens for connections on a given port using SSL/TLS.

p The options are as follows: l -tag -width Ds t Fl accept Ar port The TCP .Ar port to listen on for connections. If not specified, 4433 is used. t Fl bugs There are several known bugs in SSL and TLS implementations. Adding this option enables various workarounds. t Fl CAfile Ar file A 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. t 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. t 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

q DSA key. If not specified, the file

a server.pem will be used. t Fl cipher Ar cipherlist 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 .Sx CIPHERS section for more information. t Fl context Ar id Sets the SSL context ID. It can be given any string value. If this option is not present, a default value will be used. t 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. With the .Fl crl_check_all option, all CRLs of all CAs in the chain are checked. t Fl crlf This option translates a line feed from the terminal into CR+LF. t 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

q no additional certificate or key is used . As noted above some cipher suites require a certificate containing a key of a certain type. Some cipher suites need a certificate carrying an RSA key and some a DSS

q DSA key. 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. t Fl debug Print extensive debugging information including a hex dump of all traffic. t 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. t Fl hack This option enables a further workaround for some early Netscape SSL code

q ? . t Fl HTTP Emulates a simple web server. Pages will be resolved relative to the current directory; for example if the URL

a https://myhost/page.html is requested, the file

a ./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). t Fl id_prefix Ar arg Generate SSL/TLS session IDs prefixed by .Ar arg . This is mostly useful for testing any SSL/TLS code

q e.g. proxies that wish to deal with multiple servers, when each of which might be generating a unique range of session IDs

q e.g. with a certain prefix . t Fl key Ar keyfile The private key to use. If not specified, the certificate file will be used. t Fl msg Show all protocol messages with hex dump. t Fl nbio Turns on non-blocking I/O. t Fl nbio_test Tests non-blocking I/O. t Fl no_dhe If this option is set, no DH parameters will be loaded, effectively disabling the ephemeral DH cipher suites. t Fl no_tls1 | no_tls1_1 | no_tls1_2 By default, the initial handshake uses a method which should be compatible with clients supporting any version of TLS. These options disable the use of TLS1.0, 1.1, and 1.2, respectively. t Fl no_tmp_rsa Certain export cipher suites sometimes use a temporary RSA key; this option disables temporary RSA key generation. t Fl nocert If this option is set, no certificate is used. This restricts the cipher suites available to the anonymous ones

q currently just anonymous DH . t 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. t Fl psk_hint Ar hint Use the PSK identity hint .Ar hint when using a PSK cipher suite. t Fl quiet Inhibit printing of session and certificate information. t Fl serverpref Use server's cipher preferences. t Fl state Prints out the SSL session states. t Fl tls1 | tls1_1 | tls1_2 Permit only TLS1.0, 1.1, or 1.2, respectively. t Fl WWW Emulates a simple web server. Pages will be resolved relative to the current directory; for example if the URL

a https://myhost/page.html is requested, the file

a ./page.html will be loaded. t Fl www Sends a status message back to the client when it connects. This includes lots of 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. t Fl Verify Ar depth , Fl verify Ar depth The verify .Ar depth to use. This specifies the maximum length of the client certificate chain and makes the server request a certificate from the client. With the .Fl Verify option, the client must supply a certificate or an error occurs. With the .Fl verify option, a certificate is requested but the client does not have to send one. .El .Sh S_SERVER CONNECTED COMMANDS If a connection request is established with an SSL client and neither the .Fl www nor the .Fl WWW option has been used, then normally any data received from the client is displayed and any key presses will be sent to the client.

p Certain single letter commands are also recognized which perform special operations: these are listed below. l -tag -width "XXXX" t Ar P Send some plain text down the underlying TCP connection: this should cause the client to disconnect due to a protocol violation. t Ar Q End the current SSL connection and exit. t Ar q End the current SSL connection, but still accept new connections. t Ar R Renegotiate the SSL session and request a client certificate. t Ar r Renegotiate the SSL session. t Ar S Print out some session cache status information. .El .Sh S_SERVER NOTES .Nm s_server can be used to debug SSL clients. To accept connections from a web browser the command:

p .Dl $ openssl s_server -accept 443 -www

p can be used, for example.

p Most web browsers

q in particular Netscape and MSIE only support RSA cipher suites, so they cannot connect to servers which don't use a certificate carrying an RSA key or a version of .Nm OpenSSL with RSA disabled.

p Although specifying an empty list of CAs when requesting a client certificate is strictly speaking a protocol violation, some SSL clients interpret this to mean any CA is acceptable. This is useful for debugging purposes.

p The session parameters can printed out using the .Nm sess_id program. .Sh S_SERVER BUGS Because this program has a lot of options and also because some of the techniques used are rather old, the C source of .Nm s_server is rather hard to read and not a model of how things should be done. A typical SSL server program would be much simpler.

p The output of common ciphers is wrong: it just gives the list of ciphers that .Nm OpenSSL recognizes and the client supports.

p There should be a way for the .Nm s_server program to print out details of any unknown cipher suites a client says it supports.
S_TIME

.Sh S_TIME .nr nS 1 .Nm "openssl s_time" k -words .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 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 .Ek .nr nS 0

p The .Nm s_client 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

q if any , and calculates the average time spent for one connection.

p The options are as follows: l -tag -width Ds t Fl bugs There are several known bugs in SSL and TLS implementations. Adding this option enables various workarounds. t Fl CAfile Ar file A file containing trusted certificates to use during server authentication and to use when attempting to build the client certificate chain. t 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. t Fl cert Ar file The certificate to use, if one is requested by the server. The default is not to use a certificate. The file is in PEM format. t Fl cipher Ar cipherlist This allows the cipher list sent by the client to be modified. 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. t Fl connect Ar host : Ns Ar port This specifies the host and optional port to connect to. t Fl key Ar keyfile The private key to use. If not specified, the certificate file will be used. The file is in PEM format. t Fl nbio Turns on non-blocking I/O. t Fl new Performs 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. t Fl no_shutdown Shut down the connection without sending a .Dq close notify shutdown alert to the server. t Fl reuse Performs the timing test using the same session ID; this can be used as a test that session caching is working. If neither .Fl new nor .Fl reuse are specified, they are both on by default and executed in sequence. t Fl time Ar seconds Specifies how long

q in seconds .Nm s_time should establish connections and optionally transfer payload data from a server. The default is 30 seconds. Server and client performance and the link speed determine how many connections .Nm s_time can establish. t Fl verify Ar depth The verify depth to use. This specifies the maximum length of the server certificate chain and turns on server certificate verification. 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. t Fl www Ar page This specifies 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 S_TIME NOTES .Nm s_client can be used to measure the performance of an SSL connection. To connect to an SSL HTTP server and get the default page the command d -literal -offset indent $ openssl s_time -connect servername:443 -www / -CApath yourdir \e -CAfile yourfile.pem -cipher commoncipher .Ed

p would typically be used

q HTTPS uses port 443 . .Dq commoncipher is a cipher to which both client and server can agree; see the .Nm ciphers command for details.

p If the handshake fails, there are several possible causes: if it is nothing obvious like no client certificate, the .Fl bugs option can be tried in case it is a buggy server.

p A frequent problem when attempting to get client certificates working is that a web client complains it has no certificates or gives an empty list to choose from. This is normally because the server is not sending the clients certificate authority in its .Qq acceptable CA list when it requests a certificate. By using .Nm s_client , the CA list can be viewed and checked. However some servers only request client authentication after a specific URL is requested. To obtain the list in this case, it is necessary to use the .Fl prexit option of .Nm s_client and send an HTTP request for an appropriate page.

p If a certificate is specified on the command line using the .Fl cert option, it will not be used unless the server specifically requests a client certificate. Therefore merely including a client certificate on the command line is no guarantee that the certificate works. .Sh S_TIME BUGS Because this program does not have all the options of the .Nm s_client program to turn protocols on and off, you may not be able to measure the performance of all protocols with all servers.

p The .Fl verify option should really exit if the server verification fails.
SESS_ID

.Sh SESS_ID .nr nS 1 .Nm "openssl sess_id" k -words .Op Fl cert .Op Fl context Ar ID .Op Fl in Ar file .Op Fl inform Ar DER | PEM .Op Fl noout .Op Fl out Ar file .Op Fl outform Ar DER | PEM .Op Fl text .Ek .nr nS 0

p The .Nm sess_id program processes the encoded version of the SSL session structure and optionally prints out SSL session details

q for example the SSL session master key in human readable format. Since this is a diagnostic tool that needs some knowledge of the SSL protocol to use properly, most users will not need to use it.

p The options are as follows: l -tag -width Ds t 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. t Fl context Ar ID This option can set the session ID so the output session information uses the supplied .Ar ID . The .Ar ID can be any string of characters. This option won't normally be used. t Fl in Ar file This specifies the input .Ar file to read session information from, or standard input by default. t Fl inform Ar DER | PEM This specifies the input format. The .Ar DER argument uses an ASN1 DER-encoded format containing session details. The precise format can vary from one version to the next. The .Ar PEM form is the default format: it consists of the DER format base64-encoded with additional header and footer lines. t Fl noout This option prevents output of the encoded version of the session. t Fl out Ar file This specifies the output .Ar file to write session information to, or standard output if this option is not specified. t Fl outform Ar DER | PEM This specifies the output format; the options have the same meaning as the .Fl inform option. t Fl text Prints out the various public or private key components in plain text in addition to the encoded version. .El .Sh SESS_ID OUTPUT Typical output: d -literal SSL-Session: Protocol : TLSv1 Cipher : 0016 Session-ID: 871E62626C554CE95488823752CBD5F3673A3EF3DCE9C67BD916C809914B40ED Session-ID-ctx: 01000000 Master-Key: A7CEFC571974BE02CAC305269DC59F76EA9F0B180CB6642697A68251F2D2BB57E51DBBB4C7885573192AE9AEE220FACD Key-Arg : None Start Time: 948459261 Timeout : 300 (sec) Verify return code 0 (ok) .Ed

p These are described below in more detail.

p l -tag -width "Verify return code " -compact t Ar Protocol This is the protocol in use. t Ar Cipher The cipher used is the actual raw SSL or TLS cipher code; see the SSL or TLS specifications for more information. t Ar Session-ID The SSL session ID in hex format. t Ar Session-ID-ctx The session ID context in hex format. t Ar Master-Key This is the SSL session master key. t Ar Key-Arg The key argument; this is only used in SSL v2. t Ar Start Time This is the session start time, represented as an integer in standard x format. t Ar Timeout The timeout in seconds. t Ar Verify return code This is the return code when an SSL client certificate is verified. .El .Sh SESS_ID NOTES The PEM-encoded session format uses the header and footer lines: d -unfilled -offset indent -----BEGIN SSL SESSION PARAMETERS----- -----END SSL SESSION PARAMETERS----- .Ed

p 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 SESS_ID BUGS The cipher and start time should be printed out in human readable form.
SMIME

.Sh SMIME .nr nS 1 .Nm "openssl smime" k -words .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 Ar DER | PEM | SMIME .Op Fl inkey Ar file .Op Fl issuer_checks .Op Fl keyform Ar 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 Ar 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 ... .Ek .nr nS 0

p The .Nm smime command handles .Em S/MIME mail. It can encrypt, decrypt, sign, and verify .Em S/MIME messages.

p There are six operation options that set the type of operation to be performed. The meaning of the other options varies according to the operation type.

p The six operation options are as follows: l -tag -width "XXXX" t Fl decrypt Decrypt mail using the supplied certificate and private key. Expects an encrypted mail message in .Em MIME format for the input file. The decrypted mail is written to the output file. t Fl encrypt Encrypt mail for the given recipient certificates. Input file is the message to be encrypted. The output file is the encrypted mail in .Em MIME format. t Fl pk7out Takes an input message and writes out a PEM-encoded PKCS#7 structure. t Fl resign Resign a message: take an existing message and one or more new signers. t Fl sign Sign mail using the supplied certificate and private key. Input file is the message to be signed. The signed message in .Em MIME format is written to the output file. t Fl verify Verify signed mail. Expects a signed mail message on input and outputs the signed data. Both clear text and opaque signing is supported. .El

p The remaining options are as follows: l -tag -width "XXXX" t 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

q 56 bits , triple DES

q 168 bits , or 40-, 64-, or 128-bit RC2, respectively; if not specified, 40-bit RC2 is used. Only used with .Fl encrypt . t Fl binary Normally, the input message is converted to .Qq canonical format which is effectively using CR and LF as end of line - as required by the .Em S/MIME specification. When this option is present no translation occurs. This is useful when handling binary data which may not be in .Em MIME format. t Fl CAfile Ar file A .Ar file containing trusted CA certificates; only used with .Fl verify . t 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. t Ar cert.pem ... One or more certificates of message recipients: used when encrypting a message. t 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. t 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. t Fl content Ar file This specifies a file containing the detached content. This is only useful with the .Fl verify command. This is 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 .Em S/MIME and it uses the multipart/signed .Em MIME content type. t 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 .Em S/MIME mail clients check that the signer's certificate email address matches the From: address. t Fl in Ar file The input message to be encrypted or signed or the .Em MIME message to be decrypted or verified. t 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. t Fl inform Ar DER | PEM | SMIME This specifies the input format for the PKCS#7 structure. The default is .Em SMIME , which reads an .Em S/MIME format message. .Ar PEM and .Ar DER format change this to expect PEM and DER format PKCS#7 structures instead. This currently only affects the input format of the PKCS#7 structure; if no PKCS#7 structure is being input (for example with .Fl encrypt or .Fl sign ) , this option has no effect. t Fl inkey Ar file The private key to use when signing or decrypting. This 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. t Fl keyform Ar PEM Input private key format. t 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). t Fl noattr Normally, when a message is signed a set of attributes are included which include the signing time and supported symmetric algorithms. With this option they are not included. t Fl nocerts When signing a message, the signer's certificate is normally included; with this option it is excluded. 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). t Fl nochain Do not do chain verification of signers' certificates: that is, don't use the certificates in the signed message as untrusted CAs. t 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 .Em S/MIME . Without this option cleartext signing with the .Em MIME type multipart/signed is used. t Fl noindef Disable streaming I/O where it would produce an encoding of indefinite length. This option currently has no effect. In future streaming will be enabled by default on all relevant operations and this option will disable it. t Fl nointern When verifying a message, normally certificates

q if any included in the message are searched for the signing certificate. With this option, only the certificates specified in the .Fl certfile option are used. The supplied certificates can still be used as untrusted CAs however. t Fl nosigs Don't try to verify the signatures on the message. t Fl noverify Do not verify the signer's certificate of a signed message. t Fl out Ar file The message text that has been decrypted or verified, or the output .Em MIME format message that has been signed or verified. t Fl outform Ar DER | PEM | SMIME This specifies the output format for the PKCS#7 structure. The default is .Em SMIME , which writes an .Em S/MIME format message. .Ar PEM and .Ar DER format 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. t Fl passin Ar arg The key password source. t 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. t 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. t Fl stream The same as .Fl indef . t Fl text This option adds plain text

q text/plain .Em 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 .Em MIME type text/plain then an error occurs. .El .Sh SMIME NOTES The .Em 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.

p The supplied message to be signed or encrypted must include the necessary .Em MIME headers or many .Em S/MIME clients won't display it properly

q if at all . You can use the .Fl text option to automatically add plain text headers.

p 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: see the .Sx SMIME EXAMPLES section.

p This version of the program only allows one signer per message, but it will verify multiple signers on received messages. Some .Em S/MIME clients choke if a message contains multiple signers. It is possible to sign messages .Qq in parallel by signing an already signed message.

p The options .Fl encrypt and .Fl decrypt reflect common usage in .Em S/MIME clients. Strictly speaking these process PKCS#7 enveloped data: PKCS#7 encrypted data is used for other purposes.

p The .Fl resign option uses an existing message digest when adding a new signer. This means that attributes must be present in at least one existing signer using the same message digest or this operation will fail.

p The .Fl stream and .Fl indef options enable experimental streaming I/O support. As a result the encoding is BER using indefinite length constructed encoding and no longer DER. Streaming is supported for the .Fl encrypt and .Fl sign operations if the content is not detached.

p Streaming is always used for the .Fl sign operation with detached data but since the content is no longer part of the PKCS#7 structure the encoding remains DER. .Sh SMIME EXIT CODES l -tag -width "XXXX" t Ar 0 The operation was completely successful. t Ar 1 An error occurred parsing the command options. t Ar 2 One of the input files could not be read. t Ar 3 An error occurred creating the PKCS#7 file or when reading the .Em MIME message. t Ar 4 An error occurred decrypting or verifying the message. t Ar 5 The message was verified correctly, but an error occurred writing out the signer's certificates. .El .Sh SMIME EXAMPLES Create a cleartext signed message: d -literal -offset indent $ openssl smime -sign -in message.txt -text -out mail.msg \e -signer mycert.pem .Ed

p Create an opaque signed message: d -literal -offset indent $ openssl smime -sign -in message.txt -text -out mail.msg \e -nodetach -signer mycert.pem .Ed

p Create a signed message, include some additional certificates and read the private key from another file: d -literal -offset indent $ openssl smime -sign -in in.txt -text -out mail.msg \e -signer mycert.pem -inkey mykey.pem -certfile mycerts.pem .Ed

p Create a signed message with two signers: d -literal -offset indent openssl smime -sign -in message.txt -text -out mail.msg \e -signer mycert.pem -signer othercert.pem .Ed

p Send a signed message under x directly to .Xr sendmail 8 , including headers: d -literal -offset indent $ openssl smime -sign -in in.txt -text -signer mycert.pem \e -from steve@openssl.org -to someone@somewhere \e -subject "Signed message" | sendmail someone@somewhere .Ed

p Verify a message and extract the signer's certificate if successful: d -literal -offset indent $ openssl smime -verify -in mail.msg -signer user.pem \e -out signedtext.txt .Ed

p Send encrypted mail using triple DES: d -literal -offset indent $ openssl smime -encrypt -in in.txt -from steve@openssl.org \e -to someone@somewhere -subject "Encrypted message" \e -des3 -out mail.msg user.pem .Ed

p Sign and encrypt mail: d -literal -offset indent $ openssl smime -sign -in ml.txt -signer my.pem -text | \e openssl smime -encrypt -out mail.msg \e -from steve@openssl.org -to someone@somewhere \e -subject "Signed and Encrypted message" -des3 user.pem .Ed

p .Sy Note : The encryption command does not include the .Fl text option because the message being encrypted already has .Em MIME headers.

p Decrypt mail: d -literal -offset indent $ openssl smime -decrypt -in mail.msg -recip mycert.pem \e -inkey key.pem" .Ed

p The output from Netscape form signing is a PKCS#7 structure with the detached signature format. You can use this program to verify the signature by line wrapping the base64-encoded structure and surrounding it with: d -unfilled -offset indent -----BEGIN PKCS7----- -----END PKCS7----- .Ed

p and using the command: d -literal -offset indent $ openssl smime -verify -inform PEM -in signature.pem \e -content content.txt .Ed

p Alternatively, you can base64 decode the signature and use: d -literal -offset indent $ openssl smime -verify -inform DER -in signature.der \e -content content.txt .Ed

p Create an encrypted message using 128-bit AES: d -literal -offset indent openssl smime -encrypt -in plain.txt -aes128 \e -out mail.msg cert.pem .Ed

p Add a signer to an existing message: d -literal -offset indent openssl smime -resign -in mail.msg -signer newsign.pem \e -out mail2.msg .Ed .Sh SMIME BUGS The .Em MIME parser isn't very clever: it seems to handle most messages that I've thrown at it, but it may choke on others.

p The code currently will only write out the signer's certificate to a file: if the signer has a separate encryption certificate this must be manually extracted. There should be some heuristic that determines the correct encryption certificate.

p Ideally, a database should be maintained of a certificate for each email address.

p The code doesn't currently take note of the permitted symmetric encryption algorithms as supplied in the .Em SMIMECapabilities signed attribute. This means the user has to manually include the correct encryption algorithm. It should store the list of permitted ciphers in a database and only use those.

p No revocation checking is done on the signer's certificate.

p The current code can only handle .Em S/MIME v2 messages; the more complex .Em S/MIME v3 structures may cause parsing errors. .Sh SMIME HISTORY The use of multiple .Fl signer options and the .Fl resign command were first added in .Nm OpenSSL 1.0.0.
SPEED

.Sh SPEED .nr nS 1 .Nm "openssl speed" k -words .Op Cm aes .Op Cm aes-128-cbc .Op Cm aes-192-cbc .Op Cm aes-256-cbc .Op Cm aes-128-gcm .Op Cm aes-256-gcm .Op Cm blowfish .Op Cm bf-cbc .Op Cm cast .Op Cm cast-cbc .Op Cm chacha20-poly1305 .Op Cm des .Op Cm des-cbc .Op Cm des-ede3 .Op Cm dsa .Op Cm dsa512 .Op Cm dsa1024 .Op Cm dsa2048 .Op Cm hmac .Op Cm md4 .Op Cm md5 .Op Cm rc2 .Op Cm rc2-cbc .Op Cm rc4 .Op Cm rmd160 .Op Cm rsa .Op Cm rsa512 .Op Cm rsa1024 .Op Cm rsa2048 .Op Cm rsa4096 .Op Cm sha1 .Op Fl decrypt .Op Fl elapsed .Op Fl evp Ar e .Op Fl mr .Op Fl multi Ar number .Ek .nr nS 0

p The .Nm speed command is used to test the performance of cryptographic algorithms. l -tag -width "XXXX" t Bq Cm zero or more test algorithms If any options are given, .Nm speed tests those algorithms, otherwise all of the above are tested. t Fl decrypt Time decryption instead of encryption

q only EVP . t Fl elapsed Measure time in real time instead of CPU user time. t Fl evp Ar e Use EVP .Ar e . t Fl mr Produce machine readable output. t Fl multi Ar number Run .Ar number benchmarks in parallel. .El
TS

.Sh TS .nr nS 1 .Nm "openssl ts" k -words .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 .Ek .nr nS 0

p .nr nS 1 .Nm "openssl ts" k -words .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 .Ek .nr nS 0

p .nr nS 1 .Nm "openssl ts" k -words .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 .Ek .nr nS 0

p 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 a certain datum before a particular time. Here is a brief description of the protocol: l -enum t The TSA client computes a one-way hash value for a data file and sends the hash to the TSA. t 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. t 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

p 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.

p 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.

p The .Fl query switch can be used for creating and printing a time stamp request with the following options: l -tag -width Ds t Fl cert The TSA is expected to include its signing certificate in the response. t Fl config Ar configfile The configuration file to use. This option overrides the .Ev OPENSSL_CONF environment variable. Only the OID section of the config file is used with the .Fl query command. t Fl data Ar file_to_hash The data file for which the time stamp request needs to be created. stdin is the default if neither the .Fl data nor the .Fl digest option is specified. t Fl digest Ar digest_bytes It is possible to 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 (e.g. 1A:F6:01:... or 1AF601...). The number of bytes must match the message digest algorithm in use. t Fl in Ar request.tsq This option specifies a previously created time stamp request in DER format that will be printed into the output file. Useful when you need to examine the content of a request in human-readable format. t 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. t Fl no_nonce No nonce is specified in the request if this option is given. Otherwise a 64-bit long pseudo-random none is included in the request. It is recommended to use nonce to protect against replay-attacks. t Fl out Ar request.tsq Name of the output file to which the request will be written. The default is stdout. t Fl policy Ar object_id The policy that the client expects the TSA to use for creating the time stamp token. Either the dotted OID notation or OID names defined in the config file can be used. If no policy is requested the TSA will use its own default policy. t Fl text If this option is specified the output is in human-readable text format instead of DER. .El

p 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). l -tag -width Ds t Fl chain Ar certs_file.pem The collection of certificates, in PEM format, 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. t Fl config Ar configfile The configuration file to use. This option overrides the .Ev OPENSSL_CONF environment variable. See .Sx TS CONFIGURATION FILE OPTIONS for configurable variables. t Fl in Ar response.tsr Specifies 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, when you need to examine the content of a response or token or you want 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 .Dq granted status info is added to the token. t Fl inkey Ar private.pem The signer private key of the TSA in PEM format. Overrides the .Cm signer_key config file option. t 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. t Fl passin Ar arg The key password source. t Fl policy Ar object_id The default policy to use for the response unless the client explicitly requires a particular TSA policy. The OID can be specified either in dotted notation or with its name. Overrides the .Cm default_policy config file option. t Fl queryfile Ar request.tsq The name of the file containing a DER-encoded time stamp request. t Fl section Ar tsa_section The name of the config file section containing the settings for the response generation. If not specified the default TSA section is used; see .Sx TS CONFIGURATION FILE OPTIONS for details. t Fl signer Ar tsa_cert.pem The signer certificate of the TSA in PEM format. 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. t Fl text If this option is specified the output is human-readable text format instead of DER. t Fl token_in This flag can be used together with the .Fl in option and indicates that the input is a DER-encoded time stamp token (ContentInfo) instead of a time stamp response (TimeStampResp). t Fl token_out The output is a time stamp token (ContentInfo) instead of time stamp response (TimeStampResp). .El

p 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. l -tag -width Ds t Fl CAfile Ar trusted_certs.pem The name of the file containing a set of trusted self-signed CA certificates in PEM format. See the similar option of .Nm verify for additional details. Either this option or .Fl CApath must be specified. t Fl CApath Ar trusted_cert_path The name of the directory containing the trused CA certificates of the client. See the similar option of .Nm verify for additional details. Either this option or .Fl CAfile must be specified. t 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. t 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. t Fl in Ar response.tsr The time stamp response that needs to be verified, in DER format. This option in mandatory. t 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. t Fl token_in This flag can be used together with the .Fl in option and indicates that the input is a DER-encoded time stamp token (ContentInfo) instead of a time stamp response (TimeStampResp). t Fl untrusted Ar cert_file.pem Set of additional untrusted certificates in PEM format 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 .Sh TS CONFIGURATION FILE OPTIONS The .Fl query and .Fl reply options make use of a configuration file defined by the .Ev OPENSSL_CONF environment variable. The .Fl query option uses only the symbolic OID names section and it can work without it. However, the .Fl reply option needs the config file for its operation.

p When there is a command line switch equivalent of a variable the switch always overrides the settings in the config file. l -tag -width Ds t 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 default section can be overridden with the .Fl section command line switch. t Cm oid_file See .Nm ca for a description. t Cm oid_section See .Nm ca for a description. t Cm serial The name of 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. t Cm signer_cert TSA signing certificate, in PEM format. The same as the .Fl signer command line option. t Cm certs A file containing a set of PEM-encoded certificates that need to be included in the response. The same as the .Fl chain command line option. t Cm signer_key The private key of the TSA, in PEM format. The same as the .Fl inkey command line option. t 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. t 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. t Cm digests The list of message digest algorithms that the TSA accepts. At least one algorithm must be specified. This parameter is mandatory. t 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. t Cm clock_precision_digits Specifies 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. t 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. t 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. t 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 TS ENVIRONMENT VARIABLES .Ev OPENSSL_CONF contains the path of the configuration file and can be overridden by the .Fl config command line option. .Sh TS EXAMPLES All the examples below presume that .Ev OPENSSL_CONF is set to a proper configuration file, e.g. the example configuration file

a openssl/apps/openssl.cnf will do.

p To create a time stamp request for design1.txt with SHA-1 without nonce and policy and no certificate is required in the response: d -literal -offset indent $ openssl ts -query -data design1.txt -no_nonce \e -out design1.tsq .Ed

p To create a similar time stamp request but specifying the message imprint explicitly: d -literal -offset indent $ openssl ts -query \e -digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \e -no_nonce -out design1.tsq .Ed

p To print the content of the previous request in human readable format: d -literal -offset indent $ openssl ts -query -in design1.tsq -text .Ed

p To create a time stamp request which includes the MD5 digest of design2.txt, requests the signer certificate and nonce, specifies a policy ID (assuming the tsa_policy1 name is defined in the OID section of the config file): d -literal -offset indent $ openssl ts -query -data design2.txt -md5 \e -policy tsa_policy1 -cert -out design2.tsq .Ed

p Before generating a response, a signing certificate must be created for the TSA that contains the .Cm timeStamping critical extended key usage extension without any other key usage extensions. You can add the .Dq extendedKeyUsage = critical,timeStamping line to the user certificate section of the config file to generate a proper certificate. See the .Nm req , .Nm ca , and .Nm x509 commands for instructions. The examples below assume that cacert.pem contains the certificate of the CA, tsacert.pem is the signing certificate issued by cacert.pem and tsakey.pem is the private key of the TSA.

p To create a time stamp response for a request: d -literal -offset indent $ openssl ts -reply -queryfile design1.tsq -inkey tsakey.pem \e -signer tsacert.pem -out design1.tsr .Ed

p If you want to use the settings in the config file you could just write: d -literal -offset indent $ openssl ts -reply -queryfile design1.tsq -out design1.tsr .Ed

p To print a time stamp reply to stdout in human readable format: d -literal -offset indent $ openssl ts -reply -in design1.tsr -text .Ed

p To create a time stamp token instead of time stamp response: d -literal -offset indent $ openssl ts -reply -queryfile design1.tsq \e -out design1_token.der -token_out .Ed

p To print a time stamp token to stdout in human readable format: d -literal -offset indent $ openssl ts -reply -in design1_token.der -token_in \e -text -token_out .Ed

p To extract the time stamp token from a response: d -literal -offset indent $ openssl ts -reply -in design1.tsr -out design1_token.der \e -token_out .Ed

p To add .Dq granted status info to a time stamp token thereby creating a valid response: d -literal -offset indent $ openssl ts -reply -in design1_token.der \e -token_in -out design1.tsr .Ed

p To verify a time stamp reply against a request: d -literal -offset indent $ openssl ts -verify -queryfile design1.tsq -in design1.tsr \e -CAfile cacert.pem -untrusted tsacert.pem .Ed

p To verify a time stamp reply that includes the certificate chain: d -literal -offset indent $ openssl ts -verify -queryfile design2.tsq -in design2.tsr \e -CAfile cacert.pem .Ed

p To verify a time stamp token against the original data file: d -literal -offset indent $ openssl ts -verify -data design2.txt -in design2.tsr \e -CAfile cacert.pem .Ed

p To verify a time stamp token against a message imprint: d -literal -offset indent $ openssl ts -verify \e -digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \e -in design2.tsr -CAfile cacert.pem .Ed .Sh TS BUGS No support for time stamps over SMTP, though it is quite easy to implement an automatic email-based TSA with .Xr procmail and .Xr perl 1 . Pure TCP/IP is not supported.

p The file containing the last serial number of the TSA is not locked when being read or written. This is a problem if more than one instance of .Nm OpenSSL is trying to create a time stamp response at the same time.

p Look for the FIXME word in the source files.

p The source code should really be reviewed by somebody else, too.

p More testing is needed. .Sh TS AUTHORS .An Zoltan Glozik Aq Mt zglozik@opentsa.org , OpenTSA project

q Lk http://www.opentsa.org .
SPKAC

.Sh SPKAC .nr nS 1 .Nm "openssl spkac" k -words .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 .Ek .nr nS 0

p The .Nm spkac command processes Netscape signed public key and challenge

q SPKAC files. It can print out their contents, verify the signature, and produce its own SPKACs from a supplied private key.

p The options are as follows: l -tag -width Ds t Fl challenge Ar string Specifies the challenge string if an SPKAC is being created. t Fl in Ar file This specifies the input .Ar file to read from, or standard input if this option is not specified. Ignored if the .Fl key option is used. t 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. t Fl noout Don't output the text version of the SPKAC

q not used if an SPKAC is being created . t Fl out Ar file Specifies the output .Ar file to write to, or standard output by default. t Fl passin Ar arg The key password source. t Fl pubkey Output the public key of an SPKAC

q not used if an SPKAC is being created . t Fl spkac Ar spkacname Allows an alternative name for the variable containing the SPKAC. The default is "SPKAC". This option affects both generated and input SPKAC files. t Fl spksect Ar section Allows an alternative name for the .Ar section containing the SPKAC. The default is the default section. t Fl verify Verifies the digital signature on the supplied SPKAC. .El .Sh SPKAC EXAMPLES Print out the contents of an SPKAC:

p .Dl $ openssl spkac -in spkac.cnf

p Verify the signature of an SPKAC:

p .Dl $ openssl spkac -in spkac.cnf -noout -verify

p Create an SPKAC using the challenge string .Qq hello :

p .Dl $ openssl spkac -key key.pem -challenge hello -out spkac.cnf

p Example of an SPKAC,

q long lines split up for clarity : d -unfilled -offset indent SPKAC=MIG5MGUwXDANBgkqhkiG9w0BAQEFAANLADBIAkEA1cCoq2Wa3Ixs47uI7F\e PVwHVIPDx5yso105Y6zpozam135a8R0CpoRvkkigIyXfcCjiVi5oWk+6FfPaD03u\e PFoQIDAQABFgVoZWxsbzANBgkqhkiG9w0BAQQFAANBAFpQtY/FojdwkJh1bEIYuc\e 2EeM2KHTWPEepWYeawvHD0gQ3DngSC75YCWnnDdq+NQ3F+X4deMx9AaEglZtULwV\e 4= .Ed .Sh SPKAC NOTES A created SPKAC with suitable DN components appended can be fed into the .Nm ca utility.

p SPKACs are typically generated by Netscape when a form is submitted containing the .Em KEYGEN tag as part of the certificate enrollment process.

p The challenge string permits a primitive form of proof of possession of private key. By checking the SPKAC signature and a random challenge string, some guarantee is given that the user knows the private key corresponding to the public key being certified. This is important in some applications. Without this it is possible for a previous SPKAC to be used in a .Qq replay attack .
VERIFY

.Sh VERIFY .nr nS 1 .Nm "openssl verify" k -words .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 Fl .Op Ar certificates .Ek .nr nS 0

p The .Nm verify command verifies certificate chains.

p The options are as follows: l -tag -width Ds t 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. t Fl CAfile Ar file A .Ar file of trusted certificates. The .Ar file should contain multiple certificates in PEM format, concatenated together. t Fl CApath Ar directory A .Ar directory of trusted certificates. The certificates should have names of the form .Em hash.0 , or have symbolic links to them of this form ("hash" is the hashed certificate subject name: see the .Fl hash option of the .Nm x509 utility). The .Nm c_rehash script distributed with OpenSSL will automatically create symbolic links to a directory of certificates. t Fl crl_check Checks end entity certificate validity by attempting to look up a valid CRL. If a valid CRL cannot be found an error occurs. t Fl crl_check_all Checks the validity of all certificates in the chain by attempting to look up valid CRLs. t Fl explicit_policy Set policy variable require-explicit-policy (see RFC 3280 et al). t Fl extended_crl Enable extended CRL features such as indirect CRLs and alternate CRL signing keys. t Fl help Prints out a usage message. t Fl ignore_critical Normally if an unhandled critical extension is present which is not supported by .Nm OpenSSL , the certificate is rejected (as required by RFC 3280 et al). If this option is set, critical extensions are ignored. t Fl inhibit_any Set policy variable inhibit-any-policy (see RFC 3280 et al). t Fl inhibit_map Set policy variable inhibit-policy-mapping (see RFC 3280 et al). t Fl issuer_checks Print out diagnostics relating to searches for the issuer certificate of the current certificate. This shows why each candidate issuer certificate was rejected. However the presence of rejection messages does not itself imply that anything is wrong: during the normal verify process several rejections may take place. t Fl policy_check Enables certificate policy processing. t Fl purpose Ar purpose The intended use for the certificate. Without this option no chain verification will be done. Currently accepted uses are .Ar sslclient , sslserver , .Ar nssslserver , smimesign , .Ar smimeencrypt , crlsign , .Ar any , and .Ar ocsphelper . See the .Sx VERIFY OPERATION section for more information. t Fl untrusted Ar file A .Ar file of untrusted certificates. The .Ar file should contain multiple certificates. t Fl verbose Print extra information about the operations being performed. t Fl x509_strict Disable workarounds for broken certificates which have to be disabled for strict X.509 compliance. t Fl Marks the last option. All arguments following this are assumed to be certificate files. This is useful if the first certificate filename begins with a .Sq - . t Ar certificates One or more .Ar certificates to verify. If no certificate files are included, an attempt is made to read a certificate from standard input. They should all be in PEM format. .El .Sh VERIFY OPERATION The .Nm verify program uses the same functions as the internal SSL and S/MIME verification, therefore this description applies to these verify operations too.

p There is one crucial difference between the verify operations performed by the .Nm verify program: 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.

p The verify operation consists of a number of separate steps:

p 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.

p The process of .Qq looking up the issuer's certificate itself involves a number of steps. In versions of .Nm OpenSSL before 0.9.5a the first certificate whose subject name matched the issuer of the current certificate was assumed to be the issuer's certificate. In .Nm OpenSSL 0.9.6 and later 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

q if present must match the subject key identifier

q if present and issuer and serial number of the candidate issuer; in addition the .Em keyUsage extension of the candidate issuer

q if present must permit certificate signing.

p 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.

p 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 .Sx X.509 CERTIFICATE EXTENSIONS section below.

p The third operation is to check the trust settings on the root CA. The root CA should be trusted for the supplied purpose. For compatibility with previous versions of .Nm SSLeay and .Nm OpenSSL , a certificate with no trust settings is considered to be valid for all purposes.

p The final operation is to check the validity of the certificate chain. The validity period is checked against the current system time and the .Em notBefore and .Em notAfter dates in the certificate. The certificate signatures are also checked at this point.

p If all operations complete successfully, the certificate is considered valid. If any operation fails then the certificate is not valid. .Sh VERIFY DIAGNOSTICS When a verify operation fails, the output messages can be somewhat cryptic. The general form of the error message is: d -unfilled 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

p 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.

p 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 n openssl/x509_vfy.h . Some of the error codes are defined but never returned: these are described as .Qq unused . l -tag -width "XXXX" t Ar "0 X509_V_OK: ok" The operation was successful. t Ar 2 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: unable to get issuer certificate The issuer certificate could not be found: this occurs if the issuer certificate of an untrusted certificate cannot be found. t Ar 3 X509_V_ERR_UNABLE_TO_GET_CRL: unable to get certificate CRL The CRL of a certificate could not be found. t Ar 4 X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE: unable to decrypt certificate's 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. t Ar 5 X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE: unable to decrypt CRL's 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. t Ar 6 X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY: unable to decode issuer public key The public key in the certificate .Em SubjectPublicKeyInfo could not be read. t Ar 7 X509_V_ERR_CERT_SIGNATURE_FAILURE: certificate signature failure The signature of the certificate is invalid. t Ar 8 X509_V_ERR_CRL_SIGNATURE_FAILURE: CRL signature failure The signature of the certificate is invalid. t Ar 9 X509_V_ERR_CERT_NOT_YET_VALID: certificate is not yet valid The certificate is not yet valid: the .Em notBefore date is after the current time. t Ar 10 X509_V_ERR_CERT_HAS_EXPIRED: certificate has expired The certificate has expired; that is, the .Em notAfter date is before the current time. t Ar 11 X509_V_ERR_CRL_NOT_YET_VALID: CRL is not yet valid The CRL is not yet valid. t Ar 12 X509_V_ERR_CRL_HAS_EXPIRED: CRL has expired The CRL has expired. t Ar 13 X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: format error in certificate's notBefore field The certificate .Em notBefore field contains an invalid time. t Ar 14 X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD: format error in certificate's notAfter field The certificate .Em notAfter field contains an invalid time. t Ar 15 X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD: format error in CRL's lastUpdate field The CRL .Em lastUpdate field contains an invalid time. t Ar 16 X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD: format error in CRL's nextUpdate field The CRL .Em nextUpdate field contains an invalid time. t Ar 17 X509_V_ERR_OUT_OF_MEM: out of memory An error occurred trying to allocate memory. This should never happen. t Ar 18 X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: self signed certificate The passed certificate is self-signed and the same certificate cannot be found in the list of trusted certificates. t Ar 19 X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: self signed certificate in certificate chain The certificate chain could be built up using the untrusted certificates but the root could not be found locally. t Ar 20 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: unable to get local issuer certificate The issuer certificate of a locally looked up certificate could not be found. This normally means the list of trusted certificates is not complete. t Ar 21 X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: unable to verify the first certificate No signatures could be verified because the chain contains only one certificate and it is not self-signed. t Ar 22 X509_V_ERR_CERT_CHAIN_TOO_LONG: certificate chain too long The certificate chain length is greater than the supplied maximum depth. Unused. t Ar 23 X509_V_ERR_CERT_REVOKED: certificate revoked The certificate has been revoked. t Ar 24 X509_V_ERR_INVALID_CA: invalid CA certificate A CA certificate is invalid. Either it is not a CA or its extensions are not consistent with the supplied purpose. t Ar 25 X509_V_ERR_PATH_LENGTH_EXCEEDED: path length constraint exceeded The .Em basicConstraints pathlength parameter has been exceeded. t Ar 26 X509_V_ERR_INVALID_PURPOSE: unsupported certificate purpose The supplied certificate cannot be used for the specified purpose. t Ar 27 X509_V_ERR_CERT_UNTRUSTED: certificate not trusted The root CA is not marked as trusted for the specified purpose. t Ar 28 X509_V_ERR_CERT_REJECTED: certificate rejected The root CA is marked to reject the specified purpose. t Ar 29 X509_V_ERR_SUBJECT_ISSUER_MISMATCH: 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. t Ar 30 X509_V_ERR_AKID_SKID_MISMATCH: authority and subject key identifier 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. t Ar 31 X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH: authority and issuer serial number 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. t Ar 32 X509_V_ERR_KEYUSAGE_NO_CERTSIGN:key usage does not include certificate signing The current candidate issuer certificate was rejected because its .Em keyUsage extension does not permit certificate signing. t Ar 50 X509_V_ERR_APPLICATION_VERIFICATION: application verification failure An application specific error. Unused. .El .Sh VERIFY BUGS Although the issuer checks are a considerable improvement over the old technique, they still suffer from limitations in the underlying X509_LOOKUP API. One consequence of this is that trusted certificates with matching subject name must either appear in a file (as specified by the .Fl CAfile option) or a directory (as specified by .Fl CApath ) . If they occur in both, only the certificates in the file will be recognised.

p Previous versions of .Nm OpenSSL assumed certificates with matching subject name were identical and mishandled them.
VERSION

.Sh VERSION .Nm openssl version .Op Fl abdfopv

p The .Nm version command is used to print out version information about .Nm OpenSSL .

p The options are as follows: l -tag -width Ds t Fl a All information: this is the same as setting all the other flags. t Fl b The date the current version of .Nm OpenSSL was built. t Fl d .Ev OPENSSLDIR setting. t Fl f Compilation flags. t Fl o Option information: various options set when the library was built. t Fl p Platform setting. t 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" k -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

p 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.

p Since there are a large number of options, they are split up into various sections. .Sh X509 INPUT, OUTPUT, AND GENERAL PURPOSE OPTIONS l -tag -width "XXXX" t Fl in Ar file This specifies the input .Ar file to read a certificate from, or standard input if this option is not specified. t 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. t 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. t Fl out Ar file This specifies the output .Ar file to write to, or standard output by default. t Fl outform Ar DER | NET | PEM This specifies the output format; the options have the same meaning as the .Fl inform option. t 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. l -tag -width "XXXX" t Fl C This outputs the certificate in the form of a C source file. t 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. t Fl dates Prints out the start and expiry dates of a certificate. t Fl email Outputs the email address(es), if any. t Fl enddate Prints out the expiry date of the certificate; that is, the .Em notAfter date. t Fl fingerprint Prints out the digest of the DER-encoded version of the whole certificate (see .Sx DIGEST OPTIONS ) . t Fl hash A synonym for .Fl subject_hash , for backwards compatibility. t Fl issuer Outputs the issuer name. t Fl issuer_hash Outputs the .Qq hash of the certificate issuer name. t 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. t Fl modulus This option prints out the value of the modulus of the public key contained in the certificate. t 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. t Fl noout This option prevents output of the encoded version of the request. t Fl ocsp_uri Outputs the OCSP responder addresses, if any. t Fl ocspid Print OCSP hash values for the subject name and public key. t Fl pubkey Output the public key. t Fl serial Outputs the certificate serial number. t Fl startdate Prints out the start date of the certificate; that is, the .Em notBefore date. t Fl subject Outputs the subject name. t 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. t 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. t 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.

p 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 .

p 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.

p Trust settings currently are only used with a root CA. They allow a finer control over the purposes the root CA can be used for. For example, a CA may be trusted for an SSL client but not for SSL server use.

p See the description of the .Nm verify utility for more information on the meaning of trust settings.

p Future versions of .Nm OpenSSL will recognize trust settings on any certificate: not just root CAs. l -tag -width "XXXX" t Fl addreject Ar arg Adds a prohibited use. It accepts the same values as the .Fl addtrust option. t Fl addtrust Ar arg Adds a trusted certificate use. Any object name can be used here, but currently only .Ar clientAuth

q SSL client use , .Ar serverAuth

q SSL server use , and .Ar emailProtection

q S/MIME email are used. Other .Nm OpenSSL applications may define additional uses. t Fl alias Outputs the certificate alias, if any. t Fl clrreject Clears all the prohibited or rejected uses of the certificate. t Fl clrtrust Clears all the permitted or trusted uses of the certificate. t 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. t 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 . t 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 . l -tag -width "XXXX" t 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.

p 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. t 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. t Fl CAform Ar DER | PEM The format of the CA certificate file. The default is .Ar PEM . t 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. t Fl CAkeyform Ar DER | PEM The format of the CA private key. The default is .Ar PEM . t Fl CAserial Ar file Sets the CA serial number file to use.

p 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.

p The default filename consists of the CA certificate file base name with

a .srl appended. For example, if the CA certificate file is called

a mycacert.pem , it expects to find a serial number file called

a mycacert.srl . t 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. t 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. t Fl days Ar arg Specifies the number of days to make a certificate valid for. The default is 30 days. t 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

q default section or the default section should contain a variable called .Qq extensions which contains the section to use. t Fl extfile Ar file File containing certificate extensions to use. If not specified, no extensions are added to the certificate. t Fl keyform Ar DER | PEM Specifies the format

q DER or PEM of the private key file used in the .Fl signkey option. t Fl req By default, a certificate is expected on input. With this option a certificate request is expected instead. t 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.

p 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. t Fl signkey Ar file This option causes the input file to be self-signed using the supplied private key.

p If the input file is a certificate, it sets the issuer name to the subject name

q 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.

p 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. t 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. l -tag -width "XXXX" t Ar align Align field values for a more readable output. Only usable with .Ar sep_multiline . t Ar compat Use the old format. This is equivalent to specifying no name options at all. t 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. t 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. t 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. t Ar dump_nostr Dump non-character string types

q 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. t Ar dump_unknown Dump any field whose OID is not recognised by .Nm OpenSSL . t 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. t Ar esc_ctrl Escape control characters. That is, those with ASCII values less than 0x20

q space and the delete

q 0x7f character. They are escaped using the RFC 2253 \eXX notation (where XX are two hex digits representing the character value). t Ar esc_msb Escape characters with the MSB set; that is, with ASCII values larger than 127. t Ar multiline A multiline format. It is equivalent to .Ar esc_ctrl , esc_msb , sep_multiline , .Ar space_eq , lname , and .Ar align . t 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. t 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. t 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. t 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 . t 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. t Ar show_type Show the type of the ASN1 character string. The type precedes the field contents. For example .Qq BMPSTRING: Hello World . t Ar space_eq Places spaces round the .Sq = character which follows the field name. t 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. t 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

q 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. l -tag -width "XXXX" t 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 . t Ar compatible Use the old format. This is equivalent to specifying no output options at all. t Ar ext_default Retain default extension behaviour: attempt to print out unsupported certificate extensions. t Ar ext_dump Hex dump unsupported extensions. t Ar ext_error Print an error message for unsupported certificate extensions. t Ar ext_parse ASN1 parse unsupported extensions. t Ar no_aux Don't print out certificate trust information. t Ar no_extensions Don't print out any X509V3 extensions. t Ar no_header Don't print header information: that is, the lines saying .Qq Certificate and .Qq Data . t Ar no_issuer Don't print out the issuer name. t Ar no_pubkey Don't print out the public key. t Ar no_serial Don't print out the serial number. t Ar no_sigdump Don't give a hexadecimal dump of the certificate signature. t Ar no_signame Don't print out the signature algorithm used. t Ar no_subject Don't print out the subject name. t Ar no_validity Don't print the validity; that is, the .Em notBefore and .Em notAfter fields. t Ar no_version Don't print out the version number. .El .Sh X509 EXAMPLES Display the contents of a certificate:

p .Dl $ openssl x509 -in cert.pem -noout -text

p Display the certificate serial number:

p .Dl $ openssl x509 -in cert.pem -noout -serial

p Display the certificate subject name:

p .Dl $ openssl x509 -in cert.pem -noout -subject

p Display the certificate subject name in RFC 2253 form:

p .Dl $ openssl x509 -in cert.pem -noout -subject -nameopt RFC2253

p Display the certificate subject name in oneline form on a terminal supporting UTF8: d -literal -offset indent $ openssl x509 -in cert.pem -noout -subject \e -nameopt oneline,-esc_msb .Ed

p Display the certificate MD5 fingerprint:

p .Dl $ openssl x509 -in cert.pem -noout -fingerprint

p Display the certificate SHA1 fingerprint:

p .Dl $ openssl x509 -sha1 -in cert.pem -noout -fingerprint

p Convert a certificate from PEM to DER format:

p .Dl "$ openssl x509 -in cert.pem -inform PEM -out cert.der -outform DER"

p Convert a certificate to a certificate request: d -literal -offset indent $ openssl x509 -x509toreq -in cert.pem -out req.pem \e -signkey key.pem .Ed

p Convert a certificate request into a self-signed certificate using extensions for a CA: d -literal -offset indent $ openssl x509 -req -in careq.pem -extfile openssl.cnf -extensions \e v3_ca -signkey key.pem -out cacert.pem .Ed

p Sign a certificate request using the CA certificate above and add user certificate extensions: d -literal -offset indent $ openssl x509 -req -in req.pem -extfile openssl.cnf -extensions \e v3_usr -CA cacert.pem -CAkey key.pem -CAcreateserial .Ed

p Set a certificate to be trusted for SSL client use and set its alias to .Qq Steve's Class 1 CA : d -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: d -unfilled -offset indent -----BEGIN CERTIFICATE----- -----END CERTIFICATE----- .Ed

p It will also handle files containing: d -unfilled -offset indent -----BEGIN X509 CERTIFICATE----- -----END X509 CERTIFICATE----- .Ed

p Trusted certificates have the lines: d -unfilled -offset indent -----BEGIN TRUSTED CERTIFICATE----- -----END TRUSTED CERTIFICATE----- .Ed

p 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.

p 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.

p The Netscape fingerprint uses MD5, whereas MSIE uses SHA1.

p 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.

p The same code is used when verifying untrusted certificates in chains, so this section is useful if a chain is rejected by the verify code.

p 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.

p 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.

p If the certificate is a V1 certificate

q and thus has no extensions and it is self-signed, it is also assumed to be a CA but a warning is again given: this is to work around the problem of Verisign roots which are V1 self-signed certificates.

p 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.

p The extended key usage extension places additional restrictions on the certificate uses. If this extension is present

q whether critical or not , the key can only be used for the purposes specified.

p 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. l -tag -width "XXXX" t 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. t 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. t 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. t 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. t 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. t 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. t 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. t 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. t 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. t Ar CRL Signing The .Em keyUsage extension must be absent or it must have the .Em CRL signing bit set. t 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.

p It is possible to produce invalid certificates or requests by specifying the wrong private key or using inconsistent options in some cases: these should be checked.

p There should be options to explicitly set such things as start and end dates, rather than an offset from the current time.

p 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.

p 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.

p 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. l -tag -width "pass:password" -offset indent t 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. t 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. t 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. t 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. t Cm stdin Read the password from standard input. .El

p File formats, typically specified using .Fl inform and .Fl outform , indicate the type of file being read from or the file format to write. The argument is case insensitive.

p l -tag -width Ds -offset indent -compact t Cm der Distinguished Encoding Rules (DER) is a binary format. t Cm pem Privacy Enhanced Mail (PEM) is base64-encoded. t Cm txt Plain ASCII text. .El .Sh ENVIRONMENT The following environment variables affect the execution of .Nm openssl : l -tag -width "/etc/ssl/openssl.cnf" t Ev OPENSSL_CONF The location of the master configuration file. .El
FILES

.Sh FILES l -tag -width "/etc/ssl/openssl.cnf" -compact t Pa /etc/ssl/ Default config directory for .Nm openssl . t Pa /etc/ssl/lib/ Unused. t Pa /etc/ssl/private/ Default private key directory. t Pa /etc/ssl/openssl.cnf Default configuration file for .Nm openssl . t Pa /etc/ssl/x509v3.cnf Default configuration file for .Nm x509 certificates. .El
SEE ALSO

.Sh SEE ALSO .Xr nc 1 , .Xr ssl 8 , .Xr starttls 8 .Sh STANDARDS .Rs .%D February 1995 .%Q Netscape Communications Corp. .%T The SSL Protocol .Re

p .Rs .%D November 1996 .%Q Netscape Communications Corp. .%T The SSL 3.0 Protocol .Re

p .Rs .%A T. Dierks .%A C. Allen .%D January 1999 .%R RFC 2246 .%T The TLS Protocol Version 1.0 .Re

p .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

p .Rs .%A B. Kaliski .%D March 1998 .%R RFC 2315 .%T PKCS #7: Cryptographic Message Syntax Version 1.5 .Re

p .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

p .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

p .Rs .%A R. Housley .%D June 1999 .%R RFC 2630 .%T Cryptographic Message Syntax .Re

p .Rs .%A P. Chown .%D June 2002 .%R RFC 3268 .%T Advanced Encryption Standard (AES) Ciphersuites for Transport Layer Security (TLS) .Re
OPENSSL HISTORY

.Sh HISTORY The .Xr openssl 1 document appeared in .Nm OpenSSL 0.9.2. The .Cm list- Ns XXX Ns Cm -commands pseudo-commands were added in .Nm OpenSSL 0.9.3; the .Cm no- Ns XXX pseudo-commands were added in .Nm OpenSSL 0.9.5a; the .Cm list- Ns XXX Ns Cm -algorithms pseudo-commands were added in .Nm OpenSSL 1.0.0.