 |
|
| |
OPENSSL(1) |
FreeBSD General Commands Manual |
OPENSSL(1) |
openssl — OpenSSL
command line tool
openssl |
command [command_opt ...]
[command_arg ...] |
openssl |
list-standard-commands |
list-message-digest-commands |
list-cipher-commands |
list-cipher-algorithms |
list-message-digest-algorithms |
list-public-key-algorithms |
OpenSSL is a cryptography toolkit
implementing the Transport Layer Security (TLS) network protocol, as well as
related cryptography standards.
The openssl program is a command line tool
for using the various cryptography functions of
openssl 's crypto library from the shell.
The pseudo-commands
list-standard-commands ,
list-message-digest-commands , and
list-cipher-commands output a list (one entry per
line) of the names of all standard commands, message digest commands, or
cipher commands, respectively, that are available in the present
openssl utility.
The pseudo-commands list-cipher-algorithms
and list-message-digest-algorithms list all cipher
and message digest names, one entry per line. Aliases are listed as:
from => to
The pseudo-command
list-public-key-algorithms lists all supported
public key algorithms.
The pseudo-command
no- command tests whether a
command of the specified name is available. If command
does not exist, it returns 0 and prints
no- command; otherwise it
returns 1 and prints 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 openssl
program.
Note:
no- command is not able to
detect pseudo-commands such as quit ,
list- ...-commands ,
or no- command itself.
openssl asn1parse
- [
-i ]
[-dlimit number]
[-dump ]
[-genconf file]
[-genstr str]
[-in file]
[-inform der | pem | txt ]
[-length number]
[-noout ]
[-offset number]
[-oid file]
[-out file]
[-strparse offset]
The 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.
The options are as follows:
-dlimit
number
- Dump the first number bytes of unknown data in hex
form.
-dump
- Dump unknown data in hex form.
-genconf
file, -genstr
str
- Generate encoded data based on string str, file
file, or both, using the format described in
ASN1_generate_nconf(3).
If only file is present then the string is obtained
from the default section using the name “asn1”. The encoded
data is passed through the ASN.1 parser and printed out as though it came
from a file; the contents can thus be examined and written to a file using
the
-out option.
-i
- Indent the output according to the "depth" of the
structures.
-in
file
- The input file to read from, or standard input if not specified.
-inform
der |
pem |
txt
- The input format.
-length
number
- Number of bytes to parse; the default is until end of file.
-noout
- Do not output the parsed version of the input file.
-offset
number
- Starting offset to begin parsing; the default is start of file.
-oid
file
- A file containing additional object identifiers (OIDs). If an OID (object
identifier) is not part of
openssl 's internal
table, it will be represented in numerical form (for example 1.2.3.4).
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 "short name", which is a single word followed by
whitespace. The final column is the rest of the line and is the
"long name". asn1parse displays the
long name.
-out
file
- The DER-encoded output file; the default is no encoded output (useful when
combined with
-strparse ).
-strparse
offset
- Parse the content octets of the ASN.1 object starting at
offset. This option can be used multiple times to
"drill down" into a nested structure.
openssl ca
- [
-batch ]
[-cert file]
[-config file]
[-create_serial ]
[-crl_CA_compromise time]
[-crl_compromise time]
[-crl_hold instruction]
[-crl_reason reason]
[-crldays days]
[-crlexts section]
[-crlhours hours]
[-crlsec seconds]
[-days arg]
[-enddate date]
[-extensions section]
[-extfile file]
[-gencrl ]
[-in file]
[-infiles ]
[-key password]
[-keyfile file]
[-keyform pem | der ]
[-md alg]
[-msie_hack ]
[-multivalue-rdn ]
[-name section]
[-noemailDN ] [-notext ]
[-out file]
[-outdir directory]
[-passin arg]
[-policy arg]
[-preserveDN ]
[-revoke file]
[-selfsign ]
[-sigopt nm:v]
[-ss_cert file]
[-startdate date]
[-status serial]
[-subj arg]
[-updatedb ] [-utf8 ]
[-verbose ]
The 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.
The options relevant to CAs are as follows:
-batch
- Batch mode. In this mode no questions will be asked and all certificates
will be certified automatically.
-cert
file
- The CA certificate file.
-config
file
- Specify an alternative configuration file.
-create_serial
- If reading the serial from the text file as specified in the configuration
fails, create a new random serial to be used as the next serial
number.
-days
arg
- The number of days to certify the certificate for.
-enddate
date
- Set the expiry date. The format of the date is [YY]YYMMDDHHMMSSZ, with all
four year digits required for dates from 2050 onwards.
-extensions
section
- The section of the configuration file containing certificate extensions to
be added when a certificate is issued (defaults to
x509_extensions unless the
-extfile option is used). If no extension section
is present, a V1 certificate is created. If the extension section is
present (even if it is empty), then a V3 certificate is created. See the
x509v3.cnf(5)
manual page for details of the extension section format.
-extfile
file
- An additional configuration file to read certificate
extensions from (using the default section unless the
-extensions option is also used).
-in
file
- An input file containing a single certificate
request to be signed by the CA.
-infiles
- If present, this should be the last option; all subsequent arguments are
assumed to be the names of files containing certificate requests.
-key
password
- 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.
-keyfile
file
- The private key to sign requests with.
-keyform
pem |
der
- Private key file format. The default is
pem .
-md
alg
- The message digest to use. Possible values include
md5 and sha1. This option also
applies to CRLs.
-msie_hack
- This is a legacy option to make
ca work with very
old versions of the IE certificate enrollment control
"certenr3". It used UniversalStrings for almost everything.
Since the old control has various security bugs, its use is strongly
discouraged. The newer control "Xenroll" does not need this
option.
-multivalue-rdn
- This option causes the
-subj argument to be
interpreted with full support for multivalued RDNs, for example
"/DC=org/DC=OpenSSL/DC=users/UID=123456+CN=John Doe". If
-multivalue-rdn is not used, the UID value is set
to "123456+CN=John Doe".
-name
section
- Specifies the configuration file section to use
(overrides
default_ca in the
ca section).
-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
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
email_in_dn keyword can be used in the configuration
file to enable this behaviour.
-notext
- Don't output the text form of a certificate to the output file.
-out
file
- The output file to output certificates to. The default is standard output.
The certificate details will also be printed out to this file in PEM
format.
-outdir
directory
- The directory to output certificates to. The
certificate will be written to a file consisting of the serial number in
hex with ".pem" appended.
-passin
arg
- The key password source.
-policy
arg
- Define the CA "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 "match" (the
value must match the same field in the CA certificate),
"supplied" (the value must be present), or "optional"
(the value may be present). Any fields not mentioned in the policy section
are silently deleted, unless the
-preserveDN
option is set, but this can be regarded more of a quirk than intended
behaviour.
-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.
-selfsign
- Indicates the issued certificates are to be signed with the key the
certificate requests were signed with, given with
-keyfile . Certificate requests signed with a
different key are ignored. If -gencrl or
-ss_cert are given,
-selfsign is ignored.
A consequence of using -selfsign is
that the self-signed certificate appears among the entries in the
certificate database (see the configuration option
database ) and uses the same serial number
counter as all other certificates signed with the self-signed
certificate.
-sigopt
nm:v
- Pass options to the signature algorithm during sign or certify operations.
The names and values of these options are algorithm-specific.
-ss_cert
file
- A single self-signed certificate to be signed by the CA.
-startdate
date
- Set the start date. The format of the date is [YY]YYMMDDHHMMSSZ, with all
four year digits required for dates from 2050 onwards.
-subj
arg
- Supersedes the subject name given in the request. The
arg must be formatted as
/type0=value0/type1=value1/type2=...;
characters may be escaped by ‘\’ (backslash), no spaces are
skipped.
-utf8
- Interpret field values read from a terminal or obtained from a
configuration file as UTF-8 strings. By default, they are interpreted as
ASCII.
-verbose
- Print extra details about the operations being performed.
The options relevant to CRLs are as follows:
-crl_CA_compromise
time
- This is the same as
-crl_compromise , except the
revocation reason is set to CACompromise.
-crl_compromise
time
- Set the revocation reason to keyCompromise and the compromise time to
time. time should be in
GeneralizedTime format, i.e. YYYYMMDDHHMMSSZ.
-crl_hold
instruction
- Set the CRL revocation reason code to certificateHold and the hold
instruction to 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.
-crl_reason
reason
- Revocation reason, where reason is one of:
unspecified, keyCompromise, CACompromise, affiliationChanged, superseded,
cessationOfOperation, certificateHold or removeFromCRL. The matching of
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.
-crldays
days
- The number of days before the next CRL is due. This is the days from now
to place in the CRL
nextUpdate field.
-crlexts
section
- The 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 (even if it is
empty) then a V2 CRL is created. The CRL extensions specified are CRL
extensions and not CRL entry extensions. It should be noted that some
software can't handle V2 CRLs. See the
x509v3.cnf(5)
manual page for details of the extension section format.
-crlhours
hours
- The number of hours before the next CRL is due.
-crlsec
seconds
- The number of seconds before the next CRL is due.
-gencrl
- Generate a CRL based on information in the index file.
-revoke
file
- A file containing a certificate to revoke.
-status
serial
- Show the status of the certificate with serial number
serial.
-updatedb
- Update the database index to purge expired certificates.
Many of the options can be set in the ca
section of the configuration file (or in the default section of the
configuration file), specified using default_ca or
-name . The options preserve
and msie_hack are read directly from the
ca section.
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 (if any) used.
certificate
- The same as
-cert . It gives the file containing
the CA certificate. Mandatory.
copy_extensions
- Determines how extensions in certificate requests should be handled. If
set to
none or this option is not present, then
extensions are ignored and not copied to the certificate. If set to
copy , then any extensions present in the request
that are not already present are copied to the certificate. If set to
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.
The 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
basicConstraints extension with CA:TRUE and the
copy_extensions value is set to
copyall and the user does not spot this when the
certificate is displayed, then this will hand the requester a valid CA
certificate.
This situation can be avoided by setting
copy_extensions to copy
and including basicConstraints with CA:FALSE in
the configuration file. Then if the request contains a
basicConstraints extension, it will be
ignored.
The main use of this option is to allow a certificate request
to supply values for certain extensions such as
subjectAltName .
crl_extensions
- The same as
-crlexts .
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.
database
- The text database file to use. Mandatory. This file must be present,
though initially it will be empty.
default_crl_hours ,
default_crl_days
- The same as the
-crlhours and
-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.
default_days
- The same as the
-days option. The number of days
to certify a certificate for.
default_enddate
- The same as the
-enddate option. Either this
option or default_days (or the command line
equivalents) must be present.
default_md
- The same as the
-md option. The message digest to
use. Mandatory.
default_startdate
- The same as the
-startdate option. The start date
to certify a certificate for. If not set, the current time is used.
email_in_dn
- The same as
-noemailDN . If the EMAIL field is to
be removed from the DN of the certificate, simply set this to
"no". If not present, the default is to allow for the EMAIL
field in the certificate's DN.
msie_hack
- The same as
-msie_hack .
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
x509 utilities' -nameopt
and -certopt switches can be used here, except
that no_signame and
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).
For convenience, the value ca_default
is accepted by both to produce a reasonable output.
If neither option is present, the format used in earlier
versions of openssl is used. Use of the old
format is strongly discouraged because it only displays fields mentioned
in the policy section, mishandles multicharacter
string types and does not display extensions.
new_certs_dir
- The same as the
-outdir command line option. It
specifies the directory where new certificates will be placed.
Mandatory.
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.
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 ‘=’ and the numerical form. The short
and long names are the same when this option is used.
policy
- The same as
-policy . Mandatory.
preserve
- The same as
-preserveDN .
private_key
- Same as the
-keyfile option. The file containing
the CA private key. Mandatory.
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.
unique_subject
- If the value
yes is given, the valid certificate
entries in the database must have unique subjects. If the value
no is given, several valid certificate entries may
have the exact same subject. The default value is
yes .
Note that it is valid in some circumstances for certificates
to be created without any subject. In cases where there are multiple
certificates without subjects this does not count as a duplicate.
x509_extensions
- The same as
-extensions .
openssl certhash
- [
-nv ] dir ...
The certhash command calculates a hash
value of ".pem" file in the specified directory list and creates
symbolic links for each file, where the name of the link is the hash value.
See the
SSL_CTX_load_verify_locations(3)
manual page for how hash links are used.
The links created are of the form "HHHHHHHH.D", where
each ‘H’ is a hexadecimal character and ‘D’ is a
single decimal digit. The hashes for CRLs look similar, except the letter
‘r’ appears after the period, like this:
"HHHHHHHH.rD". When processing a directory,
certhash will first remove all links that have a
name in that syntax and invalid reference.
Multiple objects may have the same hash; they will be indicated by
incrementing the ‘D’ value. Duplicates are found by comparing
the full SHA256 fingerprint. A warning will be displayed if a duplicate is
found.
A warning will also be displayed if there are files that cannot be
parsed as either a certificate or a CRL.
The options are as follows:
-n
- Perform a dry-run, and do not make any changes.
-v
- Print extra details about the processing.
- dir ...
- Specify the directories to process.
openssl ciphers
[-hsVv ] [-tls1_2 ]
[-tls1_3 ] [control]
The ciphers command converts the
control string from the format documented in
SSL_CTX_set_cipher_list(3)
into an ordered SSL cipher suite preference list. If no
control string is specified, the
DEFAULT list is printed.
The options are as follows:
-h ,
-?
- Print a brief usage message.
-s
- Only list ciphers that are supported by the TLS method.
-tls1_2
|
-tls1_3
- In combination with the
-s option, list the
ciphers which could be used if the specified protocol version were
negotiated.
-V
- Verbose. List ciphers with cipher suite code in hex format, cipher name,
and a complete description of protocol version, key exchange,
authentication, encryption, and mac algorithms.
-v
- Like
-V , but without cipher suite codes.
openssl cms
- [
-aes128
| -aes192 | -aes256 | -camellia128 | -camellia192
| -camellia256 | -des | -des3 | -rc2-40
| -rc2-64 | -rc2-128 ]
[-CAfile file]
[-CApath directory]
[-CRLfile file]
[-binary ]
[-certfile file]
[-certsout file]
[-cmsout ] [-compress ]
[-content file]
[-crlfeol ] [-data_create ]
[-data_out ]
[-debug_decrypt ]
[-decrypt ]
[-digest_create ]
[-digest_verify ]
[-econtent_type type]
[-encrypt ]
[-EncryptedData_decrypt ]
[-EncryptedData_encrypt ]
[-from addr]
[-in file]
[-inform der | pem | smime ]
[-inkey file]
[-keyform der | pem ]
[-keyid ]
[-keyopt nm:v]
[-md digest]
[-no_attr_verify ]
[-no_content_verify ]
[-no_signer_cert_verify ]
[-noattr ] [-nocerts ]
[-nodetach ] [-nointern ]
[-nooldmime ] [-noout ]
[-nosigs ] [-nosmimecap ]
[-noverify ]
[-out file]
[-outform der | pem | smime ]
[-passin src]
[-print ]
[-pwri_password arg]
[-rctform der | pem | smime ]
[-receipt_request_all | -receipt_request_first ]
[-receipt_request_from addr]
[-receipt_request_print ]
[-receipt_request_to addr]
[-recip file]
[-resign ]
[-secretkey key]
[-secretkeyid id]
[-sign ] [-sign_receipt ]
[-signer file]
[-stream | -indef | -noindef ]
[-subject s]
[-text ]
[-to addr]
[-uncompress ] [-verify ]
[-verify_receipt file]
[-verify_retcode ]
[cert.pem ...]
The cms command handles S/MIME v3.1 mail.
It can encrypt, decrypt, sign and verify, compress and uncompress S/MIME
messages.
The MIME message must be sent without any blank lines between the
headers and the output. Some mail programs will automatically add a blank
line. Piping the mail directly to sendmail is one way to achieve the correct
format.
The supplied message to be signed or encrypted must include the
necessary MIME headers or many S/MIME clients won't display it properly (if
at all). You can use the -text option to
automatically add plain text headers.
A "signed and encrypted" message is one where a signed
message is then encrypted. This can be produced by encrypting an already
signed message.
There are various operation options that set the type of operation
to be performed. The meaning of the other options varies according to the
operation type.
-encrypt
- Encrypt mail for the given recipient certificates. Input file is the
message to be encrypted. The output file is the encrypted mail in MIME
format. The actual CMS type is EnvelopedData. Note that no revocation
check is done for the recipient cert, so if that key has been compromised,
others may be able to decrypt the text.
-decrypt
- Decrypt mail using the supplied certificate and private key. Expects an
encrypted mail message in MIME format for the input file. The decrypted
mail is written to the output file.
-sign
- Sign mail using the supplied certificate and private key. Input file is
the message to be signed. The signed message in MIME format is written to
the output file.
-verify
- Verify signed mail. Expects a signed mail message on input and outputs the
signed data. Both clear text and opaque signing are supported.
-cmsout
- Take an input message and write out a PEM encoded CMS structure.
-resign
- Resign a message. Take an existing message and one or more new signers.
This operation 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.
-data_create
- Create a CMS Data type.
-data_out
- Output a content from the input CMS Data type.
-digest_create
- Create a CMS DigestedData type.
-digest_verify
- Verify a CMS DigestedData type and output the content.
-compress
- Create a CMS CompressedData type. Must be compiled with zlib support for
this option to work.
-uncompress
- Uncompress a CMS CompressedData type and output the content. Must be
compiled with zlib support for this option to work.
-EncryptedData_encrypt
- Encrypt a content using supplied symmetric key and algorithm using a CMS
EncryptedData type.
-EncryptedData_decrypt
- Decrypt a CMS EncryptedData type using supplied symmetric key.
-sign_receipt
- Generate and output a signed receipt for the supplied message. The input
message must contain a signed receipt request. Functionality is otherwise
similar to the
-sign operation.
-verify_receipt
file
- Verify a signed receipt in file. The input message must contain the
original receipt request. Functionality is otherwise similar to the
-verify operation.
The remaining options are as follows:
-aes128
|
-aes192
|
-aes256
|
-camellia128
|
-camellia192
|
-camellia256
| -des
|
-des3
|
-rc2-40
|
-rc2-64
|
-rc2-128
- The encryption algorithm to use. 128-, 192-, or 256-bit AES, 128-, 192-,
or 256-bit CAMELLIA, DES (56 bits), triple DES (168 bits), or 40-, 64-, or
128-bit RC2, respectively; if not specified, triple DES is used. Only used
with
-encrypt and
-EncryptedData_encrypt commands.
-binary
- Normally the input message is converted to "canonical" format
which is effectively using CR/LF as end of line, as required by the S/MIME
specification. When this option is present, no translation occurs. This is
useful when handling binary data which may not be in MIME format.
-CAfile
file
- A file containing trusted CA certificates, used with
-verify and
-verify_receipt .
-CApath
directory
- A directory containing trusted CA certificates, used with
-verify and
-verify_receipt . This directory must be a standard
certificate directory: that is a hash of each subject name (using
x509 -hash ) should be
linked to each certificate.
-CRLfile
file
- Allows additional certificate revocation lists to be specified for
verification. The CRLs should be in PEM format.
- cert.pem ...
- One or more certificates of message recipients: used when encrypting a
message.
-certfile
file
- Allows additional certificates to be specified. When signing, these will
be included with the message. When verifying, these will be searched for
the signer's certificates. The certificates should be in PEM format.
-certsout
file
- A file that any certificates contained in the message are written to.
-check_ss_sig ,
-crl_check , -crl_check_all ,
-extended_crl ,
-ignore_critical ,
-issuer_checks , -policy ,
-policy_check , -purpose ,
-x509_strict
- Set various certificate chain validation options. See the
verify command for details.
-content
file
- A file containing the detached content. This is only useful with the
-verify command. This is only usable if the CMS
structure is using the detached signature form where the content is not
included. This option will override any content if the input format is
S/MIME and it uses the multipart/signed MIME content type.
-crlfeol
- Output a S/MIME message with CR/LF end of line.
-debug_decrypt
- Set the CMS_DEBUG_DECRYPT flag when decrypting. This option should be used
with caution, since this can be used to disable the MMA attack protection
and return an error if no recipient can be found. See the
CMS_decrypt(3)
manual page for details of the flag.
-from
addr, -subject
s, -to
addr
- The relevant mail headers. These are included outside the signed portion
of a message so they may be included manually. If signing then many S/MIME
mail clients check the signer's certificate's email address matches that
specified in the From: address.
-econtent_type
type
- Set the encapsulated content type, used with
-sign . If not supplied, the Data type is used. The
type argument can be any valid OID name in either text or numerical
format.
-in
file
- The input message to be encrypted or signed or the message to be decrypted
or verified.
-inform
der |
pem
| smime
- The input format for the CMS structure. The default is
smime , which reads an S/MIME format message.
pem and der format change
this to expect PEM and DER format CMS structures instead. This currently
only affects the input format of the CMS structure; if no CMS structure is
being input (for example with -encrypt or
-sign ) this option has no effect.
-inkey
file
- The private key to use when signing or decrypting. This must match the
corresponding certificate. If this option is not specified then the
private key must be included in the certificate file specified with the
-recip or -signer file.
When signing, this option can be used multiple times to specify successive
keys.
-keyform
der |
pem
- Input private key format. The default is
pem .
-keyid
- Use subject key identifier to identify certificates instead of issuer name
and serial number. The supplied certificate must include a subject key
identifier extension. Supported by
-sign and
-encrypt operations.
-keyopt
nm:v
- Set customised parameters for the preceding key or certificate for
encryption and signing. It can currently be used to set RSA-PSS for
signing, RSA-OAEP for encryption or to modify default parameters for ECDH.
This option can be used multiple times.
-md
digest
- The digest algorithm to use when signing or resigning. If not present then
the default digest algorithm for the signing key will be used (usually
SHA1).
-no_attr_verify
- Do not verify the signer's attribute of a signature.
-no_content_verify
- Do not verify the content of a signed message.
-no_signer_cert_verify
- Do not verify the signer's certificate of a signed message.
-noattr
- Do not include attributes. 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.
-nocerts
- Do not include the signer's certificate. This will reduce the size of the
signed message but the verifier must have a copy of the signer's
certificate available locally (passed using the
-certfile option for example).
-nodetach
- When signing a message, use opaque signing. This form is more resistant to
translation by mail relays but it cannot be read by mail agents that do
not support S/MIME. Without this option cleartext signing with the MIME
type multipart/signed is used.
-nointern
- Only the certificates specified in the
-certfile
option are used. When verifying a message, normally certificates (if any)
included in the message are searched for the signing certificate. The
supplied certificates can still be used as untrusted CAs however.
-nooldmime
- Output an old S/MIME content type like
"application/x-pkcs7-".
-noout
- Do not output the parsed CMS structure for the
-cmsout operation. This is useful when combined
with the -print option or if the syntax of the CMS
structure is being checked.
-nosigs
- Do not try to verify the signatures on the message.
-nosmimecap
- Exclude the list of supported algorithms from signed attributes; other
options such as signing time and content type are still included.
-noverify
- Do not verify the signer's certificate of a signed message.
-out
file
- The message text that has been decrypted or verified or the output MIME
format message that has been signed or verified.
-outform
der |
pem
| smime
- This specifies the output format for the CMS structure. The default is
smime , which writes an S/MIME format message.
pem and der format change
this to write PEM and DER format CMS structures instead. This currently
only affects the output format of the CMS structure; if no CMS structure
is being output (for example with -verify or
-decrypt ) this option has no effect.
-passin
src
- The private key password source.
-print
- Print out all fields of the CMS structure for the
-cmsout operation. This is mainly useful for
testing purposes.
-pwri_password
arg
- Specify PasswordRecipientInfo (PWRI) password to use. Supported by the
-encrypt and -decrypt
operations.
-rctform
der |
pem
| smime
- Specify the format for a signed receipt for use with the
-receipt_verify operation. The default is
smime .
-receipt_request_all
|
-receipt_request_first
- Indicate requests should be provided by all recipient or first tier
recipients (those mailed directly and not from a mailing list), for the
-sign operation to include a signed receipt
request. Ignored if -receipt_request_from is
included.
-receipt_request_from
addr
- Add an explicit email address where receipts should be supplied.
-receipt_request_print
- Print out the contents of any signed receipt requests for the
-verify operation.
-receipt_request_to
addr
- Add an explicit email address where signed receipts should be sent to.
This option must be supplied if a signed receipt is requested.
-recip
file
- When decrypting a message, this specifies the recipient's certificate. The
certificate must match one of the recipients of the message or an error
occurs. When encrypting a message, this option may be used multiple times
to specify each recipient. This form must be used if customised parameters
are required (for example to specify RSA-OAEP). Only certificates carrying
RSA, Diffie-Hellman or EC keys are supported by this option.
-secretkey
key
- Specify symmetric key to use. The key must be supplied in hex format and
be consistent with the algorithm used. Supported by the
-EncryptedData_encrypt ,
-EncryptedData_decrypt ,
-encrypt and -decrypt
operations. When used with -encrypt or
-decrypt , the supplied key is used to wrap or
unwrap the content encryption key using an AES key in the KEKRecipientInfo
type.
-secretkeyid
id
- The key identifier for the supplied symmetric key for KEKRecipientInfo
type. This option must be present if the
-secretkey option is used with
-encrypt . With -decrypt
operations the id is used to locate the relevant key; if it is not
supplied then an attempt is used to decrypt any KEKRecipientInfo
structures.
-signer
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 then the signers certificates will be written to this
file if the verification was successful.
-stream
|
-indef
|
-noindef
- The
-stream and -indef
options are equivalent and 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. -noindef disable
streaming I/O where it would produce an indefinite length constructed
encoding. This option currently has no effect.
-text
- Add plain text (text/plain) MIME headers to the supplied message if
encrypting or signing. If decrypting or verifying, it strips off text
headers: if the decrypted or verified message is not of MIME type
text/plain then an error occurs.
-verify_retcode
- Set verification error code to exit code to indicate what verification
error has occurred. Supported by
-verify operation
only. Exit code value minus 32 shows verification error code. See
verify command for the list of verification error
code.
The exit codes for cms are as follows:
- 0
- The operation was completely successful.
- 1
- An error occurred parsing the command options.
- 2
- One of the input files could not be read.
- 3
- An error occurred creating the CMS file or when reading the MIME
message.
- 4
- An error occurred decrypting or verifying the message.
- 5
- The message was verified correctly but an error occurred writing out the
signer's certificates.
- 6
- An error occurred writing the output file.
- 32+
- A verify error occurred while
-verify_retcode is
specified.
openssl crl
- [
-CAfile file]
[-CApath dir]
[-crlnumber ]
[-fingerprint ] [-hash ]
[-hash_old ]
[-in file]
[-inform der | pem ]
[-issuer ] [-lastupdate ]
[-nameopt option]
[-nextupdate ] [-noout ]
[-out file]
[-outform der | pem ]
[-text ] [-verify ]
The crl command processes CRL files in DER
or PEM format.
The options are as follows:
-CAfile
file
- Verify the signature on a CRL by looking up the issuing certificate in
file.
-CApath
directory
- Verify the signature on a CRL by looking up the issuing certificate in
dir. This directory must be a standard certificate
directory, i.e. a hash of each subject name (using
x509 -hash ) should be
linked to each certificate.
-crlnumber
- Print the CRL number.
-fingerprint
- Print the CRL fingerprint.
-hash
- Output a hash of the issuer name. This can be used to look up CRLs in a
directory by issuer name.
-hash_old
- Output an old-style (MD5) hash of the issuer name.
-in
file
- The input file to read from, or standard input if not specified.
-inform
der |
pem
- The input format.
-issuer
- Output the issuer name.
-lastupdate
- Output the
thisUpdate field. This option is
misnamed for historical reasons.
-nameopt
option
- Specify certificate name options.
-nextupdate
- Output the
nextUpdate field.
-noout
- Do not output the encoded version of the CRL.
-out
file
- The output file to write to, or standard output if not specified.
-outform
der |
pem
- The output format.
-text
- Print the CRL in plain text.
-verify
- Verify the signature on the CRL.
openssl crl2pkcs7
- [
-certfile file]
[-in file]
[-inform der | pem ]
[-nocrl ]
[-out file]
[-outform der | pem ]
The crl2pkcs7 command takes an optional
CRL and one or more certificates and converts them into a PKCS#7 degenerate
"certificates only" structure.
The options are as follows:
-certfile
file
- Add the certificates in PEM file to the PKCS#7
structure. This option can be used more than once to read certificates
from multiple files.
-in
file
- Read the CRL from file, or standard input if not
specified.
-inform
der |
pem
- The input format.
-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.
-out
file
- Write the PKCS#7 structure to file, or standard
output if not specified.
-outform
der |
pem
- The output format.
openssl dgst
- [
-cdr ] [-binary ]
[- digest]
[-hex ]
[-hmac key]
[-keyform pem ]
[-mac algorithm]
[-macopt nm:v]
[-out file]
[-passin arg]
[-prverify file]
[-sign file]
[-signature file]
[-sigopt nm:v]
[-verify file]
[file ...]
The digest functions output the message digest of a supplied
file or files in hexadecimal
form. They can also be used for digital signing and verification.
The options are as follows:
-binary
- Output the digest or signature in binary form.
-c
- Print the digest in two-digit groups separated by colons.
-d
- Print BIO debugging information.
- digest
- Use the specified message digest. The default is
SHA256. The available digests can be displayed using
openssl
list-message-digest-commands . The following are
equivalent: openssl dgst
-sha256 and openssl
sha256 .
-hex
- Digest is to be output as a hex dump. This is the default case for a
"normal" digest as opposed to a digital signature.
-hmac
key
- Create a hashed MAC using key.
-keyform
pem
- Specifies the key format to sign the digest with.
-mac
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
-macopt parameter.
-macopt
nm:v
- Passes options to the MAC algorithm, specified by
-mac . The following options are supported by HMAC:
key :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.
hexkey :string
- Specifies the MAC key in hexadecimal form (two hex digits per byte).
Key length must conform to any restrictions of the MAC algorithm.
-out
file
- The output file to write to, or standard output if not specified.
-passin
arg
- The key password source.
-prverify
file
- Verify the signature using the private key in file.
The output is either "Verification OK" or "Verification
Failure".
-r
- Print the digest in coreutils format.
-sign
file
- Digitally sign the digest using the private key in
file.
-signature
file
- The actual signature to verify.
-sigopt
nm:v
- Pass options to the signature algorithm during sign or verify operations.
The names and values of these options are algorithm-specific.
-verify file
- Verify the signature using the public key in file.
The output is either "Verification OK" or "Verification
Failure".
- file ...
- File or files to digest. If no files are specified then standard input is
used.
openssl dhparam
- [
-2 | -5 ]
[-check ] [-dsaparam ]
[-in file]
[-inform der | pem ]
[-noout ]
[-out file]
[-outform der | pem ]
[-text ] [numbits]
The dhparam command is used to manipulate
DH parameter files. Only the older PKCS#3 DH is supported, not the newer
X9.42 DH.
The options are as follows:
-2 ,
-5
- The generator to use; 2 is the default. If present, the input file is
ignored and parameters are generated instead.
-check
- Check the DH parameters.
-dsaparam
- Read or create DSA parameters, converted to DH format on output.
Otherwise, "strong" primes (such that (p-1)/2 is also prime)
will be used for DH parameter generation.
DH parameter generation with the
-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.
-in
file
- The input file to read from, or standard input if not specified.
-inform
der |
pem
- The input format.
-noout
- Do not output the encoded version of the parameters.
-out
file
- The output file to write to, or standard output if not specified.
-outform
der |
pem
- The output format.
-text
- Print the DH parameters in plain text.
- numbits
- Generate a parameter set of size 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.
openssl dsa
- [
-aes128
| -aes192 | -aes256 | -des
| -des3 ]
[-in file]
[-inform der | pem | pvk ]
[-modulus ] [-noout ]
[-out file]
[-outform der | pem | pvk ]
[-passin arg]
[-passout arg]
[-pubin ] [-pubout ]
[-pvk-none | -pvk-strong | -pvk-weak ]
[-text ]
The dsa command processes DSA keys. They
can be converted between various forms and their components printed out.
Note: This command uses the traditional
SSLeay compatible format for private key encryption:
newer applications should use the more secure PKCS#8 format using the
pkcs8 command.
The options are as follows:
-aes128
|
-aes192
|
-aes256
|
-des
|
-des3
- Encrypt the private key with the AES, DES, or the triple DES ciphers,
respectively, before outputting it. A pass phrase is prompted for. If none
of these options are specified, the key is written in plain text. This
means that using the
dsa utility to read an
encrypted key with no encryption option can be used to remove the pass
phrase from a key, or by setting the encryption options it can be used to
add or change the pass phrase. These options can only be used with PEM
format output files.
-in
file
- The input file to read from, or standard input if not specified. If the
key is encrypted, a pass phrase will be prompted for.
-inform
der |
pem
|
pvk
- The input format.
-modulus
- Print the value of the public key component of the key.
-noout
- Do not output the encoded version of the key.
-out
file
- The output file to write to, or standard output if not specified. If any
encryption options are set then a pass phrase will be prompted for.
-outform
der |
pem
|
pvk
- The output format.
-passin
arg
- The key password source.
-passout
arg
- The output file password source.
-pubin
- Read in a public key, not a private key.
-pubout
- Output a public key, not a private key. Automatically set if the input is
a public key.
-pvk-none
|
-pvk-strong
|
-pvk-weak
- Enable or disable PVK encoding. The default is
-pvk-strong .
-text
- Print the public/private key in plain text.
openssl dsaparam
- [
-genkey ]
[-in file]
[-inform der | pem ]
[-noout ]
[-out file]
[-outform der | pem ]
[-text ] [numbits]
The dsaparam command is used to manipulate
or generate DSA parameter files.
The options are as follows:
-genkey
- Generate a DSA key either using the specified or generated
parameters.
-in
file
- The input file to read from, or standard input if not specified. If the
numbits parameter is included, then this option is
ignored.
-inform
der |
pem
- The input format.
-noout
- Do not output the encoded version of the parameters.
-out
file
- The output file to write to, or standard output if not specified.
-outform
der |
pem
- The output format.
-text
- Print the DSA parameters in plain text.
- numbits
- Generate a parameter set of size numbits. If this
option is included, the input file is ignored.
openssl ec
- [
-conv_form arg]
[-des ] [-des3 ]
[-in file]
[-inform der | pem ]
[-noout ]
[-out file]
[-outform der | pem ]
[-param_enc arg]
[-param_out ]
[-passin arg]
[-passout arg]
[-pubin ] [-pubout ]
[-text ]
The ec command processes EC keys. They can
be converted between various forms and their components printed out.
openssl uses the private key format specified in
“SEC 1: Elliptic Curve Cryptography”
(https://www.secg.org/). To
convert an EC private key into the PKCS#8 private key format use the
pkcs8 command.
The options are as follows:
-conv_form
arg
- Specify how the points on the elliptic curve are converted into octet
strings. Possible values are:
compressed ,
uncompressed (the default), and
hybrid . For more information regarding the point
conversion forms see the X9.62 standard. Note: Due to patent issues the
compressed option is disabled by default for
binary curves and can be enabled by defining the preprocessor macro
OPENSSL_EC_BIN_PT_COMP at compile time.
-des
|
-des3
- Encrypt the private key with DES, triple DES, or any other cipher
supported by
openssl . 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 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
used to add or change the pass phrase. These options can only be used with
PEM format output files.
-in
file
- The input file to read a key from, or standard input if not specified. If
the key is encrypted, a pass phrase will be prompted for.
-inform
der |
pem
- The input format.
-noout
- Do not output the encoded version of the key.
-out
file
- The output filename to write to, or standard output if not specified. If
any encryption options are set then a pass phrase will be prompted
for.
-outform
der |
pem
- The output format.
-param_enc
arg
- Specify how the elliptic curve parameters are encoded. Possible value are:
named_curve , i.e. the EC parameters are specified
by an OID; or explicit , where the EC parameters
are explicitly given (see RFC 3279 for the definition of the EC parameter
structures). The default value is named_curve .
Note: the implicitlyCA alternative, as specified
in RFC 3279, is currently not implemented.
-param_out
- Print the elliptic curve parameters.
-passin
arg
- The key password source.
-passout
arg
- The output file password source.
-pubin
- Read in a public key, not a private key.
-pubout
- Output a public key, not a private key. Automatically set if the input is
a public key.
-text
- Print the public/private key in plain text.
openssl ecparam
- [
-check ]
[-conv_form arg]
[-genkey ]
[-in file]
[-inform der | pem ]
[-list_curves ]
[-name arg]
[-no_seed ] [-noout ]
[-out file]
[-outform der | pem ]
[-param_enc arg]
[-text ]
The ecparam command is used to manipulate
or generate EC parameter files. openssl is not able
to generate new groups so ecparam can only create EC
parameters from known (named) curves.
The options are as follows:
-check
- Validate the elliptic curve parameters.
-conv_form
arg
- Specify how the points on the elliptic curve are converted into octet
strings. Possible values are:
compressed ,
uncompressed (the default), and
hybrid . For more information regarding the point
conversion forms see the X9.62 standard. Note: Due to patent issues the
compressed option is disabled by default for
binary curves and can be enabled by defining the preprocessor macro
OPENSSL_EC_BIN_PT_COMP at compile time.
-genkey
- Generate an EC private key using the specified parameters.
-in
file
- The input file to read from, or standard input if not specified.
-inform
der |
pem
- The input format.
-list_curves
- Print a list of all currently implemented EC parameter names and
exit.
-name
arg
- Use the EC parameters with the specified "short" name.
-no_seed
- Do not include the seed for the parameter generation in the ECParameters
structure (see RFC 3279).
-noout
- Do not output the encoded version of the parameters.
-out
file
- The output file to write to, or standard output if not specified.
-outform
der |
pem
- The output format.
-param_enc
arg
- Specify how the elliptic curve parameters are encoded. Possible value are:
named_curve , i.e. the EC parameters are specified
by an OID, or explicit , where the EC parameters
are explicitly given (see RFC 3279 for the definition of the EC parameter
structures). The default value is named_curve .
Note: the implicitlyCA alternative, as specified
in RFC 3279, is currently not implemented.
-text
- Print the EC parameters in plain text.
openssl enc
-ciphername [-AadePpv ]
[-base64 ]
[-bufsize number]
[-debug ]
[-in file]
[-iter iterations]
[-iv IV]
[-K key]
[-k password]
[-kfile file]
[-md digest]
[-none ] [-nopad ]
[-nosalt ]
[-out file]
[-pass arg]
[-pbkdf2 ]
[-S salt]
[-salt ]
The symmetric cipher commands allow data to be encrypted or
decrypted using various block and stream ciphers using keys based on
passwords or explicitly provided. Base64 encoding or decoding can also be
performed either by itself or in addition to the encryption or decryption.
The program can be called either as openssl
ciphername or openssl enc
- ciphername.
Some of the ciphers do not have large keys and others have
security implications if not used correctly. All the block ciphers normally
use PKCS#5 padding, also known as standard block padding. If padding is
disabled, the input data must be a multiple of the cipher block length.
The options are as follows:
-A
- If the
-a option is set, then base64 process the
data on one line.
-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.
-bufsize
number
- Set the buffer size for I/O.
-d
- Decrypt the input data.
-debug
- Debug the BIOs used for I/O.
-e
- Encrypt the input data. This is the default.
-in
file
- The input file to read from, or standard input if not specified.
-iter
iterations
- Use the pbkdf2 key derivation function, with
iterations as the number of iterations.
-iv
IV
- The actual IV (initialisation vector) to use: this
must be represented as a string comprised only of hex digits. When only
the key is specified using the
-K option, the IV must explicitly be defined. When
a password is being specified using one of the other options, the IV is
generated from this password.
-K
key
- The actual key to use: this must be represented as a
string comprised only of hex digits. If only the key is specified, the IV
must also be specified using the
-iv option. When
both a key and a password are
specified, the key given with the
-K option will be used and the IV generated from
the password will be taken. It probably does not make much sense to
specify both key and
password.
-k
password
- The password to derive the key from. Superseded by
the
-pass option.
-kfile
file
- Read the password to derive the key from the first line of
file. Superseded by the
-pass option.
-md
digest
- Use digest to create a key from a pass phrase.
Currently, the default value is
sha256 .
-none
- Use NULL cipher (no encryption or decryption of input).
-nopad
- Disable standard block padding.
-nosalt
- Don't use a salt in the key derivation routines. This option should never
be used since it makes it possible to perform efficient dictionary attacks
on the password and to attack stream cipher encrypted data.
-out
file
- The output file to write to, or standard output if not specified.
-P
- Print out the salt, key, and IV used, then immediately exit; don't do any
encryption or decryption.
-p
- Print out the salt, key, and IV used.
-pass
arg
- The password source.
-pbkdf2
- Use the pbkdf2 key derivation function, with the default of 10000
iterations.
-S
salt
- The actual salt to use: this must be represented as
a string comprised only of hex digits.
-salt
- Use a salt in the key derivation routines (the default). When the salt is
being used, the first eight bytes of the encrypted data are reserved for
the salt: it is randomly generated when encrypting a file and read from
the encrypted file when it is decrypted.
-v
- Print extra details about the processing.
openssl errstr errno
...
The errstr command performs error number
to error string conversion, generating a human-readable string representing
the error code errno. The string is obtained through
the
ERR_error_string_n(3)
function and has the following format:
error:[error code]:[library
name]:[function name]:[reason string]
[error code] is an 8-digit hexadecimal number. The remaining
fields [library name], [function name], and [reason string] are all ASCII
text.
openssl gendsa
- [
-aes128
| -aes192 | -aes256 | -camellia128 | -camellia192
| -camellia256 | -des | -des3 | -idea ]
[-out file]
[-passout arg] paramfile
The gendsa command generates a DSA private
key from a DSA parameter file (typically generated by the
openssl dsaparam command). DSA key generation is
little more than random number generation so it is much quicker than, for
example, RSA key generation.
The options are as follows:
-aes128
|
-aes192
|
-aes256
|
-camellia128
|
-camellia192
|
-camellia256
|
-des
|
-des3
|
-idea
- Encrypt the private key with the AES, CAMELLIA, DES, triple DES or the
IDEA ciphers, respectively, before outputting it. A pass phrase is
prompted for. If none of these options are specified, no encryption is
used.
-out
file
- The output file to write to, or standard output if not specified.
-passout
arg
- The output file password source.
- paramfile
- Specify the DSA parameter file to use. The parameters in this file
determine the size of the private key.
openssl genpkey
- [
-algorithm alg]
[cipher] [-genparam ]
[-out file]
[-outform der | pem ]
[-paramfile file]
[-pass arg]
[-pkeyopt opt:value]
[-text ]
The genpkey command generates private
keys. The use of this program is encouraged over the algorithm specific
utilities because additional algorithm options can be used.
The options are as follows:
-algorithm
alg
- The public key algorithm to use, such as RSA, DSA, or DH. This option must
precede any
-pkeyopt options. The options
-paramfile and -algorithm
are mutually exclusive.
- cipher
- Encrypt the private key with the supplied cipher. Any algorithm name
accepted by
EVP_get_cipherbyname(3)
is acceptable.
-genparam
- Generate a set of parameters instead of a private key. This option must
precede any
-algorithm ,
-paramfile , or -pkeyopt
options.
-out
file
- The output file to write to, or standard output if not specified.
-outform
der |
pem
- The output format.
-paramfile
file
- Some public key algorithms generate a private key based on a set of
parameters, which can be supplied using this option. If this option is
used, the public key algorithm used is determined by the parameters. This
option must precede any
-pkeyopt options. The
options -paramfile and
-algorithm are mutually exclusive.
-pass
arg
- The output file password source.
-pkeyopt
opt:value
- Set the public key algorithm option opt to
value, as follows:
- rsa_keygen_bits:numbits
- (RSA) The number of bits in the generated key. The default is
2048.
- rsa_keygen_pubexp:value
- (RSA) The RSA public exponent value. This can be a large decimal or
hexadecimal value if preceded by 0x. The default is 65537.
- dsa_paramgen_bits:numbits
- (DSA) The number of bits in the generated parameters. The default is
1024.
- dh_paramgen_prime_len:numbits
- (DH) The number of bits in the prime parameter
p.
- dh_paramgen_generator:value
- (DH) The value to use for the generator g.
- ec_paramgen_curve:curve
- (EC) The elliptic curve to use.
-text
- Print the private/public key in plain text.
openssl genrsa
- [
-3 | -f4 ]
[-aes128
| -aes192 | -aes256 | -camellia128 | -camellia192
| -camellia256 | -des | -des3 | -idea ]
[-out file]
[-passout arg]
[numbits]
The genrsa command generates an RSA
private key, which essentially involves the generation of two prime numbers.
When generating the key, various symbols will be output to indicate the
progress of the generation. A ‘.’ represents each number which
has passed an initial sieve test; ‘+’ means a number has
passed a single round of the Miller-Rabin primality test; ‘*’
means the number has failed primality testing and needs to be generated
afresh. A newline means that the number has passed all the prime tests (the
actual number depends on the key size).
The options are as follows:
-3 |
-f4
- The public exponent to use, either 3 or 65537. The default is 65537.
-aes128
|
-aes192
|
-aes256
|
-camellia128
|
-camellia192
|
-camellia256
|
-des
|
-des3
|
-idea
- Encrypt the private key with the AES, CAMELLIA, DES, triple DES or the
IDEA 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
-passout option.
-out
file
- The output file to write to, or standard output if not specified.
-passout
arg
- The output file password source.
- numbits
- The size of the private key to generate in bits. This must be the last
option specified. The default is 2048.
openssl ocsp
- [
-CA file]
[-CAfile file]
[-CApath directory]
[-cert file]
[-dgst alg]
[-header name value]
[-host hostname:port]
[-ignore_err ]
[-index indexfile]
[-issuer file]
[-ndays days]
[-nmin minutes]
[-no_cert_checks ]
[-no_cert_verify ]
[-no_certs ] [-no_chain ]
[-no_explicit ]
[-no_intern ] [-no_nonce ]
[-no_signature_verify ]
[-nonce ] [-noverify ]
[-nrequest number]
[-out file]
[-path path]
[-port portnum]
[-req_text ]
[-reqin file]
[-reqout file]
[-resp_key_id ]
[-resp_no_certs ]
[-resp_text ]
[-respin file]
[-respout file]
[-rkey file]
[-rother file]
[-rsigner file]
[-serial num]
[-sign_other file]
[-signer file]
[-signkey file]
[-status_age age]
[-text ]
[-timeout seconds]
[-trust_other ]
[-url responder_url]
[-VAfile file]
[-validity_period nsec]
[-verify_other file]
The Online Certificate Status Protocol (OCSP) enables applications
to determine the (revocation) state of an identified certificate (RFC
2560).
The 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.
The options are as follows:
-CAfile
file, -CApath
directory
- A file or path containing trusted CA certificates, used to verify the
signature on the OCSP response.
-cert
file
- Add the certificate file to the request. The issuer
certificate is taken from the previous
-issuer
option, or an error occurs if no issuer certificate is specified.
-dgst alg
- Use the digest algorithm alg for certificate
identification in the OCSP request. By default SHA1 is used.
-host
hostname:port,
-path path
- Send the OCSP request to hostname on
port.
-path specifies the
HTTP path name to use, or / by default.
- Add the header name with the specified value to the OCSP request that is
sent to the responder. This may be repeated.
-issuer
file
- The current issuer certificate, in PEM format. Can be used multiple times
and must come before any
-cert options.
-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.
-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.
-no_certs
- Don't include any certificates in the signed request.
-no_chain
- Do not use certificates in the response as additional untrusted CA
certificates.
-no_explicit
- Don't check the explicit trust for OCSP signing in the root CA
certificate.
-no_intern
- Ignore certificates contained in the OCSP response when searching for the
signer's certificate. The signer's certificate must be specified with
either the
-verify_other or
-VAfile options.
-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.
-nonce ,
-no_nonce
- Add an OCSP nonce extension to a request, or disable an OCSP nonce
addition. Normally, if an OCSP request is input using the
-respin option no nonce is added: using the
-nonce option will force the addition of a nonce.
If an OCSP request is being created (using the
-cert and -serial
options), a nonce is automatically added; specifying
-no_nonce overrides this.
-noverify
- Don't attempt to verify the OCSP response signature or the nonce values.
This is normally only be used for debugging since it disables all
verification of the responder's certificate.
-out
file
- Specify the output file to write to, or standard output if not
specified.
-req_text ,
-resp_text , -text
- Print out the text form of the OCSP request, response, or both,
respectively.
-reqin
file, -respin
file
- Read an OCSP request or response file from file.
These options are ignored if an OCSP request or response creation is
implied by other options (for example with the
-serial , -cert , and
-host options).
-reqout
file, -respout
file
- Write out the DER-encoded certificate request or response to
file.
-serial
num
- Same as the
-cert option except the certificate
with serial number num is added to the request. The
serial number is interpreted as a decimal integer unless preceded by
‘0x’. Negative integers can also be specified by preceding
the value with a minus sign.
-sign_other
file
- Additional certificates to include in the signed request.
-signer
file, -signkey
file
- Sign the OCSP request using the certificate specified in the
-signer option and the private key specified by
the -signkey option. If the
-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.
-timeout
seconds
- Connection timeout to the OCSP responder in seconds.
-trust_other
- The certificates specified by the
-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.
-url
responder_url
- Specify the responder URL. Both HTTP and HTTPS (SSL/TLS) URLs can be
specified.
-VAfile
file
- A file containing explicitly trusted responder certificates. Equivalent to
the
-verify_other and
-trust_other options.
-validity_period
nsec, -status_age
age
- The range of times, in seconds, which will be tolerated in an OCSP
response. Each certificate status response includes a notBefore time and
an optional notAfter time. The current time should fall between these two
values, but the interval between the two times may be only a few seconds.
In practice the OCSP responder and clients' clocks may not be precisely
synchronised and so such a check may fail. To avoid this the
-validity_period option can be used to specify an
acceptable error range in seconds, the default value being 5 minutes.
If the notAfter time is omitted from a response, it means that
new status information is immediately available. In this case the age of
the notBefore field is checked to see it is not older than
age seconds old. By default, this additional check
is not performed.
-verify_other
file
- A file containing additional certificates to search when attempting to
locate the OCSP response signing certificate. Some responders omit the
actual signer's certificate from the response, so this can be used to
supply the necessary certificate.
The options for the OCSP server are as follows:
-CA
file
- CA certificate corresponding to the revocation information in
indexfile.
-ignore_err
- Ignore the invalid response.
-index
indexfile
- indexfile is a text index file in ca format
containing certificate revocation information.
If this option is specified, ocsp is
in responder mode, otherwise it is in client mode. The requests the
responder processes can be either specified on the command line (using
the -issuer and -serial
options), supplied in a file (using the -respin
option), or via external OCSP clients (if port or
url is specified).
If this option is present, then the
-CA and -rsigner options
must also be present.
-nmin
minutes, -ndays
days
- Number of minutes or days when
fresh revocation information is available: used in the nextUpdate field.
If neither option is present, the nextUpdate field is omitted, meaning
fresh revocation information is immediately available.
-nrequest
number
- Exit after receiving number requests (the default is
unlimited).
-port
portnum
- Port to listen for OCSP requests on. May also be specified using the
-url option.
-resp_key_id
- Identify the signer certificate using the key ID; the default is to use
the subject name.
-resp_no_certs
- Don't include any certificates in the OCSP response.
-rkey
file
- The private key to sign OCSP responses with; if not present, the file
specified in the
-rsigner option is used.
-rother
file
- Additional certificates to include in the OCSP response.
-rsigner
file
- The certificate to sign OCSP responses with.
Initially the OCSP responder certificate is located and the
signature on the OCSP request checked using the responder certificate's
public key. Then a normal certificate verify is performed on the OCSP
responder certificate building up a certificate chain in the process. The
locations of the trusted certificates used to build the chain can be
specified by the -CAfile and
-CApath options or they will be looked for in the
standard openssl certificates directory.
If the initial verify fails, the OCSP verify process halts with an
error. Otherwise the issuing CA certificate in the request is compared to
the OCSP responder certificate: if there is a match then the OCSP verify
succeeds.
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.
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.
If none of these checks is successful, the OCSP verify fails. What
this effectively means is that if the OCSP responder certificate is
authorised directly by the CA it is issuing revocation information about
(and it is correctly configured), then verification will succeed.
If the OCSP responder is a global responder, which can give
details about multiple CAs and has its own separate certificate chain, then
its root CA can be trusted for OCSP signing. Alternatively, the responder
certificate itself can be explicitly trusted with the
-VAfile option.
openssl passwd
- [
-1
| -apr1 | -crypt ]
[-in file]
[-noverify ] [-quiet ]
[-reverse ]
[-salt string]
[-stdin ] [-table ]
[password]
The passwd command computes the hash of a
password.
The options are as follows:
-1
- Use the MD5 based BSD password algorithm
"1".
-apr1
- Use the "apr1" algorithm (Apache variant of the
BSD algorithm).
-crypt
- Use the "crypt" algorithm (the default).
-in
file
- Read passwords from file.
-noverify
- Don't verify when reading a password from the terminal.
-quiet
- Don't output warnings when passwords given on the command line are
truncated.
-reverse
- Switch table columns. This only makes sense in conjunction with the
-table option.
-salt
string
- Use the salt specified by string. When reading a
password from the terminal, this implies
-noverify .
-stdin
- Read passwords from standard input.
-table
- In the output list, prepend the cleartext password and a TAB character to
each password hash.
openssl pkcs7
- [
-in file]
[-inform der | pem ]
[-noout ]
[-out file]
[-outform der | pem ]
[-print ] [-print_certs ]
[-text ]
The pkcs7 command processes PKCS#7 files
in DER or PEM format. The PKCS#7 routines only understand PKCS#7 v 1.5 as
specified in RFC 2315.
The options are as follows:
-in
file
- The input file to read from, or standard input if not specified.
-inform
der |
pem
- The input format.
-noout
- Don't output the encoded version of the PKCS#7 structure (or certificates
if
-print_certs is set).
-out
file
- The output to write to, or standard output if not specified.
-outform
der |
pem
- The output format.
-print
- Print the ASN.1 representation of PKCS#7 structure.
-print_certs
- Print any certificates or CRLs contained in the file, preceded by their
subject and issuer names in a one-line format.
-text
- Print certificate details in full rather than just subject and issuer
names.
openssl pkcs8
- [
-in file]
[-inform der | pem ]
[-nocrypt ] [-noiter ]
[-out file]
[-outform der | pem ]
[-passin arg]
[-passout arg]
[-topk8 ]
[-v1 alg]
[-v2 alg]
The pkcs8 command processes private keys
(both encrypted and unencrypted) in PKCS#8 format with a variety of PKCS#5
(v1.5 and v2.0) and PKCS#12 algorithms. The default encryption is only 56
bits; keys encrypted using PKCS#5 v2.0 algorithms and high iteration counts
are more secure.
The options are as follows:
-in
file
- The input file to read from, or standard input if not specified. If the
key is encrypted, a pass phrase will be prompted for.
-inform
der |
pem
- The input format.
-nocrypt
- Generate an unencrypted PrivateKeyInfo structure. This option does not
encrypt private keys at all and should only be used when absolutely
necessary.
-noiter
- Use an iteration count of 1. See the
PKCS12 section below for a detailed
explanation of this option.
-out
file
- The output file to write to, or standard output if none is specified. If
any encryption options are set, a pass phrase will be prompted for.
-outform
der |
pem
- The output format.
-passin
arg
- The key password source.
-passout
arg
- The output file password source.
-topk8
- Read a traditional format private key and write a PKCS#8 format key.
-v1
alg
- Specify a PKCS#5 v1.5 or PKCS#12 algorithm to use.
- PBE-MD5-DES
- 56-bit DES.
- PBE-SHA1-RC2-64 | PBE-MD5-RC2-64 | PBE-SHA1-DES
- 64-bit RC2 or 56-bit DES.
- PBE-SHA1-RC4-128 | PBE-SHA1-RC4-40 | PBE-SHA1-3DES
-
- PBE-SHA1-2DES | PBE-SHA1-RC2-128 | PBE-SHA1-RC2-40
- PKCS#12 password-based encryption algorithm, which allow strong
encryption algorithms like triple DES or 128-bit RC2.
-v2
alg
- Use PKCS#5 v2.0 algorithms. Supports algorithms such as 168-bit triple DES
or 128-bit RC2, however not many implementations support PKCS#5 v2.0 yet
(if using private keys with
openssl this doesn't
matter).
alg is the encryption algorithm to use;
valid values include des, des3, and rc2. It is recommended that des3 is
used.
openssl pkcs12
- [
-aes128
| -aes192 | -aes256 | -camellia128 | -camellia192
| -camellia256 | -des | -des3 | -idea ]
[-cacerts ]
[-CAfile file]
[-caname name]
[-CApath directory]
[-certfile file]
[-certpbe alg]
[-chain ] [-clcerts ]
[-descert ] [-export ]
[-in file]
[-info ]
[-inkey file]
[-keyex ]
[-keypbe alg]
[-keysig ]
[-macalg alg]
[-maciter ]
[-name name]
[-nocerts ] [-nodes ]
[-noiter ] [-nokeys ]
[-nomac ] [-nomaciter ]
[-nomacver ] [-noout ]
[-out file]
[-passin arg]
[-passout arg]
[-password arg]
[-twopass ]
The pkcs12 command allows PKCS#12 files
(sometimes referred to as PFX files) to be created and parsed. By default, a
PKCS#12 file is parsed; a PKCS#12 file can be created by using the
-export option.
The options for parsing a PKCS12 file are as follows:
-aes128
|
-aes192
|
-aes256
|
-camellia128
|
-camellia192
|
-camellia256
|
-des
|
-des3
|
-idea
- Encrypt private keys using AES, CAMELLIA, DES, triple DES or the IDEA
ciphers, respectively. The default is triple DES.
-cacerts
- Only output CA certificates (not client certificates).
-clcerts
- Only output client certificates (not CA certificates).
-in
file
- The input file to read from, or standard input if not specified.
-info
- Output additional information about the PKCS#12 file structure, algorithms
used, and iteration counts.
-nocerts
- Do not output certificates.
-nodes
- Do not encrypt private keys.
-nokeys
- Do not output private keys.
-nomacver
- Do not attempt to verify the integrity MAC before reading the file.
-noout
- Do not output the keys and certificates to the output file version of the
PKCS#12 file.
-out
file
- The output file to write to, or standard output if not specified.
-passin
arg
- The key password source.
-passout
arg
- The output file password source.
-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.
The options for PKCS12 file creation are as follows:
-CAfile
file
- CA storage as a file.
-CApath
directory
- CA storage as a directory. The directory must be a standard certificate
directory: that is, a hash of each subject name (using
x509 -hash ) should be
linked to each certificate.
-caname
name
- Specify the "friendly name" for other certificates. May be used
multiple times to specify names for all certificates in the order they
appear.
-certfile
file
- A file to read additional certificates from.
-certpbe
alg, -keypbe
alg
- Specify the algorithm used to encrypt the private key and certificates to
be selected. Any PKCS#5 v1.5 or PKCS#12 PBE algorithm name can be used. If
a cipher name (as output by the
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.
-chain
- Include the entire certificate chain of the user certificate. The standard
CA store is used for this search. If the search fails, it is considered a
fatal error.
-descert
- Encrypt the certificate using triple DES; this may render the PKCS#12 file
unreadable by some "export grade" software. By default, the
private key is encrypted using triple DES and the certificate using 40-bit
RC2.
-export
- Create a PKCS#12 file (rather than parsing one).
-in
file
- The input file to read from, or standard input if not specified. 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.
-inkey
file
- File to read a private key from. If not present, a private key must be
present in the input file.
-keyex
|
-keysig
- Specify whether the private key is to be used for key exchange or just
signing. Normally, "export grade" software will only allow
512-bit RSA keys to be used for encryption purposes, but arbitrary length
keys for signing. The
-keysig option marks the key
for signing only. Signing only keys can be used for S/MIME signing,
authenticode (ActiveX control signing) and SSL client authentication.
-macalg
alg
- Specify the MAC digest algorithm. The default is SHA1.
-maciter
- Included for compatibility only: it used to be needed to use MAC
iterations counts but they are now used by default.
-name
name
- Specify the "friendly name" for the certificate and private key.
This name is typically displayed in list boxes by software importing the
file.
-nomac
- Don't attempt to provide the MAC integrity.
-nomaciter ,
-noiter
- Affect the iteration counts on the MAC and key algorithms.
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.
-out
file
- The output file to write to, or standard output if not specified.
-passin
arg
- The key password source.
-passout
arg
- The output file password source.
-password
arg
- With
-export , -password is
equivalent to -passout . Otherwise,
-password is equivalent to
-passin .
openssl pkey
- [cipher]
[
-in file]
[-inform der | pem ]
[-noout ]
[-out file]
[-outform der | pem ]
[-passin arg]
[-passout arg]
[-pubin ] [-pubout ]
[-text ] [-text_pub ]
The pkey command processes public or
private keys. They can be converted between various forms and their
components printed out.
The options are as follows:
- cipher
- Encrypt the private key with the specified cipher. Any algorithm name
accepted by
EVP_get_cipherbyname(3)
is acceptable, such as
des3 .
-in
file
- The input file to read from, or standard input if not specified. If the
key is encrypted, a pass phrase will be prompted for.
-inform
der |
pem
- The input format.
-noout
- Do not output the encoded version of the key.
-out
file
- The output file to write to, or standard output if not specified. If any
encryption options are set then a pass phrase will be prompted for.
-outform
der |
pem
- The output format.
-passin
arg
- The key password source.
-passout
arg
- The output file password source.
-pubin
- Read in a public key, not a private key.
-pubout
- Output a public key, not a private key. Automatically set if the input is
a public key.
-text
- Print the public/private key in plain text.
-text_pub
- Print out only public key components even if a private key is being
processed.
openssl pkeyparam
[-in file]
[-noout ] [-out
file] [-text ]
The pkeyparam command processes public or
private keys. The key type is determined by the PEM headers.
The options are as follows:
-in
file
- The input file to read from, or standard input if not specified.
-noout
- Do not output the encoded version of the parameters.
-out
file
- The output file to write to, or standard output if not specified.
-text
- Print the parameters in plain text.
openssl pkeyutl
- [
-asn1parse ] [-certin ]
[-decrypt ] [-derive ]
[-encrypt ] [-hexdump ]
[-in file]
[-inkey file]
[-keyform der | pem ]
[-out file]
[-passin arg]
[-peerform der | pem ]
[-peerkey file]
[-pkeyopt opt:value]
[-pubin ] [-rev ]
[-sigfile file]
[-sign ] [-verify ]
[-verifyrecover ]
The pkeyutl command can be used to perform
public key operations using any supported algorithm.
The options are as follows:
-asn1parse
- ASN.1 parse the output data. This is useful when combined with the
-verifyrecover option when an ASN.1 structure is
signed.
-certin
- The input is a certificate containing a public key.
-decrypt
- Decrypt the input data using a private key.
-derive
- Derive a shared secret using the peer key.
-encrypt
- Encrypt the input data using a public key.
-hexdump
- Hex dump the output data.
-in
file
- The input file to read from, or standard input if not specified.
-inkey
file
- The input key file. By default it should be a private key.
-keyform
der |
pem
- The key format.
-out
file
- The output file to write to, or standard output if not specified.
-passin
arg
- The key password source.
-peerform
der |
pem
- The peer key format.
-peerkey
file
- The peer key file, used by key derivation (agreement) operations.
-pkeyopt
opt:value
- Set the public key algorithm option opt to
value. Unless otherwise mentioned, all algorithms
support the format digest:alg,
which specifies the digest to use for sign, verify, and verifyrecover
operations. The value alg should represent a digest
name as used in the
EVP_get_digestbyname(3)
function.
The RSA algorithm supports the encrypt, decrypt, sign, verify,
and verifyrecover operations in general. Some padding modes only support
some of these operations however.
- rsa_padding_mode:mode
- This sets the RSA padding mode. Acceptable values for
mode are
pkcs1 for
PKCS#1 padding; none for no padding;
oaep for OAEP mode;
x931 for X9.31 mode; and
pss for PSS.
In PKCS#1 padding if the message digest is not set then
the supplied data is signed or verified directly instead of using a
DigestInfo structure. If a digest is set then a DigestInfo structure
is used and its length must correspond to the digest type. For oeap
mode only encryption and decryption is supported. For x931 if the
digest type is set it is used to format the block data; otherwise
the first byte is used to specify the X9.31 digest ID. Sign, verify,
and verifyrecover can be performed in this mode. For pss mode only
sign and verify are supported and the digest type must be
specified.
- rsa_pss_saltlen: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.
The DSA algorithm supports the sign and verify operations.
Currently there are no additional options other than
digest. Only the SHA1 digest can be used and this
digest is assumed by default.
The DH algorithm supports the derive operation and no
additional options.
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
digest. Only the SHA1 digest can be used and this
digest is assumed by default.
-pubin
- The input file is a public key.
-rev
- Reverse the order of the input buffer.
-sigfile
file
- Signature file (verify operation only).
-sign
- Sign the input data and output the signed result. This requires a private
key.
-verify
- Verify the input data against the signature file and indicate if the
verification succeeded or failed.
-verifyrecover
- Verify the input data and output the recovered data.
openssl prime
[-bits n]
[-checks n]
[-generate ] [-hex ]
[-safe ] p
The 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.
The options are as follows:
-bits
n
- Specify the number of bits in the generated prime number. Must be used in
conjunction with
-generate .
-checks
n
- Perform a Miller-Rabin probabilistic primality test with
n iterations. The default is 20.
-generate
- Generate a pseudo-random prime number. Must be used in conjunction with
-bits .
-hex
- Output in hex format.
-safe
- Generate only "safe" prime numbers (i.e. a prime p so that
(p-1)/2 is also prime).
- p
- Test if number p is prime.
openssl rand
- [
-base64 ] [-hex ]
[-out file] num
The rand command outputs
num pseudo-random bytes.
The options are as follows:
-base64
- Perform base64 encoding on the output.
-hex
- Specify hexadecimal output.
-out
file
- The output file to write to, or standard output if not specified.
openssl req
- [
-addext ext]
[-batch ]
[-config file]
[-days n]
[-extensions section]
[-in file]
[-inform der | pem ]
[-key keyfile]
[-keyform der | pem ]
[-keyout file]
[-md4 | -md5 | -sha1 ]
[-modulus ]
[-multivalue-rdn ]
[-nameopt option]
[-new ] [-newhdr ]
[-newkey arg]
[-nodes ] [-noout ]
[-out file]
[-outform der | pem ]
[-passin arg]
[-passout arg]
[-pkeyopt opt:value]
[-pubkey ]
[-reqexts section]
[-reqopt option]
[-set_serial n]
[-sigopt nm:v]
[-subj arg]
[-subject ] [-text ]
[-utf8 ] [-verbose ]
[-verify ] [-x509 ]
The 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.
The options are as follows:
-addext
ext
- Add a specific extension to the certificate (if the
-x509 option is present) or certificate request.
The argument must have the form of a key=value pair as it would appear in
a config file. This option can be given multiple times.
-batch
- Non-interactive mode.
-config
file
- Specify an alternative configuration file.
-days
n
- Specify the number of days to certify the certificate for. The default is
30 days. Used with the
-x509 option.
-extensions
section, -reqexts
section
- Specify alternative sections to include certificate extensions (with
-x509 ) or certificate request extensions, allowing
several different sections to be used in the same configuration file.
-in
file
- The input file to read a request from, or standard input if not specified.
A request is only read if the creation options
-new and -newkey are not
specified.
-inform
der |
pem
- The input format.
-key
keyfile
- The file to read the private key from. It also accepts PKCS#8 format
private keys for PEM format files.
-keyform
der |
pem
- The format of the private key file specified in the
-key argument. The default is
pem .
-keyout
file
- The file to write the newly created private key to. If this option is not
specified, the filename present in the configuration file is used.
-md5
|
-sha1
|
-sha256
- The message digest to sign the request with. This overrides the digest
algorithm specified in the configuration file.
Some public key algorithms may override this choice. For
instance, DSA signatures always use SHA1.
-modulus
- Print the value of the modulus of the public key contained in the
request.
-multivalue-rdn
- This option causes the
-subj argument to be
interpreted with full support for multivalued RDNs, for example
"/DC=org/DC=OpenSSL/DC=users/UID=123456+CN=John Doe". If
-multivalue-rdn is not used, the UID value is set
to "123456+CN=John Doe".
-nameopt
option, -reqopt
option
- Determine how the subject or issuer names are displayed.
option can be a single option or multiple options
separated by commas. Alternatively, these options may be used more than
once to set multiple options. See the X509
section below for details.
-new
- Generate a new certificate request. The user is prompted for the relevant
field values. The actual fields prompted for and their maximum and minimum
sizes are specified in the configuration file and any requested
extensions.
If the -key option is not used, it
will generate a new RSA private key using information specified in the
configuration file.
-newhdr
- Add the word NEW to the PEM file header and footer lines on the outputted
request. Some software and CAs need this.
-newkey
arg
- Create a new certificate request and a new private key. The argument takes
one of several forms.
rsa:nbits
generates an RSA key nbits in size. If
nbits is omitted, the default key size is
used.
dsa:file
generates a DSA key using the parameters in
file.
param:file
generates a key using the parameters or certificate in
file.
All other algorithms support the form
algorithm:file, where file
may be an algorithm parameter file, created by the
genpkey -genparam command or an X.509
certificate for a key with appropriate algorithm.
file can be omitted, in which case any parameters
can be specified via the -pkeyopt option.
-nodes
- Do not encrypt the private key.
-noout
- Do not output the encoded version of the request.
-out
file
- The output file to write to, or standard output if not specified.
-outform
der |
pem
- The output format.
-passin
arg
- The key password source.
-passout
arg
- The output file password source.
-pkeyopt
opt:value
- Set the public key algorithm option opt to
value.
-pubkey
- Output the public key.
-reqopt
option
- Customise the output format used with
-text . The
option argument can be a single option or multiple
options separated by commas. See also the discussion of
-certopt in the x509
command.
-set_serial
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
‘0x’. It is possible to use negative serial numbers but this
is not recommended.
-sigopt
nm:v
- Pass options to the signature algorithm during sign operation. The names
and values of these options are algorithm-specific.
-subj
arg
- Replaces the subject field of an input request with the specified data and
output the modified request. arg must be formatted
as /type0=value0/type1=value1/type2=...; characters may be escaped by
‘\’ (backslash); no spaces are skipped.
-subject
- Print the request subject (or certificate subject if
-x509 is specified).
-text
- Print the certificate request in plain text.
-utf8
- Interpret field values as UTF8 strings, not ASCII.
-verbose
- Print extra details about the operations being performed.
-verify
- Verify the signature on the request.
-x509
- Output a self-signed certificate instead of a certificate request. This is
typically used to generate a test certificate or a self-signed root CA.
The extensions added to the certificate (if any) are specified in the
configuration file. Unless specified using the
-set_serial option, 0 is used for the serial
number.
The configuration options are specified in the "req"
section of the configuration file. The options available are as follows:
attributes
- The section containing any request attributes: its format is the same as
distinguished_name . Typically these may contain
the challengePassword or unstructuredName types. They are currently
ignored by the openssl request signing utilities,
but some CAs might want them.
default_bits
- The default key size, in bits. The default is 2048. It is used if the
-new option is used and can be overridden by using
the -newkey option.
default_keyfile
- The default file to write a private key to, or standard output if not
specified. It can be overridden by the
-keyout
option.
default_md
- The digest algorithm to use. Possible values include
md5 , sha1 and
sha256 (the default). It can be overridden on the
command line.
distinguished_name
- The section containing the distinguished name fields to prompt for when
generating a certificate or certificate request. The format is described
below.
encrypt_key
- If set to "no" and a private key is generated, it is not
encrypted. It is equivalent to the
-nodes option.
For compatibility, encrypt_rsa_key is an
equivalent option.
input_password
|
output_password
- The passwords for the input private key file (if present) and the output
private key file (if one will be created). The command line options
-passin and -passout
override the configuration file values.
oid_file
- A file containing additional OBJECT IDENTIFIERS. Each line of the file
should consist of the numerical form of the object identifier, followed by
whitespace, then the short name followed by whitespace and finally the
long name.
oid_section
- Specify a section in the configuration file containing extra object
identifiers. Each line should consist of the short name of the object
identifier followed by ‘=’ and the numerical form. The short
and long names are the same when this option is used.
prompt
- If set to "no", it disables prompting of certificate fields and
just takes values from the config file directly. It also changes the
expected format of the
distinguished_name and
attributes sections.
req_extensions
- The configuration file section containing a list of extensions to add to
the certificate request. It can be overridden by the
-reqexts option.
string_mask
- Limit the string types for encoding certain fields. The following values
may be used, limiting strings to the indicated types:
utf8only
- UTF8String. This is the default, as recommended by PKIX in RFC
2459.
default
- PrintableString, IA5String, T61String, BMPString, UTF8String.
pkix
- PrintableString, IA5String, BMPString, UTF8String. Inspired by the
PKIX recommendation in RFC 2459 for certificates generated before
2004, but differs by also permitting IA5String.
nombstr
- PrintableString, IA5String, T61String, UniversalString. A workaround
for some ancient software that had problems with the variable-sized
BMPString and UTF8String types.
MASK :number
- An explicit bitmask of permitted types, where
number is a C-style hex, decimal, or octal
number that's a bit-wise OR of
B_ASN1_* values
from
<openssl/asn1.h> .
utf8
- If set to "yes", field values are interpreted as UTF8
strings.
x509_extensions
- The configuration file section containing a list of extensions to add to a
certificate generated when the
-x509 switch is
used. It can be overridden by the -extensions
command line switch.
There are two separate formats for the distinguished name and
attribute sections. If the -prompt option is set to
"no", then these sections just consist of field names and values.
If the -prompt option is absent or not set to
"no", then the file contains field prompting information of the
form:
fieldName="prompt"
fieldName_default="default field value"
fieldName_min= 2
fieldName_max= 4
"fieldName" is the field name being used, for example
commonName (or CN). The "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 ‘.’ character.
The number of characters entered must be between the fieldName_min
and fieldName_max limits: there may be additional restrictions based on the
field being used (for example countryName can only
ever be two characters long and must fit in a
PrintableString ).
Some fields (such as 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 fieldName contains some
characters followed by a full stop, they will be ignored. So, for example, a
second organizationName can be input by calling it
"1.organizationName".
The actual permitted field names are any object identifier short
or long names. These are compiled into openssl and
include the usual values such as commonName ,
countryName , localityName ,
organizationName ,
organizationalUnitName ,
stateOrProvinceName . Additionally,
emailAddress is included as well as
name , surname ,
givenName , initials and
dnQualifier .
Additional object identifiers can be defined with the
oid_file or oid_section
options in the configuration file. Any additional fields will be treated as
though they were a DirectoryString .
openssl rsa
- [
-aes128
| -aes192 | -aes256 | -des | -des3 ]
[-check ]
[-in file]
[-inform der | net | pem | pvk ]
[-modulus ] [-noout ]
[-out file]
[-outform der | net | pem | pvk ]
[-passin arg]
[-passout arg]
[-pubin ] [-pubout ]
[-pvk-none | -pvk-strong | -pvk-weak ]
[-RSAPublicKey_in ]
[-RSAPublicKey_out ]
[-text ]
The rsa command processes RSA keys. They
can be converted between various forms and their components printed out.
rsa uses the traditional
SSLeay compatible format for private key encryption:
newer applications should use the more secure PKCS#8 format using the
pkcs8 utility.
The options are as follows:
-aes128
|
-aes192
|
-aes256
|
-des
|
-des3
- Encrypt the private key with the AES, DES, or the triple DES ciphers,
respectively, before outputting it. A pass phrase is prompted for. If none
of these options are specified, the key is written in plain text. This
means that using the
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.
-check
- Check the consistency of an RSA private key.
-in
file
- The input file to read from, or standard input if not specified. If the
key is encrypted, a pass phrase will be prompted for.
-inform
der |
net |
pem
|
pvk
- The input format.
-noout
- Do not output the encoded version of the key.
-modulus
- Print the value of the modulus of the key.
-out
file
- The output file to write to, or standard output if not specified.
-outform
der |
net
|
pem
|
pvk
- The output format.
-passin
arg
- The key password source.
-passout
arg
- The output file password source.
-pubin
- Read in a public key, not a private key.
-pubout
- Output a public key, not a private key. Automatically set if the input is
a public key.
-pvk-none
|
-pvk-strong
|
-pvk-weak
- Enable or disable PVK encoding. The default is
-pvk-strong .
-RSAPublicKey_in ,
-RSAPublicKey_out
- Same as
-pubin and -pubout
except RSAPublicKey format is used instead.
-text
- Print the public/private key components in plain text.
openssl rsautl
- [
-asn1parse ] [-certin ]
[-decrypt ] [-encrypt ]
[-hexdump ]
[-in file]
[-inkey file]
[-keyform der | pem ]
[-oaep | -pkcs | -raw | -x931 ]
[-out file]
[-passin arg]
[-pubin ] [-rev ]
[-sign ] [-verify ]
The rsautl command can be used to sign,
verify, encrypt and decrypt data using the RSA algorithm.
The options are as follows:
-asn1parse
- Asn1parse the output data; this is useful when combined with the
-verify option.
-certin
- The input is a certificate containing an RSA public key.
-decrypt
- Decrypt the input data using an RSA private key.
-encrypt
- Encrypt the input data using an RSA public key.
-hexdump
- Hex dump the output data.
-in
file
- The input to read from, or standard input if not specified.
-inkey
file
- The input key file; by default an RSA private key.
-keyform
der |
pem
- The private key format. The default is
pem .
-oaep
|
-pkcs
| -raw
|
-x931
- The padding to use: PKCS#1 OAEP, PKCS#1 v1.5 (the default), no padding, or
ANSI X9.31, respectively. For signatures, only
-pkcs and -raw can be
used.
-out
file
- The output file to write to, or standard output if not specified.
-passin
arg
- The key password source.
-pubin
- The input file is an RSA public key.
-rev
- Reverse the order of the input buffer.
-sign
- Sign the input data and output the signed result. This requires an RSA
private key.
-verify
- Verify the input data and output the recovered data.
openssl s_client
- [
-4 | -6 ]
[-alpn protocols]
[-bugs ]
[-CAfile file]
[-CApath directory]
[-cert file]
[-certform der | pem ]
[-check_ss_sig ]
[-cipher cipherlist]
[-connect host[:port]]
[-crl_check ]
[-crl_check_all ] [-crlf ]
[-debug ] [-dtls ]
[-dtls1_2 ] [-extended_crl ]
[-groups list]
[-host host]
[-ign_eof ]
[-ignore_critical ]
[-issuer_checks ]
[-key keyfile]
[-keyform der | pem ]
[-keymatexport label]
[-keymatexportlen len]
[-legacy_server_connect ]
[-msg ]
[-mtu mtu]
[-nbio ] [-nbio_test ]
[-no_comp ] [-no_ign_eof ]
[-no_legacy_server_connect ]
[-no_ticket ] [-no_tls1_2 ]
[-no_tls1_3 ]
[-pass arg]
[-policy_check ]
[-port port]
[-prexit ]
[-proxy host:port]
[-quiet ] [-reconnect ]
[-servername name]
[-serverpref ]
[-sess_in file]
[-sess_out file]
[-showcerts ]
[-starttls protocol]
[-state ] [-status ]
[-timeout ] [-tls1_2 ]
[-tls1_3 ] [-tlsextdebug ]
[-use_srtp profiles]
[-verify depth]
[-verify_return_error ]
[-x509_strict ]
[-xmpphost host]
The s_client command implements a generic
SSL/TLS client which connects to a remote host using SSL/TLS.
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
-quiet nor -ign_eof have
been given), the session will be renegotiated if the line begins with an
R ; if the line begins with a
Q or if end of file is reached, the connection will
be closed down.
The options are as follows:
-4
- Attempt connections using IPv4 only.
-6
- Attempt connections using IPv6 only.
-alpn
protocols
- Enable the Application-Layer Protocol Negotiation.
protocols is a comma-separated list of protocol
names that the client should advertise support for.
-bugs
- Enable various workarounds for buggy implementations.
-CAfile
file
- A file containing trusted certificates to use during
server authentication and to use when attempting to build the client
certificate chain.
-CApath
directory
- The directory to use for server certificate
verification. This directory must be in "hash format"; see
-verify for more information. These are also used
when building the client certificate chain.
-cert
file
- The certificate to use, if one is requested by the server. The default is
not to use a certificate.
-certform
der |
pem
- The certificate format. The default is
pem .
-check_ss_sig ,
-crl_check , -crl_check_all ,
-extended_crl ,
-ignore_critical ,
-issuer_checks ,
-policy_check ,
-x509_strict
- Set various certificate chain validation options. See the
verify command for details.
-cipher
cipherlist
- Modify the cipher list sent by the client. Although the server determines
which cipher suite is used, it should take the first supported cipher in
the list sent by the client. See the
ciphers
command for more information.
-connect
host[:port]
- The host and port to connect
to. If not specified, an attempt is made to connect to the local host on
port 4433. Alternatively, the host and port pair may be separated using a
forward-slash character, which is useful for numeric IPv6 addresses.
-crlf
- Translate a line feed from the terminal into CR+LF, as required by some
servers.
-debug
- Print extensive debugging information, including a hex dump of all
traffic.
-dtls
- Permit any version of DTLS.
-dtls1_2
- Permit only DTLS1.2.
-groups
list
- Set the supported elliptic curve groups to the colon separated
list of group NIDs or names as documented in
SSL_CTX_set1_groups_list(3).
-host
host
- The host to connect to. The default is
localhost.
-ign_eof
- Inhibit shutting down the connection when end of file is reached in the
input.
-key
keyfile
- The private key to use. If not specified, the certificate file will be
used.
-keyform
der |
pem
- The private key format. The default is
pem .
-keymatexport
label
- Export keying material using label.
-keymatexportlen
len
- Export len bytes of keying material (default 20).
-legacy_server_connect ,
-no_legacy_server_connect
- Allow or disallow initial connection to servers that don't support
RI.
-msg
- Show all protocol messages with hex dump.
-mtu
mtu
- Set the link layer MTU.
-nbio
- Turn on non-blocking I/O.
-nbio_test
- Test non-blocking I/O.
-no_ign_eof
- Shut down the connection when end of file is reached in the input. Can be
used to override the implicit
-ign_eof after
-quiet .
-no_tls1_2
|
-no_tls1_3
- Disable the use of TLS1.2 and 1.3, respectively.
-no_ticket
- Disable RFC 4507 session ticket support.
-pass
arg
- The private key password source.
-port
port
- The port to connect to. The default is 4433.
-prexit
- Print session information when the program exits. This will always attempt
to print out information even if the connection fails. Normally,
information will only be printed out once if the connection succeeds. This
option is useful because the cipher in use may be renegotiated or the
connection may fail because a client certificate is required or is
requested only after an attempt is made to access a certain URL. Note that
the output produced by this option is not always accurate because a
connection might never have been established.
-proxy
host:port
- Use the HTTP proxy at host and
port. The connection to the proxy is done in
cleartext and the
-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.
-quiet
- Inhibit printing of session and certificate information. This implicitly
turns on
-ign_eof as well.
-reconnect
- Reconnect to the same server 5 times using the same session ID; this can
be used as a test that session caching is working.
-servername
name
- Include the TLS Server Name Indication (SNI) extension in the ClientHello
message, using the specified server name.
-showcerts
- Display the whole server certificate chain: normally only the server
certificate itself is displayed.
-serverpref
- Use the server's cipher preferences.
-sess_in
file
- Load TLS session from file. The client will attempt to resume a connection
from this session.
-sess_out
file
- Output TLS session to file.
-starttls
protocol
- Send the protocol-specific messages to switch to TLS for communication.
protocol is a keyword for the intended protocol.
Currently, the supported keywords are "ftp", "imap",
"smtp", "pop3", and "xmpp".
-state
- Print the SSL session states.
-status
- Send a certificate status request to the server (OCSP stapling). The
server response (if any) is printed out.
-timeout
- Enable send/receive timeout on DTLS connections.
-tls1_2
|
-tls1_3
- Permit only TLS1.2 or 1.3 respectively.
-tlsextdebug
- Print a hex dump of any TLS extensions received from the server.
-use_srtp
profiles
- Offer SRTP key management with a colon-separated profile list.
-verify depth
- Turn on server certificate verification, with a maximum length of
depth. Currently the verify operation continues
after errors so all the problems with a certificate chain can be seen. As
a side effect the connection will never fail due to a server certificate
verify failure.
-verify_return_error
- Return verification error.
-xmpphost
hostname
- When used with
-starttls
xmpp, specify the host for the "to"
attribute of the stream element. If this option is not specified then the
host specified with -connect will be used.
openssl s_server
- [
-accept port]
[-alpn protocols]
[-bugs ]
[-CAfile file]
[-CApath directory]
[-cert file]
[-cert2 file]
[-certform der | pem ]
[-cipher cipherlist]
[-context id]
[-crl_check ]
[-crl_check_all ] [-crlf ]
[-dcert file]
[-dcertform der | pem ]
[-debug ]
[-dhparam file]
[-dkey file]
[-dkeyform der | pem ]
[-dpass arg]
[-dtls ] [-dtls1 ]
[-dtls1_2 ]
[-groups list]
[-HTTP ]
[-id_prefix arg]
[-key keyfile]
[-key2 keyfile]
[-keyform der | pem ]
[-keymatexport label]
[-keymatexportlen len]
[-msg ]
[-mtu mtu]
[-naccept num]
[-named_curve arg]
[-nbio ] [-nbio_test ]
[-no_cache ] [-no_dhe ]
[-no_ecdhe ] [-no_ticket ]
[-no_tls1_2 ] [-no_tls1_3 ]
[-no_tmp_rsa ] [-nocert ]
[-pass arg]
[-quiet ]
[-servername name]
[-servername_fatal ]
[-serverpref ] [-state ]
[-status ]
[-status_timeout nsec]
[-status_url url]
[-status_verbose ]
[-timeout ] [-tls1_2 ]
[-tls1_3 ] [-tlsextdebug ]
[-use_srtp profiles]
[-Verify depth]
[-verify depth]
[-verify_return_error ]
[-WWW ] [-www ]
The s_server command implements a generic
SSL/TLS server which listens for connections on a given port using
SSL/TLS.
If a connection request is established with a client and neither
the -www nor the -WWW option
has been used, then any data received from the client is displayed and any
key presses are sent to the client. Certain single letter commands perform
special operations:
P
- Send plain text, which should cause the client to disconnect.
Q
- End the current SSL connection and exit.
q
- End the current SSL connection, but still accept new connections.
R
- Renegotiate the SSL session and request a client certificate.
r
- Renegotiate the SSL session.
S
- Print out some session cache status information.
The options are as follows:
-accept
port
- Listen on TCP port for connections. The default is
port 4433.
-alpn
protocols
- Enable the Application-Layer Protocol Negotiation.
protocols is a comma-separated list of supported
protocol names.
-bugs
- Enable various workarounds for buggy implementations.
-CAfile
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.
-CApath
directory
- The directory to use for client certificate
verification. This directory must be in "hash format"; see
-verify for more information. These are also used
when building the server certificate chain.
-cert
file
- The certificate to use: most server's cipher suites require the use of a
certificate and some require a certificate with a certain public key type.
For example, the DSS cipher suites require a certificate containing a DSS
(DSA) key. If not specified, the file server.pem
will be used.
-cert2
file
- The certificate to use for servername.
-certform
der |
pem
- The certificate format. The default is
pem .
-cipher
cipherlist
- Modify the cipher list used by the server. This allows the cipher list
used by the server to be modified. When the client sends a list of
supported ciphers, the first client cipher also included in the server
list is used. Because the client specifies the preference order, the order
of the server cipherlist is irrelevant. See the
ciphers command for more information.
-context
id
- Set the SSL context ID. It can be given any string value.
-crl_check ,
-crl_check_all
- Check the peer certificate has not been revoked by its CA. The CRLs are
appended to the certificate file.
-crl_check_all
checks all CRLs of all CAs in the chain.
-crlf
- Translate a line feed from the terminal into CR+LF.
-dcert
file, -dkey
file
- Specify an additional certificate and private key; these behave in the
same manner as the
-cert and
-key options except there is no default if they
are not specified (no additional certificate or key is used). By using RSA
and DSS certificates and keys, a server can support clients which only
support RSA or DSS cipher suites by using an appropriate certificate.
-dcertform
der |
pem ,
-dkeyform der |
pem ,
-dpass arg
- Additional certificate and private key format, and private key password
source, respectively.
-debug
- Print extensive debugging information, including a hex dump of all
traffic.
-dhparam 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
s_server
program will be used.
-dtls
- Permit any version of DTLS.
-dtls1_2
- Permit only DTLS1.2.
-groups
list
- Set the supported elliptic curve groups to the colon separated
list of group NIDs or names as documented in
SSL_CTX_set1_groups_list(3).
-HTTP
- Emulate a simple web server. Pages are resolved relative to the current
directory. For example if the URL
https://myhost/page.html is requested, the file
./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).
-id_prefix
arg
- Generate SSL/TLS session IDs prefixed by arg. This
is mostly useful for testing any SSL/TLS code that wish to deal with
multiple servers, when each of which might be generating a unique range of
session IDs.
-key
keyfile
- The private key to use. If not specified, the certificate file will be
used.
-key2
keyfile
- The private key to use for servername.
-keyform
der |
pem
- The private key format. The default is
pem .
-keymatexport
label
- Export keying material using label.
-keymatexportlen
len
- Export len bytes of keying material (default 20).
-msg
- Show all protocol messages with hex dump.
-mtu
mtu
- Set the link layer MTU.
-naccept
num
- Terminate server after num connections.
-named_curve
arg
- Specify the elliptic curve name to use for ephemeral ECDH keys. This
option is deprecated; use
-groups instead.
-nbio
- Turn on non-blocking I/O.
-nbio_test
- Test non-blocking I/O.
-no_cache
- Disable session caching.
-no_dhe
- Disable ephemeral DH cipher suites.
-no_ecdhe
- Disable ephemeral ECDH cipher suites.
-no_ticket
- Disable RFC 4507 session ticket support.
-no_tls1_2
|
-no_tls1_3
- Disable the use of TLS1.2 and 1.3, respectively.
-no_tmp_rsa
- Disable temporary RSA key generation.
-nocert
- Do not use a certificate. This restricts the cipher suites available to
the anonymous ones (currently just anonymous DH).
-pass
arg
- The private key password source.
-quiet
- Inhibit printing of session and certificate information.
-servername
name
- Set the TLS Server Name Indication (SNI) extension with
name.
-servername_fatal
- Send fatal alert if servername does not match. The default is warning
alert.
-serverpref
- Use server's cipher preferences.
-state
- Print the SSL session states.
-status
- Enables certificate status request support (OCSP stapling).
-status_timeout
nsec
- Sets the timeout for OCSP response in seconds.
-status_url
url
- Sets a fallback responder URL to use if no responder URL is present in the
server certificate. Without this option, an error is returned if the
server certificate does not contain a responder address.
-status_verbose
- Enables certificate status request support (OCSP stapling) and gives a
verbose printout of the OCSP response.
-timeout
- Enable send/receive timeout on DTLS connections.
-tls1_2
|
-tls1_3
- Permit only TLS1.2, or 1.3, respectively.
-tlsextdebug
- Print a hex dump of any TLS extensions received from the server.
-use_srtp
profiles
- Offer SRTP key management with a colon-separated profile list.
-verify_return_error
- Return verification error.
-WWW
- Emulate a simple web server. Pages are resolved relative to the current
directory. For example if the URL
https://myhost/page.html is requested, the file
./page.html will be loaded.
-www
- Send a status message to the client when it connects, including
information about the ciphers used and various session parameters. The
output is in HTML format so this option will normally be used with a web
browser.
-Verify
depth, -verify
depth
- Request a certificate chain from the client, with a maximum length of
depth. With
-Verify , the
client must supply a certificate or an error occurs; with
-verify , a certificate is requested but the client
does not have to send one.
openssl s_time
- [
-bugs ]
[-CAfile file]
[-CApath directory]
[-cert file]
[-cipher cipherlist]
[-connect host[:port]]
[-key keyfile]
[-nbio ] [-new ]
[-no_shutdown ] [-reuse ]
[-time seconds]
[-verify depth]
[-www page]
The s_time command implements a generic
SSL/TLS client which connects to a remote host using SSL/TLS. It can request
a page from the server and includes the time to transfer the payload data in
its timing measurements. It measures the number of connections within a
given timeframe, the amount of data transferred (if any), and calculates the
average time spent for one connection.
The options are as follows:
-bugs
- Enable various workarounds for buggy implementations.
-CAfile
file
- A file containing trusted certificates to use during
server authentication and to use when attempting to build the client
certificate chain.
-CApath
directory
- The directory to use for server certificate verification. This directory
must be in "hash format"; see
verify for
more information. These are also used when building the client certificate
chain.
-cert
file
- The certificate to use, if one is requested by the server. The default is
not to use a certificate.
-cipher
cipherlist
- Modify the cipher list sent by the client. Although the server determines
which cipher suite is used, it should take the first supported cipher in
the list sent by the client. See the
ciphers
command for more information.
-connect
host[:port]
- The host and port to connect to.
-key
keyfile
- The private key to use. If not specified, the certificate file will be
used.
-nbio
- Turn on non-blocking I/O.
-new
- Perform the timing test using a new session ID for each connection. If
neither
-new nor -reuse
are specified, they are both on by default and executed in sequence.
-no_shutdown
- Shut down the connection without sending a "close notify"
shutdown alert to the server.
-reuse
- Perform the timing test using the same session ID for each connection. If
neither
-new nor -reuse
are specified, they are both on by default and executed in sequence.
-time
seconds
- Limit
s_time benchmarks to the number of
seconds. The default is 30 seconds.
-verify depth
- Turn on server certificate verification, with a maximum length of
depth. Currently the verify operation continues
after errors, so all the problems with a certificate chain can be seen. As
a side effect, the connection will never fail due to a server certificate
verify failure.
-www
page
- The page to GET from the server. A value of ‘/’ gets the
index.htm[l] page. If this parameter is not specified,
s_time will only perform the handshake to
establish SSL connections but not transfer any payload data.
openssl sess_id
- [
-cert ]
[-context ID]
[-in file]
[-inform der | pem ]
[-noout ]
[-out file]
[-outform der | pem ]
[-text ]
The sess_id program processes the encoded
version of the SSL session structure and optionally prints out SSL session
details (for example the SSL session master key) in human-readable
format.
The options are as follows:
-cert
- If a certificate is present in the session, it will be output using this
option; if the
-text option is also present, then
it will be printed out in text form.
-context
ID
- Set the session ID. The ID can be any string of
characters.
-in
file
- The input file to read from, or standard input if not specified.
-inform
der |
pem
- The input format.
der uses an ASN.1 DER-encoded
format containing session details. The precise format can vary from one
version to the next. pem is the default format: it
consists of the DER format base64-encoded with additional header and
footer lines.
-noout
- Do not output the encoded version of the session.
-out
file
- The output file to write to, or standard output if not specified.
-outform
der |
pem
- The output format.
-text
- Print the various public or private key components in plain text, in
addition to the encoded version.
The output of sess_id is composed as
follows:
- Protocol
- The protocol in use.
- Cipher
- The actual raw SSL or TLS cipher code.
- Session-ID
- The SSL session ID, in hex format.
- Session-ID-ctx
- The session ID context, in hex format.
- Master-Key
- The SSL session master key.
- Key-Arg
- The key argument; this is only used in SSL v2.
- Start Time
- The session start time. UNIX format.
- Timeout
- The timeout, in seconds.
- Verify return code
- The return code when a certificate is verified.
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 "real" application. This is,
however, strongly discouraged and should only be used for debugging
purposes.
openssl smime
- [
-aes128
| -aes192 | -aes256 | -des | -des3
| -rc2-40 | -rc2-64 | -rc2-128 ]
[-binary ]
[-CAfile file]
[-CApath directory]
[-certfile file]
[-check_ss_sig ]
[-content file]
[-crl_check ]
[-crl_check_all ]
[-decrypt ] [-encrypt ]
[-extended_crl ]
[-from addr]
[-ignore_critical ]
[-in file]
[-indef ]
[-inform der | pem | smime ]
[-inkey file]
[-issuer_checks ]
[-keyform der | pem ]
[-md digest]
[-noattr ] [-nocerts ]
[-nochain ] [-nodetach ]
[-noindef ] [-nointern ]
[-nosigs ] [-nosmimecap ]
[-noverify ]
[-out file]
[-outform der | pem | smime ]
[-passin arg]
[-pk7out ] [-policy_check ]
[-recip file]
[-resign ] [-sign ]
[-signer file]
[-stream ]
[-subject s]
[-text ]
[-to addr]
[-verify ] [-x509_strict ]
[cert.pem ...]
The smime command handles S/MIME mail. It
can encrypt, decrypt, sign, and verify S/MIME messages.
The MIME message must be sent without any blank lines between the
headers and the output. Some mail programs will automatically add a blank
line. Piping the mail directly to an MTA is one way to achieve the correct
format.
The supplied message to be signed or encrypted must include the
necessary MIME headers or many S/MIME clients won't display it properly (if
at all). Use the -text option to automatically add
plain text headers.
A "signed and encrypted" message is one where a signed
message is then encrypted. This can be produced by encrypting an already
signed message.
There are a number of operations that can be performed, as
follows:
-decrypt
- Decrypt mail using the supplied certificate and private key. The input
file is an encrypted mail message in MIME format. The decrypted mail is
written to the output file.
-encrypt
- Encrypt mail for the given recipient certificates. The input is the
message to be encrypted. The output file is the encrypted mail, in MIME
format.
-pk7out
- Take an input message and write out a PEM-encoded PKCS#7 structure.
-resign
- Resign a message: take an existing message and one or more new
signers.
-sign
- Sign mail using the supplied certificate and private key. The input file
is the message to be signed. The signed message, in MIME format, is
written to the output file.
-verify
- Verify signed mail. The input is a signed mail message and the output is
the signed data. Both clear text and opaque signing is supported.
The remaining options are as follows:
-aes128
|
-aes192
|
-aes256
|
-des
|
-des3
|
-rc2-40
|
-rc2-64
|
-rc2-128
- The encryption algorithm to use. 128-, 192-, or 256-bit AES, DES (56
bits), triple DES (168 bits), or 40-, 64-, or 128-bit RC2, respectively;
if not specified, 40-bit RC2 is used. Only used with
-encrypt .
-binary
- Normally, the input message is converted to "canonical" format
which uses CR/LF as end of line, as required by the S/MIME specification.
When this option is present, no translation occurs. This is useful when
handling binary data which may not be in MIME format.
-CAfile
file
- A file containing trusted CA certificates; only used
with
-verify .
-CApath
directory
- A directory containing trusted CA certificates; only
used with
-verify . This directory must be a
standard certificate directory: that is, a hash of each subject name
(using x509 -hash ) should be linked to each
certificate.
- cert.pem ...
- One or more certificates of message recipients: used when encrypting a
message.
-certfile
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.
-check_ss_sig ,
-crl_check , -crl_check_all ,
-extended_crl ,
-ignore_critical ,
-issuer_checks ,
-policy_check ,
-x509_strict
- Set various certificate chain validation options. See the
verify command for details.
-content
file
- A file containing the detached content. This is only useful with the
-verify option, and only usable if the PKCS#7
structure is using the detached signature form where the content is not
included. This option will override any content if the input format is
S/MIME and it uses the multipart/signed MIME content type.
-from
addr, -subject
s, -to
addr
- The relevant mail headers. These are included outside the signed portion
of a message so they may be included manually. When signing, many S/MIME
mail clients check that the signer's certificate email address matches the
From: address.
-in
file
- The input file to read from.
-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.
-inform
der |
pem
| smime
- The input format.
-inkey
file
- The private key to use when signing or decrypting, which must match the
corresponding certificate. If this option is not specified, the private
key must be included in the certificate file specified with the
-recip or -signer file.
When signing, this option can be used multiple times to specify successive
keys.
-keyform
der |
pem
- Input private key format. The default is
pem .
-md
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).
-noattr
- Do not include attributes.
-nocerts
- Do not include the signer's certificate. This will reduce the size of the
signed message but the verifier must have a copy of the signer's
certificate available locally (passed using the
-certfile option, for example).
-nochain
- Do not do chain verification of signers' certificates: that is, don't use
the certificates in the signed message as untrusted CAs.
-nodetach
- When signing a message, use opaque signing: this form is more resistant to
translation by mail relays but it cannot be read by mail agents that do
not support S/MIME. Without this option cleartext signing with the MIME
type multipart/signed is used.
-noindef
- Disable streaming I/O where it would produce an encoding of indefinite
length (currently has no effect).
-nointern
- Only use certificates specified in the
-certfile .
The supplied certificates can still be used as untrusted CAs.
-nosigs
- Do not try to verify the signatures on the message.
-nosmimecap
- Exclude the list of supported algorithms from signed attributes, other
options such as signing time and content type are still included.
-noverify
- Do not verify the signer's certificate of a signed message.
-out
file
- The output file to write to.
-outform
der |
pem
| smime
- The output format. The default is smime, which writes an S/MIME format
message.
pem and der
change this to write PEM and DER format PKCS#7 structures instead. This
currently only affects the output format of the PKCS#7 structure; if no
PKCS#7 structure is being output (for example with
-verify or -decrypt ) this
option has no effect.
-passin
arg
- The key password source.
-recip
file
- The recipients certificate when decrypting a message. This certificate
must match one of the recipients of the message or an error occurs.
-signer
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.
-stream
- The same as
-indef .
-text
- Add plain text (text/plain) MIME headers to the supplied message if
encrypting or signing. If decrypting or verifying, it strips off text
headers: if the decrypted or verified message is not of MIME type
text/plain then an error occurs.
The exit codes for smime are as
follows:
- 0
- The operation was completely successful.
- 1
- An error occurred parsing the command options.
- 2
- One of the input files could not be read.
- 3
- An error occurred creating the file or when reading the message.
- 4
- An error occurred decrypting or verifying the message.
- 5
- An error occurred writing certificates.
openssl speed
- [algorithm] [
-decrypt ]
[-elapsed ]
[-evp algorithm]
[-mr ]
[-multi number]
[-unaligned number]
The speed command is used to test the
performance of cryptographic algorithms.
- algorithm
- Perform the test using algorithm. The default is to
test all algorithms.
-decrypt
- Time decryption instead of encryption; must be used with
-evp .
-elapsed
- Measure time in real time instead of CPU user time.
-evp
algorithm
- Perform the test using one of the algorithms accepted by
EVP_get_cipherbyname(3).
-mr
- Produce machine readable output.
-multi
number
- Run number benchmarks in parallel.
-unaligned
number
- Use allocated buffers with an offset of number bytes
from the alignment provided by
malloc(3).
number should be between 0 and 16.
openssl ts
-query
[-md4 | -md5 | -ripemd160 | -sha1 ]
[-cert ]
[-config configfile]
[-data file_to_hash]
[-digest digest_bytes]
[-in request.tsq]
[-no_nonce ]
[-out request.tsq]
[-policy object_id]
[-text ]
openssl ts
-reply
[-chain certs_file.pem]
[-config configfile]
[-in response.tsr]
[-inkey private.pem]
[-out response.tsr]
[-passin arg]
[-policy object_id]
[-queryfile request.tsq]
[-section tsa_section]
[-signer tsa_cert.pem]
[-text ] [-token_in ]
[-token_out ]
openssl ts
-verify
[-CAfile trusted_certs.pem]
[-CApath trusted_cert_path]
[-data file_to_hash]
[-digest digest_bytes]
[-in response.tsr]
[-queryfile request.tsq]
[-token_in ]
[-untrusted cert_file.pem]
The ts command is a basic Time Stamping
Authority (TSA) client and server application as specified in RFC 3161
(Time-Stamp Protocol, TSP). A TSA can be part of a PKI deployment and its
role is to provide long term proof of the existence of specific data. Here
is a brief description of the protocol:
- The TSA client computes a one-way hash value for a data file and sends the
hash to the TSA.
- 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.
- 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.
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 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.
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.
The -query switch can be used for creating
and printing a time stamp request with the following options:
-cert
- Expect the TSA to include its signing certificate in the response.
-config
configfile
- Specify an alternative configuration file. Only the OID section is
used.
-data
file_to_hash
- The data file for which the time stamp request needs to be created. The
default is standard input.
-digest
digest_bytes
- Specify the message imprint explicitly without the data file. The imprint
must be specified in a hexadecimal format, two characters per byte, the
bytes optionally separated by colons. The number of bytes must match the
message digest algorithm in use.
-in
request.tsq
- A previously created time stamp request in DER format that will be printed
into the output file. Useful for examining the content of a request in
human-readable format.
-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
dgst
command. The default is SHA1.
-no_nonce
- Specify no nonce in the request. The default, to include a 64-bit long
pseudo-random nonce, is recommended to protect against replay
attacks.
-out
request.tsq
- The output file to write to, or standard output if not specified.
-policy
object_id
- The policy that the client expects the TSA to use for creating the time
stamp token. Either dotted OID notation or OID names defined in the config
file can be used. If no policy is requested, the TSA uses its own default
policy.
-text
- Output in human-readable text format instead of DER.
A time stamp response (TimeStampResp) consists of a response
status and the time stamp token itself (ContentInfo), if the token
generation was successful. The -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
-token_out is not specified the output is always a
time stamp response (TimeStampResp), otherwise it is a time stamp token
(ContentInfo).
-chain
certs_file.pem
- The collection of PEM certificates that will be included in the response
in addition to the signer certificate if the
-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
-reply command does not build a certificate chain
automatically.
-config
configfile
- Specify an alternative configuration file.
-in
response.tsr
- Specify a previously created time stamp response (or time stamp token, if
-token_in is also specified) in DER format that
will be written to the output file. This option does not require a
request; it is useful, for example, to examine the content of a response
or token or to extract the time stamp token from a response. If the input
is a token and the output is a time stamp response, a default
"granted" status info is added to the token.
-inkey
private.pem
- The signer private key of the TSA in PEM format. Overrides the
signer_key config file option.
-out
response.tsr
- The response is written to this file. The format and content of the file
depends on other options (see
-text and
-token_out ). The default is stdout.
-passin
arg
- The key password source.
-policy
object_id
- The default policy to use for the response. Either dotted OID notation or
OID names defined in the config file can be used. If no policy is
requested, the TSA uses its own default policy.
-queryfile
request.tsq
- The file containing a DER-encoded time stamp request.
-section
tsa_section
- The config file section containing the settings for response
generation.
-signer
tsa_cert.pem
- The PEM signer certificate of the TSA. The TSA signing certificate must
have exactly one extended key usage assigned to it: timeStamping. The
extended key usage must also be critical, otherwise the certificate is
going to be refused. Overrides the
signer_cert
variable of the config file.
-text
- Output in human-readable text format instead of DER.
-token_in
- The input is a DER-encoded time stamp token (ContentInfo) instead of a
time stamp response (TimeStampResp).
-token_out
- The output is a time stamp token (ContentInfo) instead of a time stamp
response (TimeStampResp).
The -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 -verify command
does not use the configuration file.
-CAfile
trusted_certs.pem
- The file containing a set of trusted self-signed PEM CA certificates. See
verify for additional details. Either this option
or -CApath must be specified.
-CApath
trusted_cert_path
- The directory containing the trusted CA certificates of the client. See
verify for additional details. Either this option
or -CAfile must be specified.
-data
file_to_hash
- The response or token must be verified against
file_to_hash. The file is hashed with the message
digest algorithm specified in the token. The
-digest and -queryfile
options must not be specified with this one.
-digest
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
-data
and -queryfile options must not be specified with
this one.
-in
response.tsr
- The time stamp response that needs to be verified, in DER format. This
option in mandatory.
-queryfile
request.tsq
- The original time stamp request, in DER format. The
-data and -digest options
must not be specified with this one.
-token_in
- The input is a DER-encoded time stamp token (ContentInfo) instead of a
time stamp response (TimeStampResp).
-untrusted
cert_file.pem
- Additional untrusted PEM certificates which may be needed when building
the certificate chain for the TSA's signing certificate. This file must
contain the TSA signing certificate and all intermediate CA certificates
unless the response includes them.
Options specified on the command line always override the settings
in the config file:
tsa
section, default_tsa
- This is the main section and it specifies the name of another section that
contains all the options for the
-reply option.
This section can be overridden with the -section
command line switch.
oid_file
- See
ca for a description.
oid_section
- See
ca for a description.
serial
- The file containing the hexadecimal serial number of the last time stamp
response created. This number is incremented by 1 for each response. If
the file does not exist at the time of response generation, a new file is
created with serial number 1. This parameter is mandatory.
signer_cert
- TSA signing certificate, in PEM format. The same as the
-signer command line option.
certs
- A set of PEM-encoded certificates that need to be included in the
response. The same as the
-chain command line
option.
signer_key
- The private key of the TSA, in PEM format. The same as the
-inkey command line option.
default_policy
- The default policy to use when the request does not mandate any policy.
The same as the
-policy command line option.
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.
digests
- The list of message digest algorithms that the TSA accepts. At least one
algorithm must be specified. This parameter is mandatory.
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.
clock_precision_digits
- The maximum number of digits, which represent the fraction of seconds,
that need to be included in the time field. The trailing zeroes must be
removed from the time, so there might actually be fewer digits or no
fraction of seconds at all. The maximum value is 6; the default is 0.
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.
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.
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
certs variable or the
-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.
openssl verify
- [
-CAfile file]
[-CApath directory]
[-check_ss_sig ]
[-CRLfile file]
[-crl_check ]
[-crl_check_all ]
[-explicit_policy ]
[-extended_crl ] [-help ]
[-ignore_critical ]
[-inhibit_any ]
[-inhibit_map ]
[-issuer_checks ]
[-legacy_verify ]
[-policy_check ]
[-purpose purpose]
[-trusted file]
[-untrusted file]
[-verbose ] [-x509_strict ]
[certificates]
The verify command verifies certificate
chains.
The options are as follows:
-CAfile
file
- A file of trusted certificates. The
file should contain multiple certificates in PEM
format, concatenated together.
-CApath
directory
- A directory of trusted certificates. The
certificates, or symbolic links to them, should have names of the form
hash.0, where hash is the
hashed certificate subject name (see the
-hash
option of the x509 utility).
-check_ss_sig
- Verify the signature on the self-signed root CA. This is disabled by
default because it doesn't add any security.
-CRLfile
file
- The file should contain one or more CRLs in PEM
format.
-crl_check
- Check end entity certificate validity by attempting to look up a valid
CRL. If a valid CRL cannot be found, an error occurs.
-crl_check_all
- Check the validity of all certificates in the chain by attempting to look
up valid CRLs.
-explicit_policy
- Set policy variable require-explicit-policy (RFC 3280).
-extended_crl
- Enable extended CRL features such as indirect CRLs and alternate CRL
signing keys.
-help
- Print a usage message.
-ignore_critical
- Ignore critical extensions instead of rejecting the certificate.
-inhibit_any
- Set policy variable inhibit-any-policy (RFC 3280).
-inhibit_map
- Set policy variable inhibit-policy-mapping (RFC 3280).
-issuer_checks
- Print diagnostics relating to searches for the issuer certificate of the
current certificate showing why each candidate issuer certificate was
rejected. The presence of rejection messages does not itself imply that
anything is wrong: during the normal verify process several rejections may
take place.
-legacy_verify
- Use the legacy X.509 certificate chain verification code.
-policy_check
- Enable certificate policy processing.
-purpose
purpose
- The intended use for the certificate. Without this option no chain
verification will be done. Currently accepted uses are
sslclient , sslserver ,
nssslserver , smimesign ,
smimeencrypt , crlsign ,
any , and ocsphelper .
-trusted
file
- A file of trusted certificates. The
file should contain multiple certificates.
-untrusted
file
- A file of untrusted certificates. The
file should contain multiple certificates.
-verbose
- Print extra information about the operations being performed.
-x509_strict
- Disable workarounds for broken certificates which have to be disabled for
strict X.509 compliance.
- certificates
- One or more PEM certificates to verify. If no
certificate files are included, an attempt is made to read a certificate
from standard input. If the first certificate filename begins with a dash,
use a lone dash to mark the last option.
The verify program uses the same functions
as the internal SSL and S/MIME verification, with one crucial difference:
wherever possible an attempt is made to continue after an error, whereas
normally the verify operation would halt on the first error. This allows all
the problems with a certificate chain to be determined.
The verify operation consists of a number of separate steps.
Firstly a certificate chain is built up starting from the supplied
certificate and ending in the root CA. It is an error if the whole chain
cannot be built up. The chain is built up by looking up the issuer's
certificate of the current certificate. If a certificate is found which is
its own issuer, it is assumed to be the root CA.
All certificates whose subject name matches the issuer name of the
current certificate are subject to further tests. The relevant authority key
identifier components of the current certificate (if present) must match the
subject key identifier (if present) and issuer and serial number of the
candidate issuer; in addition the keyUsage extension
of the candidate issuer (if present) must permit certificate signing.
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.
The second operation is to check every untrusted certificate's
extensions for consistency with the supplied purpose. If the
-purpose option is not included, then no checks are
done. The supplied or "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 X509 section below.
The third operation is to check the trust settings on the root CA.
The root CA should be trusted for the supplied purpose. A certificate with
no trust settings is considered to be valid for all purposes.
The final operation is to check the validity of the certificate
chain. The validity period is checked against the current system time and
the notBefore and notAfter
dates in the certificate. The certificate signatures are also checked at
this point.
If all operations complete successfully, the certificate is
considered valid. If any operation fails then the certificate is not valid.
When a verify operation fails, the output messages can be somewhat cryptic.
The general form of the error message is:
server.pem: /C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test CA (1024-bit)
error 24 at 1 depth lookup:invalid CA certificate
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 as defined by the
X509_V_ERR_* constants in
<openssl/x509_vfy.h> , the
associated error message documented in
X509_STORE_CTX_get_error(3),
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.
openssl version
[-abdfpv ]
The version command is used to print out
version information about openssl .
The options are as follows:
-a
- All information: this is the same as setting all the other flags.
-b
- The date the current version of
openssl was
built.
-d
OPENSSLDIR
setting.
-f
- Compilation flags.
-p
- Platform setting.
-v
- The current
openssl version.
openssl x509
- [
-addreject arg]
[-addtrust arg]
[-alias ]
[-CA file]
[-CAcreateserial ]
[-CAform der | pem ]
[-CAkey file]
[-CAkeyform der | pem ]
[-CAserial file]
[-certopt option]
[-checkend arg]
[-clrext ] [-clrreject ]
[-clrtrust ] [-dates ]
[-days arg]
[-email ] [-enddate ]
[-extensions section]
[-extfile file]
[-fingerprint ]
[-force_pubkey key]
[-hash ]
[-in file]
[-inform der | net | pem ]
[-issuer ] [-issuer_hash ]
[-issuer_hash_old ]
[-keyform der | pem ]
[-md5 | -sha1 ]
[-modulus ]
[-multivalue-rdn ]
[-nameopt option]
[-new ] [-next_serial ]
[-noout ] [-ocsp_uri ]
[-ocspid ]
[-out file]
[-outform der | net | pem ]
[-passin arg]
[-pubkey ] [-purpose ]
[-req ] [-serial ]
[-set_issuer name]
[-set_serial n]
[-set_subject name]
[-setalias arg]
[-signkey file]
[-sigopt nm:v]
[-startdate ] [-subject ]
[-subject_hash ]
[-subject_hash_old ]
[-text ] [-trustout ]
[-utf8 ] [-x509toreq ]
The 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
"mini CA", or edit certificate trust settings.
The following are x509 input, output, and general purpose
options:
-in
file
- The input file to read from, or standard input if not specified. This
option cannot be used with
-new .
-inform
der |
net
|
pem
- The input format. Normally, the command will expect an X.509 certificate,
but this can change if other options such as
-in
or -req are present.
-md5
|
-sha1
- The digest to use. This affects any signing or display option that uses a
message digest, such as the
-fingerprint ,
-signkey , and -CA options.
If not specified, MD5 is used. SHA1 is always used with DSA keys.
-out
file
- The output file to write to, or standard output if none is specified.
-outform
der |
net
|
pem
- The output format.
-passin
arg
- The key password source.
The following are x509 display options:
-certopt
option
- Customise the output format used with
-text ,
either using a list of comma-separated options or by specifying
-certopt multiple times. The default behaviour is
to print all fields. The options are as follows:
ca_default
- Equivalent to
no_issuer ,
no_pubkey , no_header ,
no_version ,
no_sigdump , and
no_signame .
compatible
- Equivalent to no output options at all.
ext_default
- Print unsupported certificate extensions.
ext_dump
- Hex dump unsupported extensions.
ext_error
- Print an error message for unsupported certificate extensions.
ext_parse
- ASN.1 parse unsupported extensions.
no_aux
- Do not print certificate trust information.
no_extensions
- Do not print X509V3 extensions.
- Do not print header (Certificate and Data) information.
no_issuer
- Do not print the issuer name.
no_pubkey
- Do not print the public key.
no_serial
- Do not print the serial number.
no_sigdump
- Do not give a hexadecimal dump of the certificate signature.
no_signame
- Do not print the signature algorithm used.
no_subject
- Do not print the subject name.
no_validity
- Do not print the
notBefore and
notAfter (validity) fields.
no_version
- Do not print the version number.
-dates
- Print the start and expiry date of a certificate.
-email
- Output the email addresses, if any.
-enddate
- Print the expiry date of the certificate; that is, the
notAfter date.
-fingerprint
- Print the digest of the DER-encoded version of the whole certificate.
-hash
- A synonym for
-subject_hash .
-issuer
- Print the issuer name.
-issuer_hash
- Print the hash of the certificate issuer name.
-issuer_hash_old
- Print the hash of the certificate issuer name using the older algorithm as
used by
openssl versions before 1.0.0.
-modulus
- Print the value of the modulus of the public key contained in the
certificate.
-multivalue-rdn
- This option causes the
-subj argument to be
interpreted with full support for multivalued RDNs, for example
"/DC=org/DC=OpenSSL/DC=users/UID=123456+CN=John Doe". If
-multivalue-rdn is not used, the UID value is set
to "123456+CN=John Doe".
-nameopt
option
- Customise how the subject or issuer names are displayed, either using a
list of comma-separated options or by specifying
-nameopt multiple times. The default behaviour is
to use the oneline format. The options, which can
be preceded by a dash to turn them off, are as follows:
align
- Align field values for a more readable output. Only usable with
sep_multiline.
compat
- Use the old format, equivalent to specifying no options at all.
dn_rev
- Reverse the fields of the DN, as required by RFC 2253. As a side
effect, this also reverses the order of multiple AVAs.
dump_all
- Dump all fields. When used with dump_der, it
allows the DER encoding of the structure to be unambiguously
determined.
dump_der
- Any fields that need to be hexdumped are dumped using the DER encoding
of the field. Otherwise just the content octets will be displayed.
Both options use the RFC 2253 #XXXX... format.
dump_nostr
- Dump non-character string types (for example OCTET STRING); usually,
non-character string types are displayed as though each content octet
represents a single character.
dump_unknown
- Dump any field whose OID is not recognised by
openssl .
esc_2253
- Escape the "special" characters required by RFC 2253 in a
field that is “ ,+"<>;”. Additionally,
‘#’ is escaped at the beginning of a string and a space
character at the beginning or end of a string.
esc_ctrl
- Escape control characters. That is, those with ASCII values less than
0x20 (space) and the delete (0x7f) character. They are escaped using
the RFC 2253 \XX notation (where XX are two hex digits representing
the character value).
esc_msb
- Escape characters with the MSB set; that is, with ASCII values larger
than 127.
multiline
- A multiline format. Equivalent to
esc_ctrl ,
esc_msb ,
sep_multiline ,
space_eq , lname , and
align .
no_type
- Do not attempt to interpret multibyte characters. That is, content
octets are merely dumped as though one octet represents each
character. This is useful for diagnostic purposes but results in
rather odd looking output.
nofname ,
sname , lname ,
oid
- Alter how the field name is displayed:
nofname
does not display the field at all; sname uses
the short name form (CN for commonName , for
example); lname uses the long form.
oid represents the OID in numerical form and
is useful for diagnostic purpose.
oneline
- A one line format which is more readable than
RFC2253 . Equivalent to
esc_2253 , esc_ctrl ,
esc_msb , utf8 ,
dump_nostr , dump_der ,
use_quote ,
sep_comma_plus_spc ,
space_eq , and
sname .
RFC2253
- Displays names compatible with RFC 2253. Equivalent to
esc_2253 , esc_ctrl ,
esc_msb , utf8 ,
dump_nostr ,
dump_unknown ,
dump_der ,
sep_comma_plus ,
dn_rev , and
sname .
sep_comma_plus ,
sep_comma_plus_space ,
sep_semi_plus_space ,
sep_multiline
- 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 "space"
additionally place a space after the separator to make it more
readable.
sep_multiline uses a linefeed
character for the RDN separator and a spaced ‘+’ for the
AVA separator, as well as indenting the fields by four characters. If
no field separator is specified then
sep_comma_plus_space is used by default.
show_type
- Show the type of the ASN.1 character string. The type precedes the
field contents. For example "BMPSTRING: Hello World".
space_eq
- Place spaces round the ‘=’ character which follows the
field name.
use_quote
- Escape some characters by surrounding the whole string with
‘"’ characters. Without the option, all escaping is
done with the ‘\’ character.
utf8
- Convert all strings to UTF8 format first, as required by RFC 2253. On
a UTF8 compatible terminal, the use of this option (and not setting
esc_msb ) may result in the correct display of
multibyte characters. Usually, multibyte characters larger than 0xff
are represented using the format \UXXXX for 16 bits and \WXXXXXXXX for
32 bits, and any UTF8Strings are converted to their character form
first.
-next_serial
- Print the next serial number.
-noout
- Do not output the encoded version of the request.
-ocsp_uri
- Print the OCSP responder addresses, if any.
-ocspid
- Print OCSP hash values for the subject name and public key.
-pubkey
- Print the public key.
-serial
- Print the certificate serial number.
-sigopt
nm:v
- Pass options to the signature algorithm during sign or certify operations.
The names and values of these options are algorithm-specific.
-startdate
- Print the start date of the certificate; that is, the
notBefore date.
-subject
- Print the subject name.
-subject_hash
- Print the hash of the certificate subject name. This is used in
openssl to form an index to allow certificates in
a directory to be looked up by subject name.
-subject_hash_old
- Print the hash of the certificate subject name using the older algorithm
as used by
openssl versions before 1.0.0.
-text
- Print the full certificate in text form.
A trusted certificate is a certificate which has several
additional pieces of information attached to it such as the permitted and
prohibited uses of the certificate and an alias. When a certificate is being
verified, at least one certificate must be trusted. By default, a trusted
certificate must be stored locally and be a root CA. The following are x509
trust settings options:
-addreject
arg
- Add a prohibited use. Accepts the same values as the
-addtrust option.
-addtrust
arg
- Add a trusted certificate use. Any object name can be used here, but
currently only
clientAuth (SSL client use),
serverAuth (SSL server use), and
emailProtection (S/MIME email) are used.
-alias
- Output the certificate alias.
-clrreject
- Clear all the prohibited or rejected uses of the certificate.
-clrtrust
- Clear all the permitted or trusted uses of the certificate.
-purpose
- Perform tests on the certificate extensions. 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.
The 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.
All CAs should have the CA flag set to true.
If the basicConstraints extension is
absent, then the certificate is considered to be a 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.
If the certificate is a V1 certificate (and thus has no
extensions) and it is self-signed, it is also assumed to be a CA but a
warning is again given. This is to work around the problem of Verisign
roots which are V1 self-signed certificates.
If the keyUsage extension is present,
then additional restraints are made on the uses of the certificate. A CA
certificate must have the keyCertSign bit set if
the keyUsage extension is present.
The extended key usage extension places additional
restrictions on the certificate uses. If this extension is present,
whether critical or not, the key can only be used for the purposes
specified.
A complete description of each test is given below. The
comments about basicConstraints and
keyUsage and V1 certificates above apply to all
CA certificates.
- SSL Client
- The extended key usage extension must be absent or include the web
client authentication OID.
keyUsage must be
absent or it must have the digitalSignature
bit set. The Netscape certificate type must be absent or it must have
the SSL client bit set.
- SSL Client CA
- The extended key usage extension must be absent or include the web
client authentication OID. The Netscape certificate type must be
absent or it must have the SSL CA bit set: this is used as a
workaround if the
basicConstraints extension
is absent.
- SSL Server
- The extended key usage extension must be absent or include the web
server authentication and/or one of the SGC OIDs.
keyUsage must be absent or it must have the
digitalSignature set, the
keyEncipherment set, or both bits set. The
Netscape certificate type must be absent or have the SSL server bit
set.
- SSL Server CA
- The extended key usage extension must be absent or include the web
server authentication and/or one of the SGC OIDs. The Netscape
certificate type must be absent or the SSL CA bit must be set: this is
used as a workaround if the
basicConstraints
extension is absent.
- Netscape SSL Server
- For Netscape SSL clients to connect to an SSL server; it must have the
keyEncipherment bit set if the
keyUsage extension is present. This isn't
always valid because some cipher suites use the key for digital
signing. Otherwise it is the same as a normal SSL server.
- Common S/MIME Client Tests
- The extended key usage extension must be absent or include the email
protection OID. The Netscape certificate type must be absent or should
have the S/MIME bit set. If the S/MIME bit is not set in Netscape
certificate type, then the SSL client bit is tolerated as an
alternative but a warning is shown: this is because some Verisign
certificates don't set the S/MIME bit.
- S/MIME Signing
- In addition to the common S/MIME client tests, the
digitalSignature bit must be set if the
keyUsage extension is present.
- S/MIME Encryption
- In addition to the common S/MIME tests, the
keyEncipherment bit must be set if the
keyUsage extension is present.
- S/MIME CA
- The extended key usage extension must be absent or include the email
protection OID. The Netscape certificate type must be absent or must
have the S/MIME CA bit set: this is used as a workaround if the
basicConstraints extension is absent.
- CRL Signing
- The
keyUsage extension must be absent or it
must have the CRL signing bit set.
- CRL Signing CA
- The normal CA tests apply, except the
basicConstraints extension must be
present.
-setalias
arg
- Set the alias of the certificate, allowing the certificate to be referred
to using a nickname, such as "Steve's Certificate".
-trustout
- Output a trusted certificate (the default if any trust settings are
modified). An ordinary or trusted certificate can be input, but by default
an ordinary certificate is output and any trust settings are
discarded.
The x509 utility can be used to sign
certificates and requests: it can thus behave like a mini CA. The following
are x509 signing options:
-CA
file
- The CA certificate to be used for signing. When this option is present,
x509 behaves like a 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.
This option is normally combined with the
-req option. Without the
-req option, the input is a certificate which
must be self-signed.
-CAcreateserial
- Create the CA serial number file if it does not exist instead of
generating an error. The file will contain the serial number
‘02’ and the certificate being signed will have
‘1’ as its serial number.
-CAform
der |
pem
- The format of the CA certificate file. The default is
pem .
-CAkey
file
- Set the CA private key to sign a certificate with. Otherwise it is assumed
that the CA private key is present in the CA certificate file.
-CAkeyform
der |
pem
- The format of the CA private key. The default is
pem .
-CAserial
file
- Use the serial number in file to sign a certificate.
The file should consist 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.
The default filename consists of the CA certificate file base
name with .srl appended. For example, if the CA
certificate file is called mycacert.pem, it
expects to find a serial number file called
mycacert.srl.
-checkend
arg
- Check whether the certificate expires in the next
arg seconds. If so, exit with return value 1;
otherwise exit with return value 0.
-clrext
- Delete any extensions from a certificate. This option is used when a
certificate is being created from another certificate (for example with
the
-signkey or the -CA
options). Normally, all extensions are retained.
-days
arg
- The number of days to make a certificate valid for. The default is 30
days.
-extensions
section
- The section to add certificate extensions from. If this option is not
specified, the extensions should either be contained in the unnamed
(default) section or the default section should contain a variable called
"extensions" which contains the section to use.
-extfile
file
- File containing certificate extensions to use. If not specified, no
extensions are added to the certificate.
-force_pubkey
key
- Set the public key of the certificate to the public key contained in
key.
-keyform
der |
pem
- The format of the key file used in the
-force_pubkey and -signkey
options.
-new
- Generate a new certificate using the subject given by
-set_subject and signed by
-signkey . If no public key is provided with
-force_pubkey , the resulting certificate is
self-signed. This option cannot be used with -in
or -req .
-req
- Expect a certificate request on input instead of a certificate. This
option cannot be used with
-new .
-set_issuer
name
- The issuer name to use. name must be formatted as
/type0=value0/type1=value1/type2=...; characters may be escaped by
‘\’ (backslash); no spaces are skipped.
-set_serial
n
- The serial number to use. This option can be used with either the
-signkey or -CA options.
If used in conjunction with the -CA option, the
serial number file (as specified by the -CAserial
or -CAcreateserial options) is not used.
The serial number can be decimal or hex (if preceded by
‘0x’). Negative serial numbers can also be specified but
their use is not recommended.
-set_subject
name
- The subject name to use. name must be formatted as
/type0=value0/type1=value1/type2=...; characters may be escaped by
‘\’ (backslash); no spaces are skipped.
-signkey
file
- Self-sign file using the supplied private key.
If the input file is a certificate, it sets the issuer name to
the subject name (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 -days option. Any certificate extensions
are retained unless the -clrext option is
supplied.
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.
-utf8
- Interpret field values read from a terminal or obtained from a
configuration file as UTF-8 strings. By default, they are interpreted as
ASCII.
-x509toreq
- Convert a certificate into a certificate request. The
-signkey option is used to pass the required
private key.
Several commands share a common syntax, as detailed below.
Password arguments, typically specified using
-passin and -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.
pass :password
- The actual password is password. Since the password
is visible to utilities, this form should only be used where security is
not important.
env :var
- Obtain the password from the environment variable
var. Since the environment of other processes is
visible, this option should be used with caution.
file :path
- The first line of path is the password. If the same
path argument is supplied to
-passin and -passout , then
the first line will be used for the input password and the next line for
the output password. path need not refer to a
regular file: it could, for example, refer to a device or named pipe.
fd :number
- Read the password from the file descriptor number.
This can be used to send the data via a pipe, for example.
stdin
- Read the password from standard input.
Input/output formats, typically specified using
-inform and -outform ,
indicate the format being read from or written to. The argument is case
insensitive.
der
- Distinguished Encoding Rules (DER) is a binary format.
net
- Insecure legacy format.
pem
- Privacy Enhanced Mail (PEM) is base64-encoded.
pvk
- Private Key format.
smime
- An SMIME format message.
txt
- Plain ASCII text.
The following environment variables affect the execution of
openssl :
OPENSSL_CONF
- The location of the master configuration file.
- /etc/ssl/
- Default config directory for
openssl .
- /etc/ssl/lib/
- Unused.
- /etc/ssl/private/
- Default private key directory.
- /etc/ssl/openssl.cnf
- Default configuration file for
openssl .
- /etc/ssl/x509v3.cnf
- Default configuration file for
x509
certificates.
T. Dierks and
C. Allen, The TLS Protocol
Version 1.0, RFC 2246,
January 1999.
M. Wahl,
S. Killie, and T. Howes,
Lightweight Directory Access Protocol (v3): UTF-8 String
Representation of Distinguished Names, RFC
2253, December 1997.
B. Kaliski,
PKCS #7: Cryptographic Message Syntax Version 1.5,
RFC 2315, March
1998.
R. Housley,
W. Ford, W. Polk, and
D. Solo, Internet X.509 Public
Key Infrastructure Certificate and CRL Profile, RFC
2459, January 1999.
M. Myers,
R. Ankney, A. Malpani,
S. Galperin, and C. Adams,
X.509 Internet Public Key Infrastructure Online
Certificate Status Protocol – OCSP, RFC
2560, June 1999.
R. Housley,
Cryptographic Message Syntax, RFC
2630, June 1999.
P. Chown,
Advanced Encryption Standard (AES) Ciphersuites for
Transport Layer Security (TLS), RFC 3268,
June 2002.
Visit the GSP FreeBSD Man Page Interface. Output converted with ManDoc.
|