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

Annotation of src/usr.bin/openssl/openssl.1, Revision 1.57

1.57    ! jmc         1: .\" $OpenBSD: openssl.1,v 1.56 2016/08/20 07:56:09 jmc Exp $
1.1       jsing       2: .\" ====================================================================
                      3: .\" Copyright (c) 1998-2002 The OpenSSL Project.  All rights reserved.
                      4: .\"
                      5: .\" Redistribution and use in source and binary forms, with or without
                      6: .\" modification, are permitted provided that the following conditions
                      7: .\" are met:
                      8: .\"
                      9: .\" 1. Redistributions of source code must retain the above copyright
                     10: .\"    notice, this list of conditions and the following disclaimer.
                     11: .\"
                     12: .\" 2. Redistributions in binary form must reproduce the above copyright
                     13: .\"    notice, this list of conditions and the following disclaimer in
                     14: .\"    the documentation and/or other materials provided with the
                     15: .\"    distribution.
                     16: .\"
                     17: .\" 3. All advertising materials mentioning features or use of this
                     18: .\"    software must display the following acknowledgment:
                     19: .\"    "This product includes software developed by the OpenSSL Project
                     20: .\"    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
                     21: .\"
                     22: .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
                     23: .\"    endorse or promote products derived from this software without
                     24: .\"    prior written permission. For written permission, please contact
                     25: .\"    openssl-core@openssl.org.
                     26: .\"
                     27: .\" 5. Products derived from this software may not be called "OpenSSL"
                     28: .\"    nor may "OpenSSL" appear in their names without prior written
                     29: .\"    permission of the OpenSSL Project.
                     30: .\"
                     31: .\" 6. Redistributions of any form whatsoever must retain the following
                     32: .\"    acknowledgment:
                     33: .\"    "This product includes software developed by the OpenSSL Project
                     34: .\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
                     35: .\"
                     36: .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
                     37: .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     38: .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
                     39: .\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
                     40: .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
                     41: .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
                     42: .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
                     43: .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     44: .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
                     45: .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
                     46: .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
                     47: .\" OF THE POSSIBILITY OF SUCH DAMAGE.
                     48: .\" ====================================================================
                     49: .\"
                     50: .\" This product includes cryptographic software written by Eric Young
                     51: .\" (eay@cryptsoft.com).  This product includes software written by Tim
                     52: .\" Hudson (tjh@cryptsoft.com).
                     53: .\"
                     54: .\"
                     55: .\" Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
                     56: .\" All rights reserved.
                     57: .\"
                     58: .\" This package is an SSL implementation written
                     59: .\" by Eric Young (eay@cryptsoft.com).
                     60: .\" The implementation was written so as to conform with Netscapes SSL.
                     61: .\"
                     62: .\" This library is free for commercial and non-commercial use as long as
                     63: .\" the following conditions are aheared to.  The following conditions
                     64: .\" apply to all code found in this distribution, be it the RC4, RSA,
                     65: .\" lhash, DES, etc., code; not just the SSL code.  The SSL documentation
                     66: .\" included with this distribution is covered by the same copyright terms
                     67: .\" except that the holder is Tim Hudson (tjh@cryptsoft.com).
                     68: .\"
                     69: .\" Copyright remains Eric Young's, and as such any Copyright notices in
                     70: .\" the code are not to be removed.
                     71: .\" If this package is used in a product, Eric Young should be given attribution
                     72: .\" as the author of the parts of the library used.
                     73: .\" This can be in the form of a textual message at program startup or
                     74: .\" in documentation (online or textual) provided with the package.
                     75: .\"
                     76: .\" Redistribution and use in source and binary forms, with or without
                     77: .\" modification, are permitted provided that the following conditions
                     78: .\" are met:
                     79: .\" 1. Redistributions of source code must retain the copyright
                     80: .\"    notice, this list of conditions and the following disclaimer.
                     81: .\" 2. Redistributions in binary form must reproduce the above copyright
                     82: .\"    notice, this list of conditions and the following disclaimer in the
                     83: .\"    documentation and/or other materials provided with the distribution.
                     84: .\" 3. All advertising materials mentioning features or use of this software
                     85: .\"    must display the following acknowledgement:
                     86: .\"    "This product includes cryptographic software written by
                     87: .\"     Eric Young (eay@cryptsoft.com)"
                     88: .\"    The word 'cryptographic' can be left out if the rouines from the library
                     89: .\"    being used are not cryptographic related :-).
                     90: .\" 4. If you include any Windows specific code (or a derivative thereof) from
                     91: .\"    the apps directory (application code) you must include an
                     92: .\"    acknowledgement:
                     93: .\"    "This product includes software written by Tim Hudson
                     94: .\"     (tjh@cryptsoft.com)"
                     95: .\"
                     96: .\" THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
                     97: .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     98: .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     99: .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
                    100: .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                    101: .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                    102: .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                    103: .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                    104: .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                    105: .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                    106: .\" SUCH DAMAGE.
                    107: .\"
                    108: .\" The licence and distribution terms for any publically available version or
                    109: .\" derivative of this code cannot be changed.  i.e. this code cannot simply be
                    110: .\" copied and put under another distribution licence
                    111: .\" [including the GNU Public Licence.]
                    112: .\"
                    113: .\" OPENSSL
                    114: .\"
1.57    ! jmc       115: .Dd $Mdocdate: August 20 2016 $
1.1       jsing     116: .Dt OPENSSL 1
                    117: .Os
                    118: .Sh NAME
                    119: .Nm openssl
                    120: .Nd OpenSSL command line tool
                    121: .Sh SYNOPSIS
                    122: .Nm
                    123: .Cm command
                    124: .Op Ar command_opts
                    125: .Op Ar command_args
                    126: .Pp
                    127: .Nm
1.13      bentley   128: .Cm list-standard-commands |
                    129: .Cm list-message-digest-commands |
                    130: .Cm list-cipher-commands |
                    131: .Cm list-cipher-algorithms |
                    132: .Cm list-message-digest-algorithms |
1.1       jsing     133: .Cm list-public-key-algorithms
                    134: .Pp
                    135: .Nm
1.39      jmc       136: .Cm no- Ns Ar command
1.1       jsing     137: .Sh DESCRIPTION
                    138: .Nm OpenSSL
1.31      jmc       139: is a cryptography toolkit implementing the
                    140: Transport Layer Security
1.1       jsing     141: .Pq TLS v1
1.31      jmc       142: network protocol,
                    143: as well as related cryptography standards.
1.1       jsing     144: .Pp
                    145: The
                    146: .Nm
                    147: program is a command line tool for using the various
                    148: cryptography functions of
1.39      jmc       149: .Nm openssl Ns 's
1.33      jmc       150: crypto library from the shell.
1.1       jsing     151: .Pp
                    152: The pseudo-commands
                    153: .Cm list-standard-commands , list-message-digest-commands ,
                    154: and
                    155: .Cm list-cipher-commands
                    156: output a list
                    157: .Pq one entry per line
                    158: of the names of all standard commands, message digest commands,
                    159: or cipher commands, respectively, that are available in the present
                    160: .Nm
                    161: utility.
                    162: .Pp
                    163: The pseudo-commands
                    164: .Cm list-cipher-algorithms
                    165: and
                    166: .Cm list-message-digest-algorithms
                    167: list all cipher and message digest names,
                    168: one entry per line.
                    169: Aliases are listed as:
                    170: .Pp
1.33      jmc       171: .D1 from => to
1.1       jsing     172: .Pp
                    173: The pseudo-command
                    174: .Cm list-public-key-algorithms
                    175: lists all supported public key algorithms.
                    176: .Pp
                    177: The pseudo-command
1.39      jmc       178: .Cm no- Ns Ar command
1.1       jsing     179: tests whether a command of the
                    180: specified name is available.
1.39      jmc       181: If
                    182: .Ar command
                    183: does not exist,
1.1       jsing     184: it returns 0
                    185: and prints
1.39      jmc       186: .Cm no- Ns Ar command ;
1.1       jsing     187: otherwise it returns 1 and prints
1.39      jmc       188: .Ar command .
                    189: In both cases, the output goes to stdout and nothing is printed to stderr.
1.1       jsing     190: Additional command line arguments are always ignored.
                    191: Since for each cipher there is a command of the same name,
                    192: this provides an easy way for shell scripts to test for the
                    193: availability of ciphers in the
                    194: .Nm
                    195: program.
                    196: .Pp
                    197: .Sy Note :
1.39      jmc       198: .Cm no- Ns Ar command
1.1       jsing     199: is not able to detect pseudo-commands such as
                    200: .Cm quit ,
                    201: .Cm list- Ns Ar ... Ns Cm -commands ,
                    202: or
1.39      jmc       203: .Cm no- Ns Ar command
1.1       jsing     204: itself.
                    205: .Sh ASN1PARSE
                    206: .nr nS 1
                    207: .Nm "openssl asn1parse"
                    208: .Op Fl i
                    209: .Op Fl dlimit Ar number
                    210: .Op Fl dump
                    211: .Op Fl genconf Ar file
                    212: .Op Fl genstr Ar str
                    213: .Op Fl in Ar file
1.34      jmc       214: .Op Fl inform Cm der | pem | txt
1.1       jsing     215: .Op Fl length Ar number
                    216: .Op Fl noout
                    217: .Op Fl offset Ar number
                    218: .Op Fl oid Ar file
                    219: .Op Fl out Ar file
                    220: .Op Fl strparse Ar offset
                    221: .nr nS 0
                    222: .Pp
                    223: The
                    224: .Nm asn1parse
                    225: command is a diagnostic utility that can parse ASN.1 structures.
                    226: It can also be used to extract data from ASN.1 formatted data.
                    227: .Pp
                    228: The options are as follows:
                    229: .Bl -tag -width Ds
                    230: .It Fl dlimit Ar number
                    231: Dump the first
                    232: .Ar number
                    233: bytes of unknown data in hex form.
                    234: .It Fl dump
                    235: Dump unknown data in hex form.
                    236: .It Fl genconf Ar file , Fl genstr Ar str
                    237: Generate encoded data based on string
                    238: .Ar str ,
                    239: file
                    240: .Ar file ,
1.34      jmc       241: or both, using the format described in
                    242: .Xr ASN1_generate_nconf 3 .
1.1       jsing     243: If only
                    244: .Ar file
                    245: is present then the string is obtained from the default section
                    246: using the name
                    247: .Dq asn1 .
                    248: The encoded data is passed through the ASN1 parser and printed out as
                    249: though it came from a file;
                    250: the contents can thus be examined and written to a file using the
                    251: .Fl out
                    252: option.
                    253: .It Fl i
1.34      jmc       254: Indent the output according to the
1.1       jsing     255: .Qq depth
                    256: of the structures.
                    257: .It Fl in Ar file
1.41      jmc       258: The input file to read from, or standard input if not specified.
1.34      jmc       259: .It Fl inform Cm der | pem | txt
1.1       jsing     260: The input format.
                    261: .It Fl length Ar number
1.34      jmc       262: Number of bytes to parse; the default is until end of file.
1.1       jsing     263: .It Fl noout
1.46      jmc       264: Do not output the parsed version of the input file.
1.1       jsing     265: .It Fl offset Ar number
1.34      jmc       266: Starting offset to begin parsing; the default is start of file.
1.1       jsing     267: .It Fl oid Ar file
                    268: A file containing additional object identifiers
                    269: .Pq OIDs .
                    270: If an OID
                    271: .Pq object identifier
                    272: is not part of
1.34      jmc       273: .Nm openssl Ns 's
1.1       jsing     274: internal table it will be represented in
                    275: numerical form
                    276: .Pq for example 1.2.3.4 .
1.34      jmc       277: .Pp
1.1       jsing     278: Each line consists of three columns:
                    279: the first column is the OID in numerical format and should be followed by
                    280: whitespace.
                    281: The second column is the
1.34      jmc       282: .Qq short name ,
1.1       jsing     283: which is a single word followed by whitespace.
                    284: The final column is the rest of the line and is the
                    285: .Qq long name .
                    286: .Nm asn1parse
                    287: displays the long name.
1.34      jmc       288: .It Fl out Ar file
                    289: The DER-encoded output file; the default is no encoded output
                    290: (useful when combined with
                    291: .Fl strparse ) .
                    292: .It Fl strparse Ar offset
                    293: Parse the content octets of the ASN.1 object starting at
                    294: .Ar offset .
                    295: This option can be used multiple times to
                    296: .Qq drill down
                    297: into a nested structure.
                    298: .El
1.1       jsing     299: .Sh CA
                    300: .nr nS 1
                    301: .Nm "openssl ca"
                    302: .Op Fl batch
                    303: .Op Fl cert Ar file
                    304: .Op Fl config Ar file
                    305: .Op Fl crl_CA_compromise Ar time
                    306: .Op Fl crl_compromise Ar time
                    307: .Op Fl crl_hold Ar instruction
                    308: .Op Fl crl_reason Ar reason
                    309: .Op Fl crldays Ar days
                    310: .Op Fl crlexts Ar section
                    311: .Op Fl crlhours Ar hours
                    312: .Op Fl days Ar arg
                    313: .Op Fl enddate Ar date
                    314: .Op Fl extensions Ar section
                    315: .Op Fl extfile Ar section
                    316: .Op Fl gencrl
                    317: .Op Fl in Ar file
                    318: .Op Fl infiles
                    319: .Op Fl key Ar keyfile
                    320: .Op Fl keyfile Ar arg
1.22      bcook     321: .Op Fl keyform Ar PEM
1.1       jsing     322: .Op Fl md Ar arg
                    323: .Op Fl msie_hack
                    324: .Op Fl name Ar section
                    325: .Op Fl noemailDN
                    326: .Op Fl notext
                    327: .Op Fl out Ar file
                    328: .Op Fl outdir Ar dir
                    329: .Op Fl passin Ar arg
                    330: .Op Fl policy Ar arg
                    331: .Op Fl preserveDN
                    332: .Op Fl revoke Ar file
                    333: .Op Fl spkac Ar file
                    334: .Op Fl ss_cert Ar file
                    335: .Op Fl startdate Ar date
                    336: .Op Fl status Ar serial
                    337: .Op Fl subj Ar arg
                    338: .Op Fl updatedb
                    339: .Op Fl verbose
                    340: .nr nS 0
                    341: .Pp
                    342: The
                    343: .Nm ca
1.35      jmc       344: command is a minimal certificate authority (CA) application.
1.1       jsing     345: It can be used to sign certificate requests in a variety of forms
1.35      jmc       346: and generate certificate revocation lists (CRLs).
1.1       jsing     347: It also maintains a text database of issued certificates and their status.
                    348: .Pp
1.35      jmc       349: The options relevant to CAs are as follows:
1.1       jsing     350: .Bl -tag -width "XXXX"
                    351: .It Fl batch
1.41      jmc       352: Batch mode.
1.1       jsing     353: In this mode no questions will be asked
                    354: and all certificates will be certified automatically.
                    355: .It Fl cert Ar file
                    356: The CA certificate file.
                    357: .It Fl config Ar file
                    358: Specifies the configuration file to use.
                    359: .It Fl days Ar arg
                    360: The number of days to certify the certificate for.
                    361: .It Fl enddate Ar date
1.41      jmc       362: Set the expiry date.
1.1       jsing     363: The format of the date is YYMMDDHHMMSSZ
                    364: .Pq the same as an ASN1 UTCTime structure .
                    365: .It Fl extensions Ar section
                    366: The section of the configuration file containing certificate extensions
                    367: to be added when a certificate is issued (defaults to
1.35      jmc       368: .Cm x509_extensions
1.1       jsing     369: unless the
                    370: .Fl extfile
                    371: option is used).
                    372: If no extension section is present, a V1 certificate is created.
                    373: If the extension section is present
                    374: .Pq even if it is empty ,
                    375: then a V3 certificate is created.
                    376: .It Fl extfile Ar file
                    377: An additional configuration
                    378: .Ar file
                    379: to read certificate extensions from
                    380: (using the default section unless the
                    381: .Fl extensions
                    382: option is also used).
                    383: .It Fl in Ar file
                    384: An input
                    385: .Ar file
                    386: containing a single certificate request to be signed by the CA.
                    387: .It Fl infiles
                    388: If present, this should be the last option; all subsequent arguments
                    389: are assumed to be the names of files containing certificate requests.
                    390: .It Fl key Ar keyfile
                    391: The password used to encrypt the private key.
1.35      jmc       392: Since on some systems the command line arguments are visible,
                    393: this option should be used with caution.
1.1       jsing     394: .It Fl keyfile Ar file
                    395: The private key to sign requests with.
1.22      bcook     396: .It Fl keyform Ar PEM
1.1       jsing     397: Private key file format.
                    398: .It Fl md Ar alg
                    399: The message digest to use.
                    400: Possible values include
                    401: .Ar md5
                    402: and
                    403: .Ar sha1 .
                    404: This option also applies to CRLs.
                    405: .It Fl msie_hack
                    406: This is a legacy option to make
                    407: .Nm ca
                    408: work with very old versions of the IE certificate enrollment control
                    409: .Qq certenr3 .
                    410: It used UniversalStrings for almost everything.
                    411: Since the old control has various security bugs,
                    412: its use is strongly discouraged.
                    413: The newer control
                    414: .Qq Xenroll
                    415: does not need this option.
                    416: .It Fl name Ar section
                    417: Specifies the configuration file
                    418: .Ar section
                    419: to use (overrides
                    420: .Cm default_ca
                    421: in the
                    422: .Cm ca
                    423: section).
                    424: .It Fl noemailDN
                    425: The DN of a certificate can contain the EMAIL field if present in the
1.30      mmcc      426: request DN, however it is good policy just having the email set into
1.1       jsing     427: the
1.35      jmc       428: .Cm altName
1.1       jsing     429: extension of the certificate.
                    430: When this option is set, the EMAIL field is removed from the certificate's
                    431: subject and set only in the, eventually present, extensions.
                    432: The
                    433: .Ar email_in_dn
                    434: keyword can be used in the configuration file to enable this behaviour.
                    435: .It Fl notext
                    436: Don't output the text form of a certificate to the output file.
                    437: .It Fl out Ar file
                    438: The output file to output certificates to.
                    439: The default is standard output.
                    440: The certificate details will also be printed out to this file.
                    441: .It Fl outdir Ar directory
                    442: The
                    443: .Ar directory
                    444: to output certificates to.
                    445: The certificate will be written to a file consisting of the
                    446: serial number in hex with
                    447: .Qq .pem
                    448: appended.
                    449: .It Fl passin Ar arg
                    450: The key password source.
                    451: .It Fl policy Ar arg
1.41      jmc       452: Define the CA
1.1       jsing     453: .Qq policy
                    454: to use.
1.35      jmc       455: The policy section in the configuration file
                    456: consists of a set of variables corresponding to certificate DN fields.
                    457: The values may be one of
                    458: .Qq match
                    459: (the value must match the same field in the CA certificate),
                    460: .Qq supplied
                    461: (the value must be present), or
                    462: .Qq optional
                    463: (the value may be present).
                    464: Any fields not mentioned in the policy section
                    465: are silently deleted, unless the
                    466: .Fl preserveDN
                    467: option is set,
                    468: but this can be regarded more of a quirk than intended behaviour.
1.1       jsing     469: .It Fl preserveDN
                    470: Normally, the DN order of a certificate is the same as the order of the
                    471: fields in the relevant policy section.
                    472: When this option is set, the order is the same as the request.
                    473: This is largely for compatibility with the older IE enrollment control
                    474: which would only accept certificates if their DNs matched the order of the
                    475: request.
                    476: This is not needed for Xenroll.
                    477: .It Fl spkac Ar file
                    478: A file containing a single Netscape signed public key and challenge,
                    479: and additional field values to be signed by the CA.
1.35      jmc       480: This will usually come from the
                    481: KEYGEN tag in an HTML form to create a new private key.
                    482: It is, however, possible to create SPKACs using the
                    483: .Nm spkac
                    484: utility.
                    485: .Pp
                    486: The file should contain the variable SPKAC set to the value of
                    487: the SPKAC and also the required DN components as name value pairs.
                    488: If it's necessary to include the same component twice,
                    489: then it can be preceded by a number and a
                    490: .Sq \&. .
1.1       jsing     491: .It Fl ss_cert Ar file
                    492: A single self-signed certificate to be signed by the CA.
                    493: .It Fl startdate Ar date
1.41      jmc       494: Set the start date.
1.1       jsing     495: The format of the date is YYMMDDHHMMSSZ
                    496: .Pq the same as an ASN1 UTCTime structure .
                    497: .It Fl status Ar serial
1.35      jmc       498: Show the status of the certificate with serial number
1.1       jsing     499: .Ar serial .
                    500: .It Fl updatedb
                    501: Update database for expired certificates.
                    502: .It Fl verbose
1.41      jmc       503: Print extra details about the operations being performed.
1.1       jsing     504: .El
1.35      jmc       505: .Pp
                    506: The options relevant to CRLs are as follows:
1.1       jsing     507: .Bl -tag -width "XXXX"
                    508: .It Fl crl_CA_compromise Ar time
                    509: This is the same as
                    510: .Fl crl_compromise ,
                    511: except the revocation reason is set to CACompromise.
                    512: .It Fl crl_compromise Ar time
1.41      jmc       513: Set the revocation reason to keyCompromise and the compromise time to
1.1       jsing     514: .Ar time .
                    515: .Ar time
                    516: should be in GeneralizedTime format, i.e. YYYYMMDDHHMMSSZ.
                    517: .It Fl crl_hold Ar instruction
1.41      jmc       518: Set the CRL revocation reason code to certificateHold and the hold
1.1       jsing     519: instruction to
                    520: .Ar instruction
                    521: which must be an OID.
                    522: Although any OID can be used, only holdInstructionNone
                    523: (the use of which is discouraged by RFC 2459), holdInstructionCallIssuer or
                    524: holdInstructionReject will normally be used.
                    525: .It Fl crl_reason Ar reason
                    526: Revocation reason, where
                    527: .Ar reason
                    528: is one of:
                    529: unspecified, keyCompromise, CACompromise, affiliationChanged, superseded,
                    530: cessationOfOperation, certificateHold or removeFromCRL.
                    531: The matching of
                    532: .Ar reason
                    533: is case insensitive.
                    534: Setting any revocation reason will make the CRL v2.
                    535: In practice, removeFromCRL is not particularly useful because it is only used
                    536: in delta CRLs which are not currently implemented.
                    537: .It Fl crldays Ar num
                    538: The number of days before the next CRL is due.
                    539: This is the days from now to place in the CRL
1.35      jmc       540: .Cm nextUpdate
1.1       jsing     541: field.
                    542: .It Fl crlexts Ar section
                    543: The
                    544: .Ar section
                    545: of the configuration file containing CRL extensions to include.
                    546: If no CRL extension section is present then a V1 CRL is created;
                    547: if the CRL extension section is present
                    548: .Pq even if it is empty
                    549: then a V2 CRL is created.
                    550: The CRL extensions specified are CRL extensions and
                    551: .Em not
                    552: CRL entry extensions.
                    553: It should be noted that some software
                    554: .Pq for example Netscape
                    555: can't handle V2 CRLs.
                    556: .It Fl crlhours Ar num
                    557: The number of hours before the next CRL is due.
                    558: .It Fl gencrl
1.41      jmc       559: Generate a CRL based on information in the index file.
1.1       jsing     560: .It Fl revoke Ar file
                    561: A
                    562: .Ar file
                    563: containing a certificate to revoke.
                    564: .It Fl subj Ar arg
                    565: Supersedes the subject name given in the request.
                    566: The
                    567: .Ar arg
                    568: must be formatted as
                    569: .Ar /type0=value0/type1=value1/type2=... ;
                    570: characters may be escaped by
                    571: .Sq \e
                    572: .Pq backslash ,
                    573: no spaces are skipped.
                    574: .El
                    575: .Pp
1.35      jmc       576: Many of the options can be set in the
                    577: .Cm ca
                    578: section of the configuration file
                    579: (or in the default section of the configuration file),
                    580: specified using
                    581: .Cm default_ca
                    582: or
                    583: .Fl name .
                    584: The options
                    585: .Cm preserve
                    586: and
                    587: .Cm msie_hack
                    588: are read directly from the
                    589: .Cm ca
                    590: section.
1.1       jsing     591: .Pp
                    592: Many of the configuration file options are identical to command line
                    593: options.
                    594: Where the option is present in the configuration file and the command line,
                    595: the command line value is used.
                    596: Where an option is described as mandatory, then it must be present in
                    597: the configuration file or the command line equivalent
                    598: .Pq if any
                    599: used.
                    600: .Bl -tag -width "XXXX"
1.35      jmc       601: .It Cm certificate
1.1       jsing     602: The same as
                    603: .Fl cert .
                    604: It gives the file containing the CA certificate.
                    605: Mandatory.
1.35      jmc       606: .It Cm copy_extensions
1.1       jsing     607: Determines how extensions in certificate requests should be handled.
                    608: If set to
1.35      jmc       609: .Cm none
1.1       jsing     610: or this option is not present, then extensions are
                    611: ignored and not copied to the certificate.
                    612: If set to
1.35      jmc       613: .Cm copy ,
1.1       jsing     614: then any extensions present in the request that are not already present
                    615: are copied to the certificate.
                    616: If set to
1.35      jmc       617: .Cm copyall ,
1.1       jsing     618: then all extensions in the request are copied to the certificate:
                    619: if the extension is already present in the certificate it is deleted first.
1.35      jmc       620: .Pp
                    621: The
                    622: .Cm copy_extensions
                    623: option should be used with caution.
                    624: If care is not taken, it can be a security risk.
                    625: For example, if a certificate request contains a
                    626: .Cm basicConstraints
                    627: extension with CA:TRUE and the
                    628: .Cm copy_extensions
                    629: value is set to
                    630: .Cm copyall
                    631: and the user does not spot
                    632: this when the certificate is displayed, then this will hand the requestor
                    633: a valid CA certificate.
                    634: .Pp
                    635: This situation can be avoided by setting
                    636: .Cm copy_extensions
                    637: to
                    638: .Cm copy
                    639: and including
                    640: .Cm basicConstraints
                    641: with CA:FALSE in the configuration file.
                    642: Then if the request contains a
                    643: .Cm basicConstraints
                    644: extension, it will be ignored.
1.1       jsing     645: .Pp
                    646: The main use of this option is to allow a certificate request to supply
                    647: values for certain extensions such as
1.35      jmc       648: .Cm subjectAltName .
                    649: .It Cm crl_extensions
1.1       jsing     650: The same as
                    651: .Fl crlexts .
1.35      jmc       652: .It Cm crlnumber
1.1       jsing     653: A text file containing the next CRL number to use in hex.
                    654: The CRL number will be inserted in the CRLs only if this file exists.
                    655: If this file is present, it must contain a valid CRL number.
1.35      jmc       656: .It Cm database
1.1       jsing     657: The text database file to use.
                    658: Mandatory.
                    659: This file must be present, though initially it will be empty.
1.35      jmc       660: .It Cm default_crl_hours , default_crl_days
1.1       jsing     661: The same as the
                    662: .Fl crlhours
                    663: and
                    664: .Fl crldays
                    665: options.
                    666: These will only be used if neither command line option is present.
                    667: At least one of these must be present to generate a CRL.
1.35      jmc       668: .It Cm default_days
1.1       jsing     669: The same as the
                    670: .Fl days
                    671: option.
                    672: The number of days to certify a certificate for.
1.35      jmc       673: .It Cm default_enddate
1.1       jsing     674: The same as the
                    675: .Fl enddate
                    676: option.
                    677: Either this option or
1.35      jmc       678: .Cm default_days
1.1       jsing     679: .Pq or the command line equivalents
                    680: must be present.
1.35      jmc       681: .It Cm default_md
1.1       jsing     682: The same as the
                    683: .Fl md
                    684: option.
                    685: The message digest to use.
                    686: Mandatory.
1.35      jmc       687: .It Cm default_startdate
1.1       jsing     688: The same as the
                    689: .Fl startdate
                    690: option.
                    691: The start date to certify a certificate for.
                    692: If not set, the current time is used.
1.35      jmc       693: .It Cm email_in_dn
1.1       jsing     694: The same as
                    695: .Fl noemailDN .
                    696: If the EMAIL field is to be removed from the DN of the certificate,
                    697: simply set this to
                    698: .Qq no .
                    699: If not present, the default is to allow for the EMAIL field in the
                    700: certificate's DN.
1.35      jmc       701: .It Cm msie_hack
1.1       jsing     702: The same as
                    703: .Fl msie_hack .
1.35      jmc       704: .It Cm name_opt , cert_opt
1.1       jsing     705: These options allow the format used to display the certificate details
                    706: when asking the user to confirm signing.
                    707: All the options supported by the
                    708: .Nm x509
                    709: utilities'
                    710: .Fl nameopt
                    711: and
                    712: .Fl certopt
                    713: switches can be used here, except that
1.35      jmc       714: .Cm no_signame
1.1       jsing     715: and
1.35      jmc       716: .Cm no_sigdump
1.1       jsing     717: are permanently set and cannot be disabled
                    718: (this is because the certificate signature cannot be displayed because
                    719: the certificate has not been signed at this point).
                    720: .Pp
                    721: For convenience, the value
1.35      jmc       722: .Cm ca_default
1.1       jsing     723: is accepted by both to produce a reasonable output.
                    724: .Pp
                    725: If neither option is present, the format used in earlier versions of
1.35      jmc       726: .Nm openssl
1.1       jsing     727: is used.
                    728: Use of the old format is
                    729: .Em strongly
                    730: discouraged because it only displays fields mentioned in the
1.35      jmc       731: .Cm policy
1.1       jsing     732: section,
                    733: mishandles multicharacter string types and does not display extensions.
1.35      jmc       734: .It Cm new_certs_dir
1.1       jsing     735: The same as the
                    736: .Fl outdir
                    737: command line option.
                    738: It specifies the directory where new certificates will be placed.
                    739: Mandatory.
1.35      jmc       740: .It Cm oid_file
1.1       jsing     741: This specifies a file containing additional object identifiers.
                    742: Each line of the file should consist of the numerical form of the
                    743: object identifier followed by whitespace, then the short name followed
                    744: by whitespace and finally the long name.
1.35      jmc       745: .It Cm oid_section
1.1       jsing     746: This specifies a section in the configuration file containing extra
                    747: object identifiers.
                    748: Each line should consist of the short name of the object identifier
                    749: followed by
                    750: .Sq =
                    751: and the numerical form.
                    752: The short and long names are the same when this option is used.
1.35      jmc       753: .It Cm policy
1.1       jsing     754: The same as
                    755: .Fl policy .
                    756: Mandatory.
1.35      jmc       757: .It Cm preserve
1.1       jsing     758: The same as
                    759: .Fl preserveDN .
1.35      jmc       760: .It Cm private_key
1.1       jsing     761: Same as the
                    762: .Fl keyfile
                    763: option.
                    764: The file containing the CA private key.
                    765: Mandatory.
1.35      jmc       766: .It Cm serial
1.1       jsing     767: A text file containing the next serial number to use in hex.
                    768: Mandatory.
                    769: This file must be present and contain a valid serial number.
1.35      jmc       770: .It Cm unique_subject
1.1       jsing     771: If the value
1.35      jmc       772: .Cm yes
1.1       jsing     773: is given, the valid certificate entries in the
                    774: database must have unique subjects.
                    775: If the value
1.35      jmc       776: .Cm no
1.1       jsing     777: is given,
                    778: several valid certificate entries may have the exact same subject.
                    779: The default value is
1.35      jmc       780: .Cm yes .
                    781: .It Cm x509_extensions
1.1       jsing     782: The same as
                    783: .Fl extensions .
                    784: .El
                    785: .Sh CIPHERS
                    786: .Nm openssl ciphers
                    787: .Op Fl hVv
1.18      jmc       788: .Op Fl tls1
1.1       jsing     789: .Op Ar cipherlist
                    790: .Pp
                    791: The
                    792: .Nm ciphers
                    793: command converts
1.36      jmc       794: .Nm openssl
1.1       jsing     795: cipher lists into ordered SSL cipher preference lists.
1.41      jmc       796: It can be used as a way to determine the appropriate cipher list.
1.1       jsing     797: .Pp
                    798: The options are as follows:
                    799: .Bl -tag -width Ds
                    800: .It Fl h , \&?
                    801: Print a brief usage message.
                    802: .It Fl tls1
                    803: Only include TLS v1 ciphers.
                    804: .It Fl V
1.36      jmc       805: Verbose.
                    806: List ciphers with a complete description of protocol version,
                    807: key exchange, authentication, encryption and mac algorithms,
                    808: any key size restrictions,
                    809: and cipher suite codes (hex format).
                    810: .It Fl v
1.1       jsing     811: Like
1.36      jmc       812: .Fl V ,
                    813: but without cipher suite codes.
1.1       jsing     814: .It Ar cipherlist
                    815: A cipher list to convert to a cipher preference list.
                    816: If it is not included, the default cipher list will be used.
1.36      jmc       817: .Pp
                    818: The cipher list consists of one or more cipher strings
1.1       jsing     819: separated by colons.
                    820: Commas or spaces are also acceptable separators, but colons are normally used.
                    821: .Pp
1.36      jmc       822: The actual cipher string can take several different forms:
1.1       jsing     823: .Pp
1.36      jmc       824: It can consist of a single cipher suite, such as RC4-SHA.
1.1       jsing     825: .Pp
                    826: It can represent a list of cipher suites containing a certain algorithm,
                    827: or cipher suites of a certain type.
1.36      jmc       828: For example SHA1 represents all cipher suites using the digest algorithm SHA1.
                    829: .Pp
                    830: Lists of cipher suites can be combined in a single cipher string using the
1.1       jsing     831: .Sq +
1.36      jmc       832: character
                    833: (logical AND operation).
                    834: For example, SHA1+DES represents all cipher suites
                    835: containing the SHA1 and DES algorithms.
1.1       jsing     836: .Pp
                    837: Each cipher string can be optionally preceded by the characters
                    838: .Sq \&! ,
                    839: .Sq - ,
                    840: or
                    841: .Sq + .
                    842: If
                    843: .Sq !\&
                    844: is used, then the ciphers are permanently deleted from the list.
                    845: The ciphers deleted can never reappear in the list even if they are
                    846: explicitly stated.
                    847: If
                    848: .Sq -
                    849: is used, then the ciphers are deleted from the list, but some or
                    850: all of the ciphers can be added again by later options.
                    851: If
                    852: .Sq +
                    853: is used, then the ciphers are moved to the end of the list.
                    854: This option doesn't add any new ciphers, it just moves matching existing ones.
                    855: .Pp
                    856: If none of these characters is present, the string is just interpreted
                    857: as a list of ciphers to be appended to the current preference list.
                    858: If the list includes any ciphers already present, they will be ignored;
                    859: that is, they will not be moved to the end of the list.
                    860: .Pp
                    861: Additionally, the cipher string
1.36      jmc       862: .Cm @STRENGTH
1.1       jsing     863: can be used at any point to sort the current cipher list in order of
                    864: encryption algorithm key length.
1.36      jmc       865: .El
                    866: .Pp
1.1       jsing     867: The following is a list of all permitted cipher strings and their meanings.
                    868: .Bl -tag -width "XXXX"
1.36      jmc       869: .It Cm DEFAULT
1.1       jsing     870: The default cipher list.
                    871: This is determined at compile time and is currently
1.36      jmc       872: .Cm ALL:!aNULL:!eNULL:!SSLv2 .
                    873: This must be the first cipher string specified.
                    874: .It Cm COMPLEMENTOFDEFAULT
1.1       jsing     875: The ciphers included in
1.36      jmc       876: .Cm ALL ,
1.1       jsing     877: but not enabled by default.
                    878: Currently this is
1.36      jmc       879: .Cm ADH .
1.1       jsing     880: Note that this rule does not cover
1.36      jmc       881: .Cm eNULL ,
1.1       jsing     882: which is not included by
1.36      jmc       883: .Cm ALL
1.1       jsing     884: (use
1.36      jmc       885: .Cm COMPLEMENTOFALL
1.1       jsing     886: if necessary).
1.36      jmc       887: .It Cm ALL
1.1       jsing     888: All cipher suites except the
1.36      jmc       889: .Cm eNULL
                    890: ciphers, which must be explicitly enabled.
                    891: .It Cm COMPLEMENTOFALL
1.1       jsing     892: The cipher suites not enabled by
1.36      jmc       893: .Cm ALL ,
1.1       jsing     894: currently being
1.36      jmc       895: .Cm eNULL .
                    896: .It Cm HIGH
1.1       jsing     897: .Qq High
                    898: encryption cipher suites.
                    899: This currently means those with key lengths larger than 128 bits.
1.36      jmc       900: .It Cm MEDIUM
1.1       jsing     901: .Qq Medium
                    902: encryption cipher suites, currently those using 128-bit encryption.
1.36      jmc       903: .It Cm LOW
1.1       jsing     904: .Qq Low
                    905: encryption cipher suites, currently those using 64- or 56-bit encryption
1.9       lteo      906: algorithms.
1.36      jmc       907: .It Cm eNULL , NULL
1.1       jsing     908: The
                    909: .Qq NULL
                    910: ciphers; that is, those offering no encryption.
                    911: Because these offer no encryption at all and are a security risk,
                    912: they are disabled unless explicitly included.
1.36      jmc       913: .It Cm aNULL
1.1       jsing     914: The cipher suites offering no authentication.
                    915: This is currently the anonymous DH algorithms.
                    916: These cipher suites are vulnerable to a
                    917: .Qq man in the middle
                    918: attack, so their use is normally discouraged.
1.36      jmc       919: .It Cm kRSA , RSA
1.1       jsing     920: Cipher suites using RSA key exchange.
1.36      jmc       921: .It Cm kEDH
1.1       jsing     922: Cipher suites using ephemeral DH key agreement.
1.36      jmc       923: .It Cm aRSA
1.1       jsing     924: Cipher suites using RSA authentication, i.e. the certificates carry RSA keys.
1.36      jmc       925: .It Cm aDSS , DSS
1.1       jsing     926: Cipher suites using DSS authentication, i.e. the certificates carry DSS keys.
1.36      jmc       927: .It Cm TLSv1
1.18      jmc       928: TLS v1.0 cipher suites.
1.36      jmc       929: .It Cm DH
1.1       jsing     930: Cipher suites using DH, including anonymous DH.
1.36      jmc       931: .It Cm ADH
1.1       jsing     932: Anonymous DH cipher suites.
1.36      jmc       933: .It Cm AES
1.1       jsing     934: Cipher suites using AES.
1.36      jmc       935: .It Cm 3DES
1.1       jsing     936: Cipher suites using triple DES.
1.36      jmc       937: .It Cm DES
1.1       jsing     938: Cipher suites using DES
                    939: .Pq not triple DES .
1.36      jmc       940: .It Cm RC4
1.1       jsing     941: Cipher suites using RC4.
1.36      jmc       942: .It Cm CAMELLIA
1.9       lteo      943: Cipher suites using Camellia.
1.36      jmc       944: .It Cm CHACHA20
1.9       lteo      945: Cipher suites using ChaCha20.
1.36      jmc       946: .It Cm IDEA
1.9       lteo      947: Cipher suites using IDEA.
1.36      jmc       948: .It Cm MD5
1.1       jsing     949: Cipher suites using MD5.
1.36      jmc       950: .It Cm SHA1 , SHA
1.1       jsing     951: Cipher suites using SHA1.
                    952: .El
                    953: .Sh CRL
                    954: .nr nS 1
                    955: .Nm "openssl crl"
                    956: .Op Fl CAfile Ar file
                    957: .Op Fl CApath Ar dir
                    958: .Op Fl fingerprint
                    959: .Op Fl hash
                    960: .Op Fl in Ar file
1.38      jmc       961: .Op Fl inform Cm der | pem
1.1       jsing     962: .Op Fl issuer
                    963: .Op Fl lastupdate
                    964: .Op Fl nextupdate
                    965: .Op Fl noout
                    966: .Op Fl out Ar file
1.38      jmc       967: .Op Fl outform Cm der | pem
1.1       jsing     968: .Op Fl text
                    969: .nr nS 0
                    970: .Pp
                    971: The
                    972: .Nm crl
                    973: command processes CRL files in DER or PEM format.
1.37      jmc       974: The PEM CRL format uses the header and footer lines:
                    975: .Bd -unfilled -offset indent
                    976: -----BEGIN X509 CRL-----
                    977: -----END X509 CRL-----
                    978: .Ed
                    979: .Pp
1.1       jsing     980: The options are as follows:
                    981: .Bl -tag -width Ds
                    982: .It Fl CAfile Ar file
                    983: Verify the signature on a CRL by looking up the issuing certificate in
                    984: .Ar file .
                    985: .It Fl CApath Ar directory
                    986: Verify the signature on a CRL by looking up the issuing certificate in
                    987: .Ar dir .
                    988: This directory must be a standard certificate directory,
                    989: i.e. a hash of each subject name (using
                    990: .Cm x509 Fl hash )
                    991: should be linked to each certificate.
                    992: .It Fl fingerprint
                    993: Print the CRL fingerprint.
                    994: .It Fl hash
                    995: Output a hash of the issuer name.
                    996: This can be used to look up CRLs in a directory by issuer name.
                    997: .It Fl in Ar file
1.37      jmc       998: The input file to read from, or standard input if not specified.
1.38      jmc       999: .It Fl inform Cm der | pem
1.37      jmc      1000: The input format.
1.1       jsing    1001: .It Fl issuer
                   1002: Output the issuer name.
                   1003: .It Fl lastupdate
                   1004: Output the
1.37      jmc      1005: .Cm lastUpdate
1.1       jsing    1006: field.
                   1007: .It Fl nextupdate
                   1008: Output the
1.37      jmc      1009: .Cm nextUpdate
1.1       jsing    1010: field.
                   1011: .It Fl noout
1.46      jmc      1012: Do not output the encoded version of the CRL.
1.1       jsing    1013: .It Fl out Ar file
1.37      jmc      1014: The output file to write to, or standard output if not specified.
1.38      jmc      1015: .It Fl outform Cm der | pem
1.37      jmc      1016: The output format.
1.1       jsing    1017: .It Fl text
1.48      jmc      1018: Print the CRL in text form.
1.1       jsing    1019: .El
                   1020: .Sh CRL2PKCS7
                   1021: .nr nS 1
                   1022: .Nm "openssl crl2pkcs7"
                   1023: .Op Fl certfile Ar file
                   1024: .Op Fl in Ar file
1.40      jmc      1025: .Op Fl inform Cm der | pem
1.1       jsing    1026: .Op Fl nocrl
                   1027: .Op Fl out Ar file
1.40      jmc      1028: .Op Fl outform Cm der | pem
1.1       jsing    1029: .nr nS 0
                   1030: .Pp
                   1031: The
                   1032: .Nm crl2pkcs7
                   1033: command takes an optional CRL and one or more
                   1034: certificates and converts them into a PKCS#7 degenerate
                   1035: .Qq certificates only
                   1036: structure.
                   1037: .Pp
                   1038: The options are as follows:
                   1039: .Bl -tag -width Ds
                   1040: .It Fl certfile Ar file
1.40      jmc      1041: Add the certificates in PEM
1.1       jsing    1042: .Ar file
1.40      jmc      1043: to the PKCS#7 structure.
                   1044: This option can be used more than once
                   1045: to read certificates from multiple files.
1.1       jsing    1046: .It Fl in Ar file
1.40      jmc      1047: Read the CRL from
                   1048: .Ar file ,
                   1049: or standard input if not specified.
                   1050: .It Fl inform Cm der | pem
                   1051: Specify the CRL input format.
1.1       jsing    1052: .It Fl nocrl
                   1053: Normally, a CRL is included in the output file.
                   1054: With this option, no CRL is
                   1055: included in the output file and a CRL is not read from the input file.
                   1056: .It Fl out Ar file
1.40      jmc      1057: Write the PKCS#7 structure to
                   1058: .Ar file ,
                   1059: or standard output if not specified.
                   1060: .It Fl outform Cm der | pem
                   1061: Specify the PKCS#7 structure output format.
1.1       jsing    1062: .El
                   1063: .Sh DGST
                   1064: .nr nS 1
                   1065: .Nm "openssl dgst"
1.43      jmc      1066: .Op Fl cd
1.1       jsing    1067: .Op Fl binary
1.43      jmc      1068: .Op Fl Ar digest
1.1       jsing    1069: .Op Fl hex
                   1070: .Op Fl hmac Ar key
1.43      jmc      1071: .Op Fl keyform Cm pem
1.1       jsing    1072: .Op Fl mac Ar algorithm
                   1073: .Op Fl macopt Ar nm : Ns Ar v
                   1074: .Op Fl out Ar file
                   1075: .Op Fl passin Ar arg
                   1076: .Op Fl prverify Ar file
                   1077: .Op Fl sign Ar file
                   1078: .Op Fl signature Ar file
                   1079: .Op Fl sigopt Ar nm : Ns Ar v
                   1080: .Op Fl verify Ar file
                   1081: .Op Ar
                   1082: .nr nS 0
                   1083: .Pp
                   1084: The digest functions output the message digest of a supplied
                   1085: .Ar file
                   1086: or
                   1087: .Ar files
                   1088: in hexadecimal form.
                   1089: They can also be used for digital signing and verification.
                   1090: .Pp
                   1091: The options are as follows:
                   1092: .Bl -tag -width Ds
                   1093: .It Fl binary
                   1094: Output the digest or signature in binary form.
                   1095: .It Fl c
1.48      jmc      1096: Print the digest in two-digit groups separated by colons.
1.1       jsing    1097: .It Fl d
1.48      jmc      1098: Print BIO debugging information.
1.43      jmc      1099: .It Fl Ar digest
                   1100: Use the specified message
                   1101: .Ar digest .
                   1102: The default is MD5.
                   1103: The available digests can be displayed using
                   1104: .Nm openssl
                   1105: .Cm list-message-digest-commands .
                   1106: The following are equivalent:
                   1107: .Nm openssl dgst
                   1108: .Fl md5
                   1109: and
                   1110: .Nm openssl
                   1111: .Cm md5 .
1.1       jsing    1112: .It Fl hex
                   1113: Digest is to be output as a hex dump.
                   1114: This is the default case for a
                   1115: .Qq normal
                   1116: digest as opposed to a digital signature.
                   1117: .It Fl hmac Ar key
                   1118: Create a hashed MAC using
                   1119: .Ar key .
1.43      jmc      1120: .It Fl keyform Cm pem
1.1       jsing    1121: Specifies the key format to sign the digest with.
                   1122: .It Fl mac Ar algorithm
                   1123: Create a keyed Message Authentication Code (MAC).
                   1124: The most popular MAC algorithm is HMAC (hash-based MAC),
                   1125: but there are other MAC algorithms which are not based on hash.
                   1126: MAC keys and other options should be set via the
                   1127: .Fl macopt
                   1128: parameter.
                   1129: .It Fl macopt Ar nm : Ns Ar v
                   1130: Passes options to the MAC algorithm, specified by
                   1131: .Fl mac .
                   1132: The following options are supported by HMAC:
                   1133: .Bl -tag -width Ds
1.43      jmc      1134: .It Cm key : Ns Ar string
1.1       jsing    1135: Specifies the MAC key as an alphanumeric string
                   1136: (use if the key contain printable characters only).
                   1137: String length must conform to any restrictions of the MAC algorithm.
1.43      jmc      1138: .It Cm hexkey : Ns Ar string
1.1       jsing    1139: Specifies the MAC key in hexadecimal form (two hex digits per byte).
                   1140: Key length must conform to any restrictions of the MAC algorithm.
                   1141: .El
                   1142: .It Fl out Ar file
1.43      jmc      1143: The output file to write to,
                   1144: or standard output if not specified.
1.1       jsing    1145: .It Fl passin Ar arg
                   1146: The key password source.
                   1147: .It Fl prverify Ar file
                   1148: Verify the signature using the private key in
                   1149: .Ar file .
                   1150: The output is either
                   1151: .Qq Verification OK
                   1152: or
                   1153: .Qq Verification Failure .
                   1154: .It Fl sign Ar file
                   1155: Digitally sign the digest using the private key in
                   1156: .Ar file .
                   1157: .It Fl signature Ar file
                   1158: The actual signature to verify.
                   1159: .It Fl sigopt Ar nm : Ns Ar v
                   1160: Pass options to the signature algorithm during sign or verify operations.
                   1161: The names and values of these options are algorithm-specific.
                   1162: .It Fl verify Ar file
                   1163: Verify the signature using the public key in
                   1164: .Ar file .
                   1165: The output is either
                   1166: .Qq Verification OK
                   1167: or
                   1168: .Qq Verification Failure .
                   1169: .It Ar
                   1170: File or files to digest.
                   1171: If no files are specified then standard input is used.
                   1172: .El
                   1173: .Sh DHPARAM
                   1174: .nr nS 1
                   1175: .Nm "openssl dhparam"
                   1176: .Op Fl 2 | 5
                   1177: .Op Fl C
                   1178: .Op Fl check
                   1179: .Op Fl dsaparam
                   1180: .Op Fl in Ar file
1.44      jmc      1181: .Op Fl inform Cm der | pem
1.1       jsing    1182: .Op Fl noout
                   1183: .Op Fl out Ar file
1.44      jmc      1184: .Op Fl outform Cm der | pem
1.1       jsing    1185: .Op Fl text
                   1186: .Op Ar numbits
                   1187: .nr nS 0
                   1188: .Pp
                   1189: The
                   1190: .Nm dhparam
                   1191: command is used to manipulate DH parameter files.
1.44      jmc      1192: Only the older PKCS#3 DH is supported,
                   1193: not the newer X9.42 DH.
1.1       jsing    1194: .Pp
                   1195: The options are as follows:
                   1196: .Bl -tag -width Ds
                   1197: .It Fl 2 , 5
1.44      jmc      1198: The generator to use;
1.1       jsing    1199: 2 is the default.
                   1200: If present, the input file is ignored and parameters are generated instead.
                   1201: .It Fl C
1.44      jmc      1202: Convert the parameters into C code.
1.1       jsing    1203: The parameters can then be loaded by calling the
1.44      jmc      1204: .No get_dh Ns Ar numbits
1.1       jsing    1205: function.
                   1206: .It Fl check
                   1207: Check the DH parameters.
                   1208: .It Fl dsaparam
1.44      jmc      1209: Read or create DSA parameters,
                   1210: converted to DH format on output.
1.1       jsing    1211: Otherwise,
                   1212: .Qq strong
                   1213: primes
                   1214: .Pq such that (p-1)/2 is also prime
                   1215: will be used for DH parameter generation.
                   1216: .Pp
                   1217: DH parameter generation with the
                   1218: .Fl dsaparam
                   1219: option is much faster,
                   1220: and the recommended exponent length is shorter,
                   1221: which makes DH key exchange more efficient.
                   1222: Beware that with such DSA-style DH parameters,
                   1223: a fresh DH key should be created for each use to
                   1224: avoid small-subgroup attacks that may be possible otherwise.
                   1225: .It Fl in Ar file
1.44      jmc      1226: The input file to read from,
                   1227: or standard input if not specified.
                   1228: .It Fl inform Cm der | pem
                   1229: The input format.
                   1230: .Cm der
1.1       jsing    1231: uses an ASN1 DER-encoded form compatible with the PKCS#3 DHparameter
                   1232: structure.
1.44      jmc      1233: .Cm pem
                   1234: is the default:
1.1       jsing    1235: it consists of the DER format base64-encoded with
1.44      jmc      1236: additional header and footer lines:
                   1237: .Bd -unfilled -offset indent
                   1238: -----BEGIN DH PARAMETERS-----
                   1239: -----END DH PARAMETERS-----
                   1240: .Ed
1.1       jsing    1241: .It Fl noout
1.46      jmc      1242: Do not output the encoded version of the parameters.
1.44      jmc      1243: .It Fl out Ar file
                   1244: The output file to write to,
                   1245: or standard output if not specified.
                   1246: .It Fl outform Cm der | pem
                   1247: The output format.
                   1248: .It Fl text
1.48      jmc      1249: Print the DH parameters in human readable form.
1.1       jsing    1250: .It Ar numbits
1.44      jmc      1251: Generate a parameter set of size
1.1       jsing    1252: .Ar numbits .
                   1253: It must be the last option.
1.16      sthen    1254: If not present, a value of 2048 is used.
1.1       jsing    1255: If this value is present, the input file is ignored and
                   1256: parameters are generated instead.
                   1257: .El
                   1258: .Sh DSA
                   1259: .nr nS 1
                   1260: .Nm "openssl dsa"
                   1261: .Oo
                   1262: .Fl aes128 | aes192 | aes256 |
                   1263: .Fl des | des3
                   1264: .Oc
                   1265: .Op Fl in Ar file
1.45      jmc      1266: .Op Fl inform Cm der | pem
1.1       jsing    1267: .Op Fl modulus
                   1268: .Op Fl noout
                   1269: .Op Fl out Ar file
1.45      jmc      1270: .Op Fl outform Cm der | pem
1.1       jsing    1271: .Op Fl passin Ar arg
                   1272: .Op Fl passout Ar arg
                   1273: .Op Fl pubin
                   1274: .Op Fl pubout
                   1275: .Op Fl text
                   1276: .nr nS 0
                   1277: .Pp
                   1278: The
                   1279: .Nm dsa
                   1280: command processes DSA keys.
                   1281: They can be converted between various forms and their components printed out.
                   1282: .Pp
                   1283: .Sy Note :
                   1284: This command uses the traditional
                   1285: .Nm SSLeay
                   1286: compatible format for private key encryption:
                   1287: newer applications should use the more secure PKCS#8 format using the
                   1288: .Nm pkcs8
                   1289: command.
                   1290: .Pp
1.45      jmc      1291: The PEM private key format uses the header and footer lines:
                   1292: .Bd -unfilled -offset indent
                   1293: -----BEGIN DSA PRIVATE KEY-----
                   1294: -----END DSA PRIVATE KEY-----
                   1295: .Ed
                   1296: .Pp
                   1297: The PEM public key format uses the header and footer lines:
                   1298: .Bd -unfilled -offset indent
                   1299: -----BEGIN PUBLIC KEY-----
                   1300: -----END PUBLIC KEY-----
                   1301: .Ed
                   1302: .Pp
1.1       jsing    1303: The options are as follows:
                   1304: .Bl -tag -width Ds
                   1305: .It Xo
                   1306: .Fl aes128 | aes192 | aes256 |
                   1307: .Fl des | des3
                   1308: .Xc
1.45      jmc      1309: Encrypt the private key with the AES, DES, or the triple DES
1.1       jsing    1310: ciphers, respectively, before outputting it.
                   1311: A pass phrase is prompted for.
1.45      jmc      1312: If none of these options are specified, the key is written in plain text.
1.1       jsing    1313: This means that using the
                   1314: .Nm dsa
1.45      jmc      1315: utility to read an encrypted key with no encryption option can be used to
1.1       jsing    1316: remove the pass phrase from a key,
1.45      jmc      1317: or by setting the encryption options it can be used to add or change
1.1       jsing    1318: the pass phrase.
                   1319: These options can only be used with PEM format output files.
                   1320: .It Fl in Ar file
1.45      jmc      1321: The input file to read from,
                   1322: or standard input if not specified.
1.1       jsing    1323: If the key is encrypted, a pass phrase will be prompted for.
1.45      jmc      1324: .It Fl inform Cm der | pem
                   1325: The input format.
                   1326: .Cm der
                   1327: with a private key uses an ASN1 DER-encoded form of an ASN.1
1.1       jsing    1328: SEQUENCE consisting of the values of version
                   1329: .Pq currently zero ,
                   1330: P, Q, G,
                   1331: and the public and private key components, respectively, as ASN.1 INTEGERs.
                   1332: When used with a public key it uses a
                   1333: .Em SubjectPublicKeyInfo
                   1334: structure: it is an error if the key is not DSA.
                   1335: .Pp
1.45      jmc      1336: .Cm pem
                   1337: is the default format:
1.1       jsing    1338: it consists of the DER format base64-encoded with additional header and footer
                   1339: lines.
                   1340: In the case of a private key, PKCS#8 format is also accepted.
                   1341: .It Fl modulus
1.45      jmc      1342: Print the value of the public key component of the key.
1.1       jsing    1343: .It Fl noout
1.46      jmc      1344: Do not output the encoded version of the key.
1.1       jsing    1345: .It Fl out Ar file
1.45      jmc      1346: The output file to write to,
                   1347: or standard output if not specified.
1.1       jsing    1348: If any encryption options are set then a pass phrase will be
                   1349: prompted for.
1.45      jmc      1350: .It Fl outform Cm der | pem
                   1351: The output format.
1.1       jsing    1352: .It Fl passin Ar arg
                   1353: The key password source.
                   1354: .It Fl passout Ar arg
                   1355: The output file password source.
                   1356: .It Fl pubin
                   1357: By default, a private key is read from the input file.
                   1358: With this option a public key is read instead.
                   1359: .It Fl pubout
                   1360: By default, a private key is output.
                   1361: With this option a public key will be output instead.
                   1362: This option is automatically set if the input is a public key.
                   1363: .It Fl text
1.48      jmc      1364: Print the public/private key components and parameters.
1.1       jsing    1365: .El
                   1366: .Sh DSAPARAM
                   1367: .nr nS 1
                   1368: .Nm "openssl dsaparam"
                   1369: .Op Fl C
                   1370: .Op Fl genkey
                   1371: .Op Fl in Ar file
1.46      jmc      1372: .Op Fl inform Cm der | pem
1.1       jsing    1373: .Op Fl noout
                   1374: .Op Fl out Ar file
1.46      jmc      1375: .Op Fl outform Cm der | pem
1.1       jsing    1376: .Op Fl text
                   1377: .Op Ar numbits
                   1378: .nr nS 0
                   1379: .Pp
                   1380: The
                   1381: .Nm dsaparam
                   1382: command is used to manipulate or generate DSA parameter files.
                   1383: .Pp
1.46      jmc      1384: PEM format DSA parameters use the header and footer lines:
                   1385: .Bd -unfilled -offset indent
                   1386: -----BEGIN DSA PARAMETERS-----
                   1387: -----END DSA PARAMETERS-----
                   1388: .Ed
                   1389: .Pp
1.1       jsing    1390: The options are as follows:
                   1391: .Bl -tag -width Ds
                   1392: .It Fl C
1.46      jmc      1393: Convert the parameters into C code.
1.1       jsing    1394: The parameters can then be loaded by calling the
1.46      jmc      1395: .No get_dsa Ns Ar XXX
1.1       jsing    1396: function.
                   1397: .It Fl genkey
1.46      jmc      1398: Generate a DSA key either using the specified or generated
1.1       jsing    1399: parameters.
                   1400: .It Fl in Ar file
1.46      jmc      1401: The input file to read from,
                   1402: or standard input if not specified.
1.1       jsing    1403: If the
                   1404: .Ar numbits
1.46      jmc      1405: parameter is included, then this option is ignored.
                   1406: .It Fl inform Cm der | pem
                   1407: The input format.
                   1408: .Cm der
                   1409: uses an ASN1 DER-encoded form compatible with RFC 2459
1.1       jsing    1410: .Pq PKIX
                   1411: DSS-Parms that is a SEQUENCE consisting of p, q and g, respectively.
1.46      jmc      1412: .Cm pem
                   1413: is the default format:
1.1       jsing    1414: it consists of the DER format base64-encoded with additional header
                   1415: and footer lines.
                   1416: .It Fl noout
1.46      jmc      1417: Do not output the encoded version of the parameters.
                   1418: .It Fl out Ar file
                   1419: The output file to write to,
                   1420: or standard output if not specified.
                   1421: .It Fl outform Cm der | pem
                   1422: The output format.
                   1423: .It Fl text
                   1424: Print the DSA parameters in human readable form.
1.1       jsing    1425: .It Ar numbits
1.46      jmc      1426: Generate a parameter set of size
1.1       jsing    1427: .Ar numbits .
1.46      jmc      1428: If this option is included, the input file is ignored.
1.1       jsing    1429: .El
                   1430: .Sh EC
                   1431: .nr nS 1
                   1432: .Nm "openssl ec"
                   1433: .Op Fl conv_form Ar arg
                   1434: .Op Fl des
                   1435: .Op Fl des3
                   1436: .Op Fl in Ar file
1.47      jmc      1437: .Op Fl inform Cm der | pem
1.1       jsing    1438: .Op Fl noout
                   1439: .Op Fl out Ar file
1.47      jmc      1440: .Op Fl outform Cm der | pem
1.1       jsing    1441: .Op Fl param_enc Ar arg
                   1442: .Op Fl param_out
                   1443: .Op Fl passin Ar arg
                   1444: .Op Fl passout Ar arg
                   1445: .Op Fl pubin
                   1446: .Op Fl pubout
                   1447: .Op Fl text
                   1448: .nr nS 0
                   1449: .Pp
                   1450: The
                   1451: .Nm ec
                   1452: command processes EC keys.
                   1453: They can be converted between various
                   1454: forms and their components printed out.
1.47      jmc      1455: .Nm openssl
1.1       jsing    1456: uses the private key format specified in
                   1457: .Dq SEC 1: Elliptic Curve Cryptography
                   1458: .Pq Lk http://www.secg.org/ .
                   1459: To convert an
                   1460: EC private key into the PKCS#8 private key format use the
                   1461: .Nm pkcs8
                   1462: command.
                   1463: .Pp
1.47      jmc      1464: The PEM private key format uses the header and footer lines:
                   1465: .Bd -literal -offset indent
                   1466: -----BEGIN EC PRIVATE KEY-----
                   1467: -----END EC PRIVATE KEY-----
                   1468: .Ed
                   1469: .Pp
                   1470: The PEM public key format uses the header and footer lines:
                   1471: .Bd -literal -offset indent
                   1472: -----BEGIN PUBLIC KEY-----
                   1473: -----END PUBLIC KEY-----
                   1474: .Ed
                   1475: .Pp
1.1       jsing    1476: The options are as follows:
                   1477: .Bl -tag -width Ds
                   1478: .It Fl conv_form Ar arg
1.47      jmc      1479: Specify how the points on the elliptic curve are converted
1.1       jsing    1480: into octet strings.
                   1481: Possible values are:
                   1482: .Cm compressed
1.47      jmc      1483: (the default),
1.1       jsing    1484: .Cm uncompressed ,
                   1485: and
                   1486: .Cm hybrid .
                   1487: For more information regarding
1.47      jmc      1488: the point conversion forms see the X9.62 standard.
1.1       jsing    1489: Note:
                   1490: Due to patent issues the
                   1491: .Cm compressed
                   1492: option is disabled by default for binary curves
                   1493: and can be enabled by defining the preprocessor macro
1.47      jmc      1494: .Dv OPENSSL_EC_BIN_PT_COMP
1.1       jsing    1495: at compile time.
                   1496: .It Fl des | des3
1.47      jmc      1497: Encrypt the private key with DES, triple DES, or
1.1       jsing    1498: any other cipher supported by
1.47      jmc      1499: .Nm openssl .
1.1       jsing    1500: A pass phrase is prompted for.
                   1501: If none of these options is specified the key is written in plain text.
                   1502: This means that using the
                   1503: .Nm ec
                   1504: utility to read in an encrypted key with no
                   1505: encryption option can be used to remove the pass phrase from a key,
                   1506: or by setting the encryption options
                   1507: it can be use to add or change the pass phrase.
                   1508: These options can only be used with PEM format output files.
                   1509: .It Fl in Ar file
1.47      jmc      1510: The input file to read a key from,
                   1511: or standard input if not specified.
1.1       jsing    1512: If the key is encrypted a pass phrase will be prompted for.
1.47      jmc      1513: .It Fl inform Cm der | pem
                   1514: The input format.
                   1515: .Cm der
                   1516: with a private key uses
1.1       jsing    1517: an ASN.1 DER-encoded SEC1 private key.
                   1518: When used with a public key it
                   1519: uses the SubjectPublicKeyInfo structure as specified in RFC 3280.
1.47      jmc      1520: .Cm pem
                   1521: is the default format:
1.48      jmc      1522: it consists of the DER format base64-encoded
                   1523: with additional header and footer lines.
1.1       jsing    1524: In the case of a private key
                   1525: PKCS#8 format is also accepted.
                   1526: .It Fl noout
1.47      jmc      1527: Do not output the encoded version of the key.
1.1       jsing    1528: .It Fl out Ar file
1.47      jmc      1529: The output filename to write to,
                   1530: or standard output if not specified.
1.1       jsing    1531: If any encryption options are set then a pass phrase will be prompted for.
1.47      jmc      1532: .It Fl outform Cm der | pem
                   1533: The output format.
1.1       jsing    1534: .It Fl param_enc Ar arg
1.47      jmc      1535: Specify how the elliptic curve parameters are encoded.
1.1       jsing    1536: Possible value are:
                   1537: .Cm named_curve ,
                   1538: i.e. the EC parameters are specified by an OID; or
                   1539: .Cm explicit ,
                   1540: where the EC parameters are explicitly given
                   1541: (see RFC 3279 for the definition of the EC parameter structures).
                   1542: The default value is
                   1543: .Cm named_curve .
                   1544: Note: the
                   1545: .Cm implicitlyCA
                   1546: alternative,
                   1547: as specified in RFC 3279,
1.47      jmc      1548: is currently not implemented.
1.1       jsing    1549: .It Fl passin Ar arg
                   1550: The key password source.
                   1551: .It Fl passout Ar arg
                   1552: The output file password source.
                   1553: .It Fl pubin
                   1554: By default a private key is read from the input file;
                   1555: with this option a public key is read instead.
                   1556: .It Fl pubout
                   1557: By default a private key is output;
                   1558: with this option a public key is output instead.
                   1559: This option is automatically set if the input is a public key.
                   1560: .It Fl text
1.48      jmc      1561: Print the public/private key components and parameters.
1.1       jsing    1562: .El
                   1563: .Sh ECPARAM
                   1564: .nr nS 1
                   1565: .Nm "openssl ecparam"
                   1566: .Op Fl C
                   1567: .Op Fl check
                   1568: .Op Fl conv_form Ar arg
                   1569: .Op Fl genkey
                   1570: .Op Fl in Ar file
1.48      jmc      1571: .Op Fl inform Cm der | pem
1.1       jsing    1572: .Op Fl list_curves
                   1573: .Op Fl name Ar arg
                   1574: .Op Fl no_seed
                   1575: .Op Fl noout
                   1576: .Op Fl out Ar file
1.48      jmc      1577: .Op Fl outform Cm der | pem
1.1       jsing    1578: .Op Fl param_enc Ar arg
                   1579: .Op Fl text
                   1580: .nr nS 0
                   1581: .Pp
1.48      jmc      1582: The
                   1583: .Nm ecparam
                   1584: command is used to manipulate or generate EC parameter files.
                   1585: .Nm openssl
                   1586: is not able to generate new groups so
                   1587: .Nm ecparam
                   1588: can only create EC parameters from known (named) curves.
                   1589: .Pp
                   1590: PEM format EC parameters use the header and footer lines:
                   1591: .Bd -literal -offset indent
                   1592: -----BEGIN EC PARAMETERS-----
                   1593: -----END EC PARAMETERS-----
                   1594: .Ed
1.1       jsing    1595: .Pp
                   1596: The options are as follows:
                   1597: .Bl -tag -width Ds
                   1598: .It Fl C
                   1599: Convert the EC parameters into C code.
                   1600: The parameters can then be loaded by calling the
1.48      jmc      1601: .No get_ec_group_ Ns Ar XXX
1.1       jsing    1602: function.
                   1603: .It Fl check
                   1604: Validate the elliptic curve parameters.
                   1605: .It Fl conv_form Ar arg
                   1606: Specify how the points on the elliptic curve are converted
                   1607: into octet strings.
                   1608: Possible values are:
                   1609: .Cm compressed
1.48      jmc      1610: (the default),
1.1       jsing    1611: .Cm uncompressed ,
                   1612: and
                   1613: .Cm hybrid .
                   1614: For more information regarding
1.48      jmc      1615: the point conversion forms see the X9.62 standard.
1.1       jsing    1616: Note:
                   1617: Due to patent issues the
                   1618: .Cm compressed
                   1619: option is disabled by default for binary curves
                   1620: and can be enabled by defining the preprocessor macro
1.48      jmc      1621: .Dv OPENSSL_EC_BIN_PT_COMP
1.1       jsing    1622: at compile time.
                   1623: .It Fl genkey
                   1624: Generate an EC private key using the specified parameters.
                   1625: .It Fl in Ar file
1.48      jmc      1626: The input file to read from,
                   1627: or standard input if not specified.
                   1628: .It Fl inform Cm der | pem
                   1629: The input format.
                   1630: .Cm der
                   1631: uses an ASN.1 DER-encoded
1.1       jsing    1632: form compatible with RFC 3279 EcpkParameters.
1.48      jmc      1633: .Cm pem
                   1634: is the default format:
                   1635: it consists of the DER format base64-encoded with additional
1.1       jsing    1636: header and footer lines.
                   1637: .It Fl list_curves
1.48      jmc      1638: Print a list of all
1.1       jsing    1639: currently implemented EC parameter names and exit.
                   1640: .It Fl name Ar arg
1.48      jmc      1641: Use the EC parameters with the specified "short" name.
1.1       jsing    1642: .It Fl no_seed
1.48      jmc      1643: Do not include the seed for the parameter generation
                   1644: in the ECParameters structure (see RFC 3279).
1.1       jsing    1645: .It Fl noout
1.48      jmc      1646: Do not output the encoded version of the parameters.
1.1       jsing    1647: .It Fl out Ar file
1.48      jmc      1648: The output file to write to,
                   1649: or standard output if not specified.
                   1650: .It Fl outform Cm der | pem
                   1651: The output format.
1.1       jsing    1652: .It Fl param_enc Ar arg
1.48      jmc      1653: Specify how the elliptic curve parameters are encoded.
1.1       jsing    1654: Possible value are:
                   1655: .Cm named_curve ,
                   1656: i.e. the EC parameters are specified by an OID, or
                   1657: .Cm explicit ,
                   1658: where the EC parameters are explicitly given
                   1659: (see RFC 3279 for the definition of the EC parameter structures).
                   1660: The default value is
                   1661: .Cm named_curve .
                   1662: Note: the
                   1663: .Cm implicitlyCA
                   1664: alternative, as specified in RFC 3279,
1.48      jmc      1665: is currently not implemented.
1.1       jsing    1666: .It Fl text
1.48      jmc      1667: Print the EC parameters in human readable form.
1.1       jsing    1668: .El
                   1669: .Sh ENC
                   1670: .nr nS 1
                   1671: .Nm "openssl enc"
                   1672: .Fl ciphername
                   1673: .Op Fl AadePp
                   1674: .Op Fl base64
                   1675: .Op Fl bufsize Ar number
                   1676: .Op Fl debug
                   1677: .Op Fl in Ar file
                   1678: .Op Fl iv Ar IV
                   1679: .Op Fl K Ar key
                   1680: .Op Fl k Ar password
                   1681: .Op Fl kfile Ar file
                   1682: .Op Fl md Ar digest
                   1683: .Op Fl none
                   1684: .Op Fl nopad
                   1685: .Op Fl nosalt
                   1686: .Op Fl out Ar file
                   1687: .Op Fl pass Ar arg
                   1688: .Op Fl S Ar salt
                   1689: .Op Fl salt
                   1690: .nr nS 0
                   1691: .Pp
                   1692: The symmetric cipher commands allow data to be encrypted or decrypted
                   1693: using various block and stream ciphers using keys based on passwords
                   1694: or explicitly provided.
                   1695: Base64 encoding or decoding can also be performed either by itself
                   1696: or in addition to the encryption or decryption.
1.49      jmc      1697: The program can be called either as
                   1698: .Nm openssl Ar ciphername
                   1699: or
                   1700: .Nm openssl enc - Ns Ar ciphername .
                   1701: .Pp
                   1702: Some of the ciphers do not have large keys and others have security
                   1703: implications if not used correctly.
                   1704: All the block ciphers normally use PKCS#5 padding,
                   1705: also known as standard block padding.
                   1706: If padding is disabled, the input data must be a multiple of the cipher
                   1707: block length.
1.1       jsing    1708: .Pp
                   1709: The options are as follows:
                   1710: .Bl -tag -width Ds
                   1711: .It Fl A
                   1712: If the
                   1713: .Fl a
                   1714: option is set, then base64 process the data on one line.
                   1715: .It Fl a , base64
                   1716: Base64 process the data.
                   1717: This means that if encryption is taking place, the data is base64-encoded
                   1718: after encryption.
1.49      jmc      1719: If decryption is set, the input data is base64-decoded before
1.1       jsing    1720: being decrypted.
                   1721: .It Fl bufsize Ar number
                   1722: Set the buffer size for I/O.
                   1723: .It Fl d
                   1724: Decrypt the input data.
                   1725: .It Fl debug
                   1726: Debug the BIOs used for I/O.
                   1727: .It Fl e
1.49      jmc      1728: Encrypt the input data.
                   1729: This is the default.
1.1       jsing    1730: .It Fl in Ar file
1.49      jmc      1731: The input file to read from,
1.57    ! jmc      1732: or standard input if not specified.
1.1       jsing    1733: .It Fl iv Ar IV
                   1734: The actual
                   1735: .Ar IV
                   1736: .Pq initialisation vector
                   1737: to use:
                   1738: this must be represented as a string comprised only of hex digits.
                   1739: When only the
                   1740: .Ar key
                   1741: is specified using the
                   1742: .Fl K
1.49      jmc      1743: option,
                   1744: the IV must explicitly be defined.
1.1       jsing    1745: When a password is being specified using one of the other options,
1.49      jmc      1746: the IV is generated from this password.
1.1       jsing    1747: .It Fl K Ar key
                   1748: The actual
                   1749: .Ar key
                   1750: to use:
                   1751: this must be represented as a string comprised only of hex digits.
1.49      jmc      1752: If only the key is specified,
                   1753: the IV must also be specified using the
1.1       jsing    1754: .Fl iv
                   1755: option.
                   1756: When both a
                   1757: .Ar key
                   1758: and a
                   1759: .Ar password
                   1760: are specified, the
                   1761: .Ar key
                   1762: given with the
                   1763: .Fl K
1.49      jmc      1764: option will be used and the IV generated from the password will be taken.
1.1       jsing    1765: It probably does not make much sense to specify both
                   1766: .Ar key
                   1767: and
                   1768: .Ar password .
                   1769: .It Fl k Ar password
                   1770: The
                   1771: .Ar password
                   1772: to derive the key from.
                   1773: Superseded by the
                   1774: .Fl pass
                   1775: option.
                   1776: .It Fl kfile Ar file
                   1777: Read the password to derive the key from the first line of
                   1778: .Ar file .
                   1779: Superseded by the
                   1780: .Fl pass
                   1781: option.
                   1782: .It Fl md Ar digest
                   1783: Use
                   1784: .Ar digest
                   1785: to create a key from a pass phrase.
                   1786: .Ar digest
                   1787: may be one of
1.49      jmc      1788: .Cm md5
1.1       jsing    1789: or
1.49      jmc      1790: .Cm sha1 .
1.1       jsing    1791: .It Fl none
                   1792: Use NULL cipher (no encryption or decryption of input).
                   1793: .It Fl nopad
                   1794: Disable standard block padding.
                   1795: .It Fl nosalt
1.49      jmc      1796: Don't use a salt in the key derivation routines.
1.1       jsing    1797: This option should
                   1798: .Em NEVER
1.49      jmc      1799: be used
                   1800: since it makes it possible to perform efficient dictionary
                   1801: attacks on the password and to attack stream cipher encrypted data.
1.1       jsing    1802: .It Fl out Ar file
1.51      jmc      1803: The output file to write to,
1.57    ! jmc      1804: or standard output if not specified.
1.1       jsing    1805: .It Fl P
1.49      jmc      1806: Print out the salt, key, and IV used, then immediately exit;
1.1       jsing    1807: don't do any encryption or decryption.
                   1808: .It Fl p
1.49      jmc      1809: Print out the salt, key, and IV used.
1.1       jsing    1810: .It Fl pass Ar arg
                   1811: The password source.
                   1812: .It Fl S Ar salt
                   1813: The actual
                   1814: .Ar salt
                   1815: to use:
                   1816: this must be represented as a string comprised only of hex digits.
                   1817: .It Fl salt
1.49      jmc      1818: Use a salt in the key derivation routines (the default).
                   1819: When the salt is being used
                   1820: the first eight bytes of the encrypted data are reserved for the salt:
                   1821: it is randomly generated when encrypting a file and read from the
                   1822: encrypted file when it is decrypted.
1.1       jsing    1823: .El
                   1824: .Sh ERRSTR
                   1825: .Nm openssl errstr
                   1826: .Op Fl stats
                   1827: .Ar errno ...
                   1828: .Pp
                   1829: The
                   1830: .Nm errstr
                   1831: command performs error number to error string conversion,
                   1832: generating a human-readable string representing the error code
                   1833: .Ar errno .
                   1834: The string is obtained through the
                   1835: .Xr ERR_error_string_n 3
                   1836: function and has the following format:
                   1837: .Pp
                   1838: .Dl error:[error code]:[library name]:[function name]:[reason string]
                   1839: .Pp
                   1840: .Bq error code
                   1841: is an 8-digit hexadecimal number.
                   1842: The remaining fields
                   1843: .Bq library name ,
                   1844: .Bq function name ,
                   1845: and
                   1846: .Bq reason string
                   1847: are all ASCII text.
                   1848: .Pp
                   1849: The options are as follows:
                   1850: .Bl -tag -width Ds
                   1851: .It Fl stats
                   1852: Print debugging statistics about various aspects of the hash table.
                   1853: .El
                   1854: .Sh GENDSA
                   1855: .nr nS 1
                   1856: .Nm "openssl gendsa"
                   1857: .Oo
                   1858: .Fl aes128 | aes192 | aes256 |
                   1859: .Fl des | des3
                   1860: .Oc
                   1861: .Op Fl out Ar file
                   1862: .Op Ar paramfile
                   1863: .nr nS 0
                   1864: .Pp
                   1865: The
                   1866: .Nm gendsa
                   1867: command generates a DSA private key from a DSA parameter file
1.51      jmc      1868: (typically generated by the
1.1       jsing    1869: .Nm openssl dsaparam
                   1870: command).
1.51      jmc      1871: DSA key generation is little more than random number generation so it is
                   1872: much quicker than,
                   1873: for example,
                   1874: RSA key generation.
1.1       jsing    1875: .Pp
                   1876: The options are as follows:
                   1877: .Bl -tag -width Ds
                   1878: .It Xo
                   1879: .Fl aes128 | aes192 | aes256 |
                   1880: .Fl des | des3
                   1881: .Xc
1.51      jmc      1882: Encrypt the private key with the AES, DES,
1.1       jsing    1883: or the triple DES ciphers, respectively, before outputting it.
                   1884: A pass phrase is prompted for.
                   1885: If none of these options are specified, no encryption is used.
                   1886: .It Fl out Ar file
1.51      jmc      1887: The output file to write to,
1.57    ! jmc      1888: or standard output if not specified.
1.1       jsing    1889: .It Ar paramfile
1.51      jmc      1890: Specify the DSA parameter file to use.
1.1       jsing    1891: The parameters in this file determine the size of the private key.
                   1892: .El
                   1893: .Sh GENPKEY
                   1894: .nr nS 1
                   1895: .Nm "openssl genpkey"
                   1896: .Op Fl algorithm Ar alg
                   1897: .Op Ar cipher
                   1898: .Op Fl genparam
                   1899: .Op Fl out Ar file
1.52      jmc      1900: .Op Fl outform Cm der | pem
1.1       jsing    1901: .Op Fl paramfile Ar file
                   1902: .Op Fl pass Ar arg
                   1903: .Op Fl pkeyopt Ar opt : Ns Ar value
                   1904: .Op Fl text
                   1905: .nr nS 0
                   1906: .Pp
                   1907: The
                   1908: .Nm genpkey
                   1909: command generates private keys.
                   1910: The use of this
                   1911: program is encouraged over the algorithm specific utilities
1.22      bcook    1912: because additional algorithm options can be used.
1.1       jsing    1913: .Pp
                   1914: The options are as follows:
                   1915: .Bl -tag -width Ds
                   1916: .It Fl algorithm Ar alg
                   1917: The public key algorithm to use,
                   1918: such as RSA, DSA, or DH.
1.52      jmc      1919: This option must precede any
1.1       jsing    1920: .Fl pkeyopt
                   1921: options.
                   1922: The options
                   1923: .Fl paramfile
                   1924: and
                   1925: .Fl algorithm
                   1926: are mutually exclusive.
                   1927: .It Ar cipher
                   1928: Encrypt the private key with the supplied cipher.
                   1929: Any algorithm name accepted by
1.52      jmc      1930: .Xr EVP_get_cipherbyname 3
                   1931: is acceptable.
1.1       jsing    1932: .It Fl genparam
                   1933: Generate a set of parameters instead of a private key.
1.52      jmc      1934: This option must precede any
1.1       jsing    1935: .Fl algorithm ,
                   1936: .Fl paramfile ,
                   1937: or
                   1938: .Fl pkeyopt
                   1939: options.
                   1940: .It Fl out Ar file
1.52      jmc      1941: The output file to write to,
1.57    ! jmc      1942: or standard output if not specified.
1.52      jmc      1943: .It Fl outform Cm der | pem
                   1944: The output format.
1.1       jsing    1945: .It Fl paramfile Ar file
1.52      jmc      1946: Some public key algorithms generate a private key based on a set of parameters,
                   1947: which can be supplied using this option.
1.1       jsing    1948: If this option is used the public key
                   1949: algorithm used is determined by the parameters.
1.52      jmc      1950: This option must precede any
1.1       jsing    1951: .Fl pkeyopt
                   1952: options.
                   1953: The options
                   1954: .Fl paramfile
                   1955: and
                   1956: .Fl algorithm
                   1957: are mutually exclusive.
                   1958: .It Fl pass Ar arg
                   1959: The output file password source.
                   1960: .It Fl pkeyopt Ar opt : Ns Ar value
                   1961: Set the public key algorithm option
                   1962: .Ar opt
                   1963: to
1.52      jmc      1964: .Ar value ,
                   1965: as follows:
1.1       jsing    1966: .Bl -tag -width Ds -offset indent
                   1967: .It rsa_keygen_bits : Ns Ar numbits
                   1968: (RSA)
                   1969: The number of bits in the generated key.
1.52      jmc      1970: The default is 2048.
1.1       jsing    1971: .It rsa_keygen_pubexp : Ns Ar value
                   1972: (RSA)
                   1973: The RSA public exponent value.
                   1974: This can be a large decimal or hexadecimal value if preceded by 0x.
1.52      jmc      1975: The default is 65537.
1.1       jsing    1976: .It dsa_paramgen_bits : Ns Ar numbits
                   1977: (DSA)
                   1978: The number of bits in the generated parameters.
1.52      jmc      1979: The default is 1024.
1.1       jsing    1980: .It dh_paramgen_prime_len : Ns Ar numbits
                   1981: (DH)
                   1982: The number of bits in the prime parameter
                   1983: .Ar p .
                   1984: .It dh_paramgen_generator : Ns Ar value
                   1985: (DH)
                   1986: The value to use for the generator
                   1987: .Ar g .
                   1988: .It ec_paramgen_curve : Ns Ar curve
                   1989: (EC)
                   1990: The EC curve to use.
                   1991: .El
1.52      jmc      1992: .It Fl text
                   1993: Print an unencrypted text representation of private and public keys and
                   1994: parameters along with the DER or PEM structure.
                   1995: .El
1.1       jsing    1996: .Sh GENRSA
                   1997: .nr nS 1
                   1998: .Nm "openssl genrsa"
                   1999: .Op Fl 3 | f4
1.53      jmc      2000: .Op Fl aes128 | aes192 | aes256 | des | des3
1.1       jsing    2001: .Op Fl out Ar file
                   2002: .Op Fl passout Ar arg
                   2003: .Op Ar numbits
                   2004: .nr nS 0
                   2005: .Pp
                   2006: The
                   2007: .Nm genrsa
1.53      jmc      2008: command generates an RSA private key,
                   2009: which essentially involves the generation of two prime numbers.
                   2010: When generating the key,
                   2011: various symbols will be output to indicate the progress of the generation.
                   2012: A
                   2013: .Sq \&.
                   2014: represents each number which has passed an initial sieve test;
                   2015: .Sq +
                   2016: means a number has passed a single round of the Miller-Rabin primality test.
                   2017: A newline means that the number has passed all the prime tests
                   2018: (the actual number depends on the key size).
1.1       jsing    2019: .Pp
                   2020: The options are as follows:
                   2021: .Bl -tag -width Ds
                   2022: .It Fl 3 | f4
                   2023: The public exponent to use, either 3 or 65537.
                   2024: The default is 65537.
1.53      jmc      2025: .It Fl aes128 | aes192 | aes256 | des | des3
                   2026: Encrypt the private key with the AES, DES,
1.1       jsing    2027: or the triple DES ciphers, respectively, before outputting it.
                   2028: If none of these options are specified, no encryption is used.
                   2029: If encryption is used, a pass phrase is prompted for,
                   2030: if it is not supplied via the
                   2031: .Fl passout
                   2032: option.
                   2033: .It Fl out Ar file
1.53      jmc      2034: The output file to write to,
1.57    ! jmc      2035: or standard output if not specified.
1.1       jsing    2036: .It Fl passout Ar arg
                   2037: The output file password source.
                   2038: .It Ar numbits
                   2039: The size of the private key to generate in bits.
                   2040: This must be the last option specified.
                   2041: The default is 2048.
                   2042: .El
                   2043: .Sh NSEQ
                   2044: .Nm openssl nseq
                   2045: .Op Fl in Ar file
                   2046: .Op Fl out Ar file
                   2047: .Op Fl toseq
                   2048: .Pp
                   2049: The
                   2050: .Nm nseq
1.54      jmc      2051: command takes a file containing a Netscape certificate sequence
                   2052: (an alternative to the standard PKCS#7 format)
                   2053: and prints out the certificates contained in it,
                   2054: or takes a file of certificates
                   2055: and converts it into a Netscape certificate sequence.
                   2056: .Pp
                   2057: The PEM-encoded form uses the same headers and footers as a certificate:
                   2058: .Bd -unfilled -offset indent
                   2059: -----BEGIN CERTIFICATE-----
                   2060: -----END CERTIFICATE-----
                   2061: .Ed
1.1       jsing    2062: .Pp
                   2063: The options are as follows:
                   2064: .Bl -tag -width Ds
                   2065: .It Fl in Ar file
1.54      jmc      2066: The input file to read from,
                   2067: or standard input if not specified.
1.1       jsing    2068: .It Fl out Ar file
1.54      jmc      2069: The output file to write to,
                   2070: or standard output if not specified.
1.1       jsing    2071: .It Fl toseq
                   2072: Normally, a Netscape certificate sequence will be input and the output
                   2073: is the certificates contained in it.
                   2074: With the
                   2075: .Fl toseq
                   2076: option the situation is reversed:
                   2077: a Netscape certificate sequence is created from a file of certificates.
                   2078: .El
                   2079: .Sh OCSP
                   2080: .nr nS 1
                   2081: .Nm "openssl ocsp"
                   2082: .Op Fl CA Ar file
                   2083: .Op Fl CAfile Ar file
                   2084: .Op Fl CApath Ar directory
                   2085: .Op Fl cert Ar file
                   2086: .Op Fl dgst Ar alg
1.55      jmc      2087: .Op Fl host Ar hostname : Ns Ar port
1.1       jsing    2088: .Op Fl index Ar indexfile
                   2089: .Op Fl issuer Ar file
                   2090: .Op Fl ndays Ar days
                   2091: .Op Fl nmin Ar minutes
                   2092: .Op Fl no_cert_checks
                   2093: .Op Fl no_cert_verify
                   2094: .Op Fl no_certs
                   2095: .Op Fl no_chain
                   2096: .Op Fl no_intern
                   2097: .Op Fl no_nonce
                   2098: .Op Fl no_signature_verify
                   2099: .Op Fl nonce
                   2100: .Op Fl noverify
                   2101: .Op Fl nrequest Ar number
                   2102: .Op Fl out Ar file
                   2103: .Op Fl path Ar path
                   2104: .Op Fl port Ar portnum
                   2105: .Op Fl req_text
                   2106: .Op Fl reqin Ar file
                   2107: .Op Fl reqout Ar file
                   2108: .Op Fl resp_key_id
                   2109: .Op Fl resp_no_certs
                   2110: .Op Fl resp_text
                   2111: .Op Fl respin Ar file
                   2112: .Op Fl respout Ar file
                   2113: .Op Fl rkey Ar file
                   2114: .Op Fl rother Ar file
                   2115: .Op Fl rsigner Ar file
                   2116: .Op Fl serial Ar number
                   2117: .Op Fl sign_other Ar file
                   2118: .Op Fl signer Ar file
                   2119: .Op Fl signkey Ar file
                   2120: .Op Fl status_age Ar age
                   2121: .Op Fl text
                   2122: .Op Fl trust_other
                   2123: .Op Fl url Ar responder_url
                   2124: .Op Fl VAfile Ar file
                   2125: .Op Fl validity_period Ar nsec
                   2126: .Op Fl verify_other Ar file
                   2127: .nr nS 0
                   2128: .Pp
1.55      jmc      2129: The Online Certificate Status Protocol (OCSP)
                   2130: enables applications to determine the (revocation) state
                   2131: of an identified certificate (RFC 2560).
1.1       jsing    2132: .Pp
                   2133: The
                   2134: .Nm ocsp
                   2135: command performs many common OCSP tasks.
                   2136: It can be used to print out requests and responses,
                   2137: create requests and send queries to an OCSP responder,
                   2138: and behave like a mini OCSP server itself.
                   2139: .Pp
                   2140: The options are as follows:
                   2141: .Bl -tag -width Ds
                   2142: .It Fl CAfile Ar file , Fl CApath Ar directory
1.55      jmc      2143: A file or path containing trusted CA certificates,
                   2144: used to verify the signature on the OCSP response.
1.1       jsing    2145: .It Fl cert Ar file
                   2146: Add the certificate
                   2147: .Ar file
                   2148: to the request.
                   2149: The issuer certificate is taken from the previous
                   2150: .Fl issuer
                   2151: option, or an error occurs if no issuer certificate is specified.
                   2152: .It Fl dgst Ar alg
1.55      jmc      2153: Use the digest algorithm
                   2154: .Ar alg
                   2155: for certificate identification in the OCSP request.
1.1       jsing    2156: By default SHA-1 is used.
                   2157: .It Xo
                   2158: .Fl host Ar hostname : Ns Ar port ,
                   2159: .Fl path Ar path
                   2160: .Xc
1.55      jmc      2161: Send
                   2162: the OCSP request to
1.1       jsing    2163: .Ar hostname
1.55      jmc      2164: on
1.1       jsing    2165: .Ar port .
                   2166: .Fl path
                   2167: specifies the HTTP path name to use, or
1.55      jmc      2168: .Pa /
1.1       jsing    2169: by default.
                   2170: .It Fl issuer Ar file
1.55      jmc      2171: The current issuer certificate,
                   2172: in PEM format.
                   2173: Can be used multiple times
                   2174: and must come before any
1.1       jsing    2175: .Fl cert
                   2176: options.
                   2177: .It Fl no_cert_checks
                   2178: Don't perform any additional checks on the OCSP response signer's certificate.
                   2179: That is, do not make any checks to see if the signer's certificate is
                   2180: authorised to provide the necessary status information:
                   2181: as a result this option should only be used for testing purposes.
                   2182: .It Fl no_cert_verify
                   2183: Don't verify the OCSP response signer's certificate at all.
                   2184: Since this option allows the OCSP response to be signed by any certificate,
                   2185: it should only be used for testing purposes.
                   2186: .It Fl no_certs
1.55      jmc      2187: Don't include any certificates in the signed request.
1.1       jsing    2188: .It Fl no_chain
                   2189: Do not use certificates in the response as additional untrusted CA
                   2190: certificates.
                   2191: .It Fl no_intern
                   2192: Ignore certificates contained in the OCSP response
                   2193: when searching for the signer's certificate.
1.55      jmc      2194: The signer's certificate must be specified with either the
1.1       jsing    2195: .Fl verify_other
                   2196: or
                   2197: .Fl VAfile
                   2198: options.
                   2199: .It Fl no_signature_verify
                   2200: Don't check the signature on the OCSP response.
                   2201: Since this option tolerates invalid signatures on OCSP responses,
                   2202: it will normally only be used for testing purposes.
                   2203: .It Fl nonce , no_nonce
1.55      jmc      2204: Add an OCSP nonce extension to a request,
                   2205: or disable an OCSP nonce addition.
1.1       jsing    2206: Normally, if an OCSP request is input using the
                   2207: .Fl respin
1.55      jmc      2208: option no nonce is added:
1.1       jsing    2209: using the
                   2210: .Fl nonce
1.55      jmc      2211: option will force the addition of a nonce.
1.1       jsing    2212: If an OCSP request is being created (using the
                   2213: .Fl cert
                   2214: and
                   2215: .Fl serial
                   2216: options)
1.55      jmc      2217: a nonce is automatically added; specifying
1.1       jsing    2218: .Fl no_nonce
                   2219: overrides this.
                   2220: .It Fl noverify
1.55      jmc      2221: Don't attempt to verify the OCSP response signature or the nonce values.
                   2222: This is normally only be used for debugging
1.1       jsing    2223: since it disables all verification of the responder's certificate.
                   2224: .It Fl out Ar file
1.55      jmc      2225: Specify the output file to write to,
1.57    ! jmc      2226: or standard output if not specified.
1.1       jsing    2227: .It Fl req_text , resp_text , text
                   2228: Print out the text form of the OCSP request, response, or both, respectively.
                   2229: .It Fl reqin Ar file , Fl respin Ar file
                   2230: Read an OCSP request or response file from
                   2231: .Ar file .
                   2232: These options are ignored
                   2233: if an OCSP request or response creation is implied by other options
                   2234: (for example with the
                   2235: .Fl serial , cert ,
                   2236: and
                   2237: .Fl host
                   2238: options).
                   2239: .It Fl reqout Ar file , Fl respout Ar file
                   2240: Write out the DER-encoded certificate request or response to
                   2241: .Ar file .
                   2242: .It Fl serial Ar num
                   2243: Same as the
                   2244: .Fl cert
                   2245: option except the certificate with serial number
                   2246: .Ar num
                   2247: is added to the request.
                   2248: The serial number is interpreted as a decimal integer unless preceded by
                   2249: .Sq 0x .
1.55      jmc      2250: Negative integers can also be specified
                   2251: by preceding the value with a minus sign.
1.1       jsing    2252: .It Fl sign_other Ar file
                   2253: Additional certificates to include in the signed request.
                   2254: .It Fl signer Ar file , Fl signkey Ar file
                   2255: Sign the OCSP request using the certificate specified in the
                   2256: .Fl signer
                   2257: option and the private key specified by the
                   2258: .Fl signkey
                   2259: option.
                   2260: If the
                   2261: .Fl signkey
                   2262: option is not present, then the private key is read from the same file
                   2263: as the certificate.
                   2264: If neither option is specified, the OCSP request is not signed.
                   2265: .It Fl trust_other
                   2266: The certificates specified by the
                   2267: .Fl verify_other
                   2268: option should be explicitly trusted and no additional checks will be
                   2269: performed on them.
                   2270: This is useful when the complete responder certificate chain is not available
                   2271: or trusting a root CA is not appropriate.
                   2272: .It Fl url Ar responder_url
                   2273: Specify the responder URL.
                   2274: Both HTTP and HTTPS
                   2275: .Pq SSL/TLS
                   2276: URLs can be specified.
                   2277: .It Fl VAfile Ar file
1.55      jmc      2278: A file containing explicitly trusted responder certificates.
1.1       jsing    2279: Equivalent to the
                   2280: .Fl verify_other
                   2281: and
                   2282: .Fl trust_other
                   2283: options.
                   2284: .It Fl validity_period Ar nsec , Fl status_age Ar age
1.55      jmc      2285: The range of times, in seconds, which will be tolerated in an OCSP response.
                   2286: Each certificate status response includes a notBefore time
                   2287: and an optional notAfter time.
1.1       jsing    2288: The current time should fall between these two values,
                   2289: but the interval between the two times may be only a few seconds.
                   2290: In practice the OCSP responder and clients' clocks may not be precisely
                   2291: synchronised and so such a check may fail.
                   2292: To avoid this the
                   2293: .Fl validity_period
                   2294: option can be used to specify an acceptable error range in seconds,
1.55      jmc      2295: the default value being 5 minutes.
1.1       jsing    2296: .Pp
1.55      jmc      2297: If the notAfter time is omitted from a response,
                   2298: it means that new status information is immediately available.
                   2299: In this case the age of the notBefore field is checked
                   2300: to see it is not older than
1.1       jsing    2301: .Ar age
                   2302: seconds old.
                   2303: By default, this additional check is not performed.
                   2304: .It Fl verify_other Ar file
1.55      jmc      2305: A file containing additional certificates to search
                   2306: when attempting to locate the OCSP response signing certificate.
                   2307: Some responders omit the actual signer's certificate from the response,
                   2308: so this can be used to supply the necessary certificate.
1.1       jsing    2309: .El
1.55      jmc      2310: .Pp
                   2311: The options for the OCSP server are as follows:
1.1       jsing    2312: .Bl -tag -width "XXXX"
                   2313: .It Fl CA Ar file
                   2314: CA certificate corresponding to the revocation information in
                   2315: .Ar indexfile .
                   2316: .It Fl index Ar indexfile
                   2317: .Ar indexfile
1.55      jmc      2318: is a text index file in ca format
                   2319: containing certificate revocation information.
1.1       jsing    2320: .Pp
1.55      jmc      2321: If this option is specified,
1.1       jsing    2322: .Nm ocsp
1.55      jmc      2323: is in responder mode, otherwise it is in client mode.
                   2324: The requests the responder processes can be either specified on
1.1       jsing    2325: the command line (using the
                   2326: .Fl issuer
                   2327: and
                   2328: .Fl serial
                   2329: options), supplied in a file (using the
                   2330: .Fl respin
1.55      jmc      2331: option), or via external OCSP clients (if
1.1       jsing    2332: .Ar port
                   2333: or
                   2334: .Ar url
                   2335: is specified).
                   2336: .Pp
1.55      jmc      2337: If this option is present, then the
1.1       jsing    2338: .Fl CA
                   2339: and
                   2340: .Fl rsigner
                   2341: options must also be present.
                   2342: .It Fl nmin Ar minutes , Fl ndays Ar days
                   2343: Number of
                   2344: .Ar minutes
                   2345: or
                   2346: .Ar days
1.55      jmc      2347: when fresh revocation information is available:
                   2348: used in the nextUpdate field.
                   2349: If neither option is present,
                   2350: the nextUpdate field is omitted,
                   2351: meaning fresh revocation information is immediately available.
1.1       jsing    2352: .It Fl nrequest Ar number
1.55      jmc      2353: Exit after receiving
1.1       jsing    2354: .Ar number
1.55      jmc      2355: requests (the default is unlimited).
1.1       jsing    2356: .It Fl port Ar portnum
                   2357: Port to listen for OCSP requests on.
1.55      jmc      2358: May also be specified using the
1.1       jsing    2359: .Fl url
                   2360: option.
                   2361: .It Fl resp_key_id
                   2362: Identify the signer certificate using the key ID;
1.55      jmc      2363: the default is to use the subject name.
1.1       jsing    2364: .It Fl resp_no_certs
                   2365: Don't include any certificates in the OCSP response.
                   2366: .It Fl rkey Ar file
                   2367: The private key to sign OCSP responses with;
                   2368: if not present, the file specified in the
                   2369: .Fl rsigner
                   2370: option is used.
                   2371: .It Fl rother Ar file
                   2372: Additional certificates to include in the OCSP response.
                   2373: .It Fl rsigner Ar file
                   2374: The certificate to sign OCSP responses with.
                   2375: .El
                   2376: .Pp
                   2377: Initially the OCSP responder certificate is located and the signature on
                   2378: the OCSP request checked using the responder certificate's public key.
                   2379: Then a normal certificate verify is performed on the OCSP responder certificate
                   2380: building up a certificate chain in the process.
                   2381: The locations of the trusted certificates used to build the chain can be
                   2382: specified by the
                   2383: .Fl CAfile
                   2384: and
                   2385: .Fl CApath
                   2386: options or they will be looked for in the standard
1.55      jmc      2387: .Nm openssl
                   2388: certificates directory.
1.1       jsing    2389: .Pp
1.55      jmc      2390: If the initial verify fails, the OCSP verify process halts with an error.
1.1       jsing    2391: Otherwise the issuing CA certificate in the request is compared to the OCSP
                   2392: responder certificate: if there is a match then the OCSP verify succeeds.
                   2393: .Pp
                   2394: Otherwise the OCSP responder certificate's CA is checked against the issuing
                   2395: CA certificate in the request.
                   2396: If there is a match and the OCSPSigning extended key usage is present
                   2397: in the OCSP responder certificate, then the OCSP verify succeeds.
                   2398: .Pp
                   2399: Otherwise the root CA of the OCSP responder's CA is checked to see if it
                   2400: is trusted for OCSP signing.
                   2401: If it is, the OCSP verify succeeds.
                   2402: .Pp
                   2403: If none of these checks is successful, the OCSP verify fails.
                   2404: What this effectively means is that if the OCSP responder certificate is
                   2405: authorised directly by the CA it is issuing revocation information about
1.55      jmc      2406: (and it is correctly configured),
1.1       jsing    2407: then verification will succeed.
                   2408: .Pp
1.55      jmc      2409: If the OCSP responder is a global responder,
                   2410: which can give details about multiple CAs
                   2411: and has its own separate certificate chain,
                   2412: then its root CA can be trusted for OCSP signing.
1.1       jsing    2413: For example:
                   2414: .Bd -literal -offset indent
                   2415: $ openssl x509 -in ocspCA.pem -addtrust OCSPSigning \e
                   2416:        -out trustedCA.pem
                   2417: .Ed
                   2418: .Pp
                   2419: Alternatively, the responder certificate itself can be explicitly trusted
                   2420: with the
                   2421: .Fl VAfile
                   2422: option.
                   2423: .Sh PASSWD
                   2424: .nr nS 1
                   2425: .Nm "openssl passwd"
                   2426: .Op Fl 1 | apr1 | crypt
                   2427: .Op Fl in Ar file
                   2428: .Op Fl noverify
                   2429: .Op Fl quiet
                   2430: .Op Fl reverse
                   2431: .Op Fl salt Ar string
                   2432: .Op Fl stdin
                   2433: .Op Fl table
                   2434: .Op Ar password
                   2435: .nr nS 0
                   2436: .Pp
                   2437: The
                   2438: .Nm passwd
1.56      jmc      2439: command computes the hash of a password.
1.1       jsing    2440: .Pp
                   2441: The options are as follows:
                   2442: .Bl -tag -width Ds
                   2443: .It Fl 1
                   2444: Use the MD5 based
                   2445: .Bx
                   2446: password algorithm
1.56      jmc      2447: .Qq 1 .
1.1       jsing    2448: .It Fl apr1
                   2449: Use the
1.56      jmc      2450: .Qq apr1
1.1       jsing    2451: algorithm
1.56      jmc      2452: .Po
                   2453: Apache variant of the
1.1       jsing    2454: .Bx
1.56      jmc      2455: algorithm
                   2456: .Pc .
1.1       jsing    2457: .It Fl crypt
                   2458: Use the
1.56      jmc      2459: .Qq crypt
                   2460: algorithm (the default).
1.1       jsing    2461: .It Fl in Ar file
                   2462: Read passwords from
                   2463: .Ar file .
                   2464: .It Fl noverify
                   2465: Don't verify when reading a password from the terminal.
                   2466: .It Fl quiet
                   2467: Don't output warnings when passwords given on the command line are truncated.
                   2468: .It Fl reverse
                   2469: Switch table columns.
                   2470: This only makes sense in conjunction with the
                   2471: .Fl table
                   2472: option.
                   2473: .It Fl salt Ar string
1.56      jmc      2474: Use the salt specified by
                   2475: .Ar string .
1.1       jsing    2476: When reading a password from the terminal, this implies
                   2477: .Fl noverify .
                   2478: .It Fl stdin
1.56      jmc      2479: Read passwords from standard input.
1.1       jsing    2480: .It Fl table
                   2481: In the output list, prepend the cleartext password and a TAB character
                   2482: to each password hash.
                   2483: .El
                   2484: .Sh PKCS7
                   2485: .nr nS 1
                   2486: .Nm "openssl pkcs7"
                   2487: .Op Fl in Ar file
1.57    ! jmc      2488: .Op Fl inform Cm der | pem
1.1       jsing    2489: .Op Fl noout
                   2490: .Op Fl out Ar file
1.57    ! jmc      2491: .Op Fl outform Cm der | pem
1.1       jsing    2492: .Op Fl print_certs
                   2493: .Op Fl text
                   2494: .nr nS 0
                   2495: .Pp
                   2496: The
                   2497: .Nm pkcs7
                   2498: command processes PKCS#7 files in DER or PEM format.
1.57    ! jmc      2499: The PKCS#7 routines only understand PKCS#7 v 1.5 as specified in RFC 2315.
        !          2500: They cannot currently parse, for example, the new CMS as described in RFC 2630.
        !          2501: .Pp
        !          2502: The PEM PKCS#7 format uses the header and footer lines:
        !          2503: .Bd -unfilled -offset indent
        !          2504: -----BEGIN PKCS7-----
        !          2505: -----END PKCS7-----
        !          2506: .Ed
        !          2507: .Pp
        !          2508: For compatibility with some CAs it will also accept:
        !          2509: .Bd -unfilled -offset indent
        !          2510: -----BEGIN CERTIFICATE-----
        !          2511: -----END CERTIFICATE-----
        !          2512: .Ed
1.1       jsing    2513: .Pp
                   2514: The options are as follows:
                   2515: .Bl -tag -width Ds
                   2516: .It Fl in Ar file
1.57    ! jmc      2517: The input file to read from,
        !          2518: or standard input if not specified.
        !          2519: .It Fl inform Cm der | pem
        !          2520: The input format.
        !          2521: .Cm der
1.1       jsing    2522: format is a DER-encoded PKCS#7 v1.5 structure.
1.57    ! jmc      2523: .Cm pem
        !          2524: (the default)
1.1       jsing    2525: is a base64-encoded version of the DER form with header and footer lines.
                   2526: .It Fl noout
                   2527: Don't output the encoded version of the PKCS#7 structure
                   2528: (or certificates if
                   2529: .Fl print_certs
                   2530: is set).
                   2531: .It Fl out Ar file
1.57    ! jmc      2532: The output to write to,
        !          2533: or standard output if not specified.
        !          2534: .It Fl outform Cm der | pem
        !          2535: The output format.
1.1       jsing    2536: .It Fl print_certs
1.57    ! jmc      2537: Print any certificates or CRLs contained in the file,
        !          2538: preceded by their subject and issuer names in a one-line format.
1.1       jsing    2539: .It Fl text
1.57    ! jmc      2540: Print certificate details in full rather than just subject and issuer names.
1.1       jsing    2541: .El
                   2542: .\"
                   2543: .\" PKCS8
                   2544: .\"
                   2545: .Sh PKCS8
                   2546: .nr nS 1
                   2547: .Nm "openssl pkcs8"
                   2548: .Bk -words
                   2549: .Op Fl embed
                   2550: .Op Fl in Ar file
                   2551: .Op Fl inform Ar DER | PEM
                   2552: .Op Fl nocrypt
                   2553: .Op Fl noiter
                   2554: .Op Fl nooct
                   2555: .Op Fl nsdb
                   2556: .Op Fl out Ar file
                   2557: .Op Fl outform Ar DER | PEM
                   2558: .Op Fl passin Ar arg
                   2559: .Op Fl passout Ar arg
                   2560: .Op Fl topk8
                   2561: .Op Fl v1 Ar alg
                   2562: .Op Fl v2 Ar alg
                   2563: .Ek
                   2564: .nr nS 0
                   2565: .Pp
                   2566: The
                   2567: .Nm pkcs8
                   2568: command processes private keys in PKCS#8 format.
                   2569: It can handle both unencrypted PKCS#8 PrivateKeyInfo format
                   2570: and EncryptedPrivateKeyInfo format with a variety of PKCS#5
                   2571: .Pq v1.5 and v2.0
                   2572: and PKCS#12 algorithms.
                   2573: .Pp
                   2574: The options are as follows:
                   2575: .Bl -tag -width Ds
                   2576: .It Fl embed
                   2577: This option generates DSA keys in a broken format.
                   2578: The DSA parameters are embedded inside the
                   2579: .Em PrivateKey
                   2580: structure.
                   2581: In this form the OCTET STRING contains an ASN1 SEQUENCE consisting of
                   2582: two structures:
                   2583: a SEQUENCE containing the parameters and an ASN1 INTEGER containing
                   2584: the private key.
                   2585: .It Fl in Ar file
                   2586: This specifies the input
                   2587: .Ar file
                   2588: to read a key from, or standard input if this option is not specified.
                   2589: If the key is encrypted, a pass phrase will be prompted for.
                   2590: .It Fl inform Ar DER | PEM
                   2591: This specifies the input format.
                   2592: If a PKCS#8 format key is expected on input,
                   2593: then either a
                   2594: DER- or PEM-encoded version of a PKCS#8 key will be expected.
                   2595: Otherwise the DER or PEM format of the traditional format private key is used.
                   2596: .It Fl nocrypt
                   2597: PKCS#8 keys generated or input are normally PKCS#8
                   2598: .Em EncryptedPrivateKeyInfo
                   2599: structures using an appropriate password-based encryption algorithm.
                   2600: With this option, an unencrypted
                   2601: .Em PrivateKeyInfo
                   2602: structure is expected or output.
                   2603: This option does not encrypt private keys at all and should only be used
                   2604: when absolutely necessary.
                   2605: Certain software such as some versions of Java code signing software use
                   2606: unencrypted private keys.
                   2607: .It Fl noiter
                   2608: Use an iteration count of 1.
                   2609: See the
                   2610: .Sx PKCS12
                   2611: section below for a detailed explanation of this option.
                   2612: .It Fl nooct
                   2613: This option generates RSA private keys in a broken format that some software
                   2614: uses.
                   2615: Specifically the private key should be enclosed in an OCTET STRING,
                   2616: but some software just includes the structure itself without the
                   2617: surrounding OCTET STRING.
                   2618: .It Fl nsdb
                   2619: This option generates DSA keys in a broken format compatible with Netscape
                   2620: private key databases.
                   2621: The
                   2622: .Em PrivateKey
                   2623: contains a SEQUENCE consisting of the public and private keys, respectively.
                   2624: .It Fl out Ar file
                   2625: This specifies the output
                   2626: .Ar file
                   2627: to write a key to, or standard output by default.
                   2628: If any encryption options are set, a pass phrase will be prompted for.
                   2629: The output filename should
                   2630: .Em not
                   2631: be the same as the input filename.
                   2632: .It Fl outform Ar DER | PEM
                   2633: This specifies the output format; the options have the same meaning as the
                   2634: .Fl inform
                   2635: option.
                   2636: .It Fl passin Ar arg
                   2637: The key password source.
                   2638: .It Fl passout Ar arg
                   2639: The output file password source.
                   2640: .It Fl topk8
                   2641: Normally, a PKCS#8 private key is expected on input and a traditional format
                   2642: private key will be written.
                   2643: With the
                   2644: .Fl topk8
                   2645: option the situation is reversed:
                   2646: it reads a traditional format private key and writes a PKCS#8 format key.
                   2647: .It Fl v1 Ar alg
                   2648: This option specifies a PKCS#5 v1.5 or PKCS#12 algorithm to use.
                   2649: A complete list of possible algorithms is included below.
                   2650: .It Fl v2 Ar alg
                   2651: This option enables the use of PKCS#5 v2.0 algorithms.
                   2652: Normally, PKCS#8 private keys are encrypted with the password-based
                   2653: encryption algorithm called
                   2654: .Em pbeWithMD5AndDES-CBC ;
                   2655: this uses 56-bit DES encryption but it was the strongest encryption
                   2656: algorithm supported in PKCS#5 v1.5.
                   2657: Using the
                   2658: .Fl v2
                   2659: option PKCS#5 v2.0 algorithms are used which can use any
                   2660: encryption algorithm such as 168-bit triple DES or 128-bit RC2, however
                   2661: not many implementations support PKCS#5 v2.0 yet.
                   2662: If using private keys with
                   2663: .Nm OpenSSL
                   2664: then this doesn't matter.
                   2665: .Pp
                   2666: The
                   2667: .Ar alg
                   2668: argument is the encryption algorithm to use; valid values include
                   2669: .Ar des , des3 ,
                   2670: and
                   2671: .Ar rc2 .
                   2672: It is recommended that
                   2673: .Ar des3
                   2674: is used.
                   2675: .El
                   2676: .Sh PKCS8 NOTES
                   2677: The encrypted form of a PEM-encoded PKCS#8 file uses the following
                   2678: headers and footers:
                   2679: .Bd -unfilled -offset indent
                   2680: -----BEGIN ENCRYPTED PRIVATE KEY-----
                   2681: -----END ENCRYPTED PRIVATE KEY-----
                   2682: .Ed
                   2683: .Pp
                   2684: The unencrypted form uses:
                   2685: .Bd -unfilled -offset indent
                   2686: -----BEGIN PRIVATE KEY-----
                   2687: -----END PRIVATE KEY-----
                   2688: .Ed
                   2689: .Pp
                   2690: Private keys encrypted using PKCS#5 v2.0 algorithms and high iteration
                   2691: counts are more secure than those encrypted using the traditional
                   2692: .Nm SSLeay
                   2693: compatible formats.
                   2694: So if additional security is considered important, the keys should be converted.
                   2695: .Pp
                   2696: The default encryption is only 56 bits because this is the encryption
                   2697: that most current implementations of PKCS#8 support.
                   2698: .Pp
                   2699: Some software may use PKCS#12 password-based encryption algorithms
                   2700: with PKCS#8 format private keys: these are handled automatically
                   2701: but there is no option to produce them.
                   2702: .Pp
                   2703: It is possible to write out
                   2704: DER-encoded encrypted private keys in PKCS#8 format because the encryption
                   2705: details are included at an ASN1
                   2706: level whereas the traditional format includes them at a PEM level.
                   2707: .Sh PKCS#5 V1.5 AND PKCS#12 ALGORITHMS
                   2708: Various algorithms can be used with the
                   2709: .Fl v1
                   2710: command line option, including PKCS#5 v1.5 and PKCS#12.
                   2711: These are described in more detail below.
                   2712: .Pp
                   2713: .Bl -tag -width "XXXX" -compact
1.29      bcook    2714: .It Ar PBE-MD5-DES
1.1       jsing    2715: These algorithms were included in the original PKCS#5 v1.5 specification.
                   2716: They only offer 56 bits of protection since they both use DES.
                   2717: .Pp
1.29      bcook    2718: .It Ar PBE-SHA1-RC2-64 | PBE-MD5-RC2-64 | PBE-SHA1-DES
1.1       jsing    2719: These algorithms are not mentioned in the original PKCS#5 v1.5 specification
                   2720: but they use the same key derivation algorithm and are supported by some
                   2721: software.
                   2722: They are mentioned in PKCS#5 v2.0.
                   2723: They use either 64-bit RC2 or 56-bit DES.
                   2724: .Pp
                   2725: .It Ar PBE-SHA1-RC4-128 | PBE-SHA1-RC4-40 | PBE-SHA1-3DES | PBE-SHA1-2DES
                   2726: .It Ar PBE-SHA1-RC2-128 | PBE-SHA1-RC2-40
                   2727: These algorithms use the PKCS#12 password-based encryption algorithm and
                   2728: allow strong encryption algorithms like triple DES or 128-bit RC2 to be used.
                   2729: .El
                   2730: .Sh PKCS8 EXAMPLES
                   2731: Convert a private key from traditional to PKCS#5 v2.0 format using triple DES:
                   2732: .Pp
                   2733: .Dl "$ openssl pkcs8 -in key.pem -topk8 -v2 des3 -out enckey.pem"
                   2734: .Pp
                   2735: Convert a private key to PKCS#8 using a PKCS#5 1.5 compatible algorithm
                   2736: .Pq DES :
                   2737: .Pp
                   2738: .Dl $ openssl pkcs8 -in key.pem -topk8 -out enckey.pem
                   2739: .Pp
                   2740: Convert a private key to PKCS#8 using a PKCS#12 compatible algorithm
                   2741: .Pq 3DES :
                   2742: .Bd -literal -offset indent
                   2743: $ openssl pkcs8 -in key.pem -topk8 -out enckey.pem \e
                   2744:        -v1 PBE-SHA1-3DES
                   2745: .Ed
                   2746: .Pp
                   2747: Read a DER-unencrypted PKCS#8 format private key:
                   2748: .Pp
                   2749: .Dl "$ openssl pkcs8 -inform DER -nocrypt -in key.der -out key.pem"
                   2750: .Pp
                   2751: Convert a private key from any PKCS#8 format to traditional format:
                   2752: .Pp
                   2753: .Dl $ openssl pkcs8 -in pk8.pem -out key.pem
                   2754: .Sh PKCS8 STANDARDS
                   2755: Test vectors from this PKCS#5 v2.0 implementation were posted to the
                   2756: pkcs-tng mailing list using triple DES, DES and RC2 with high iteration counts;
                   2757: several people confirmed that they could decrypt the private
                   2758: keys produced and therefore it can be assumed that the PKCS#5 v2.0
                   2759: implementation is reasonably accurate at least as far as these
                   2760: algorithms are concerned.
                   2761: .Pp
                   2762: The format of PKCS#8 DSA
                   2763: .Pq and other
                   2764: private keys is not well documented:
                   2765: it is hidden away in PKCS#11 v2.01, section 11.9;
                   2766: .Nm OpenSSL Ns Li 's
                   2767: default DSA PKCS#8 private key format complies with this standard.
                   2768: .Sh PKCS8 BUGS
                   2769: There should be an option that prints out the encryption algorithm
                   2770: in use and other details such as the iteration count.
                   2771: .Pp
                   2772: PKCS#8 using triple DES and PKCS#5 v2.0 should be the default private
                   2773: key format; for
                   2774: .Nm OpenSSL
                   2775: compatibility, several of the utilities use the old format at present.
                   2776: .\"
                   2777: .\" PKCS12
                   2778: .\"
                   2779: .Sh PKCS12
                   2780: .nr nS 1
                   2781: .Nm "openssl pkcs12"
                   2782: .Bk -words
                   2783: .Oo
                   2784: .Fl aes128 | aes192 | aes256 |
                   2785: .Fl des | des3
                   2786: .Oc
                   2787: .Op Fl cacerts
                   2788: .Op Fl CAfile Ar file
                   2789: .Op Fl caname Ar name
                   2790: .Op Fl CApath Ar directory
                   2791: .Op Fl certfile Ar file
                   2792: .Op Fl certpbe Ar alg
                   2793: .Op Fl chain
                   2794: .Op Fl clcerts
                   2795: .Op Fl CSP Ar name
                   2796: .Op Fl descert
                   2797: .Op Fl export
                   2798: .Op Fl in Ar file
                   2799: .Op Fl info
                   2800: .Op Fl inkey Ar file
                   2801: .Op Fl keyex
                   2802: .Op Fl keypbe Ar alg
                   2803: .Op Fl keysig
                   2804: .Op Fl macalg Ar alg
                   2805: .Op Fl maciter
                   2806: .Op Fl name Ar name
                   2807: .Op Fl nocerts
                   2808: .Op Fl nodes
                   2809: .Op Fl noiter
                   2810: .Op Fl nokeys
                   2811: .Op Fl nomac
                   2812: .Op Fl nomaciter
                   2813: .Op Fl nomacver
                   2814: .Op Fl noout
                   2815: .Op Fl out Ar file
                   2816: .Op Fl passin Ar arg
                   2817: .Op Fl passout Ar arg
                   2818: .Op Fl twopass
                   2819: .Ek
                   2820: .nr nS 0
                   2821: .Pp
                   2822: The
                   2823: .Nm pkcs12
                   2824: command allows PKCS#12 files
                   2825: .Pq sometimes referred to as PFX files
                   2826: to be created and parsed.
                   2827: PKCS#12 files are used by several programs including Netscape, MSIE
                   2828: and MS Outlook.
                   2829: .Pp
                   2830: There are a lot of options; the meaning of some depends on whether a
                   2831: PKCS#12 file is being created or parsed.
                   2832: By default, a PKCS#12 file is parsed;
                   2833: a PKCS#12 file can be created by using the
                   2834: .Fl export
                   2835: option
                   2836: .Pq see below .
                   2837: .Sh PKCS12 PARSING OPTIONS
                   2838: .Bl -tag -width "XXXX"
                   2839: .It Xo
                   2840: .Fl aes128 | aes192 | aes256 |
                   2841: .Fl des | des3
                   2842: .Xc
                   2843: Use AES, DES, or triple DES, respectively,
                   2844: to encrypt private keys before outputting.
                   2845: The default is triple DES.
                   2846: .It Fl cacerts
                   2847: Only output CA certificates
                   2848: .Pq not client certificates .
                   2849: .It Fl clcerts
                   2850: Only output client certificates
                   2851: .Pq not CA certificates .
                   2852: .It Fl in Ar file
                   2853: This specifies the
                   2854: .Ar file
                   2855: of the PKCS#12 file to be parsed.
                   2856: Standard input is used by default.
                   2857: .It Fl info
                   2858: Output additional information about the PKCS#12 file structure,
                   2859: algorithms used, and iteration counts.
                   2860: .It Fl nocerts
                   2861: No certificates at all will be output.
                   2862: .It Fl nodes
                   2863: Don't encrypt the private keys at all.
                   2864: .It Fl nokeys
                   2865: No private keys will be output.
                   2866: .It Fl nomacver
                   2867: Don't attempt to verify the integrity MAC before reading the file.
                   2868: .It Fl noout
                   2869: This option inhibits output of the keys and certificates to the output file
                   2870: version of the PKCS#12 file.
                   2871: .It Fl out Ar file
                   2872: The
                   2873: .Ar file
                   2874: to write certificates and private keys to, standard output by default.
                   2875: They are all written in PEM format.
                   2876: .It Fl passin Ar arg
                   2877: The key password source.
                   2878: .It Fl passout Ar arg
                   2879: The output file password source.
                   2880: .It Fl twopass
                   2881: Prompt for separate integrity and encryption passwords: most software
                   2882: always assumes these are the same so this option will render such
                   2883: PKCS#12 files unreadable.
                   2884: .El
                   2885: .Sh PKCS12 FILE CREATION OPTIONS
                   2886: .Bl -tag -width "XXXX"
                   2887: .It Fl CAfile Ar file
                   2888: CA storage as a file.
                   2889: .It Fl CApath Ar directory
                   2890: CA storage as a directory.
                   2891: This directory must be a standard certificate directory:
                   2892: that is, a hash of each subject name (using
                   2893: .Cm x509 -hash )
                   2894: should be linked to each certificate.
                   2895: .It Fl caname Ar name
                   2896: This specifies the
                   2897: .Qq friendly name
                   2898: for other certificates.
                   2899: This option may be used multiple times to specify names for all certificates
                   2900: in the order they appear.
                   2901: Netscape ignores friendly names on other certificates,
                   2902: whereas MSIE displays them.
                   2903: .It Fl certfile Ar file
                   2904: A file to read additional certificates from.
                   2905: .It Fl certpbe Ar alg , Fl keypbe Ar alg
                   2906: These options allow the algorithm used to encrypt the private key and
                   2907: certificates to be selected.
                   2908: Any PKCS#5 v1.5 or PKCS#12 PBE algorithm name can be used (see the
                   2909: .Sx PKCS12 NOTES
                   2910: section for more information).
                   2911: If a cipher name
                   2912: (as output by the
                   2913: .Cm list-cipher-algorithms
                   2914: command) is specified then it
                   2915: is used with PKCS#5 v2.0.
                   2916: For interoperability reasons it is advisable to only use PKCS#12 algorithms.
                   2917: .It Fl chain
                   2918: If this option is present, an attempt is made to include the entire
                   2919: certificate chain of the user certificate.
                   2920: The standard CA store is used for this search.
                   2921: If the search fails, it is considered a fatal error.
                   2922: .It Fl CSP Ar name
                   2923: Write
                   2924: .Ar name
                   2925: as a Microsoft CSP name.
                   2926: .It Fl descert
                   2927: Encrypt the certificate using triple DES; this may render the PKCS#12
                   2928: file unreadable by some
                   2929: .Qq export grade
                   2930: software.
                   2931: By default, the private key is encrypted using triple DES and the
                   2932: certificate using 40-bit RC2.
                   2933: .It Fl export
                   2934: This option specifies that a PKCS#12 file will be created rather than
                   2935: parsed.
                   2936: .It Fl in Ar file
                   2937: The
                   2938: .Ar file
                   2939: to read certificates and private keys from, standard input by default.
                   2940: They must all be in PEM format.
                   2941: The order doesn't matter but one private key and its corresponding
                   2942: certificate should be present.
                   2943: If additional certificates are present, they will also be included
                   2944: in the PKCS#12 file.
                   2945: .It Fl inkey Ar file
                   2946: File to read private key from.
                   2947: If not present, a private key must be present in the input file.
                   2948: .It Fl keyex | keysig
                   2949: Specifies that the private key is to be used for key exchange or just signing.
                   2950: This option is only interpreted by MSIE and similar MS software.
                   2951: Normally,
                   2952: .Qq export grade
                   2953: software will only allow 512-bit RSA keys to be
                   2954: used for encryption purposes, but arbitrary length keys for signing.
                   2955: The
                   2956: .Fl keysig
                   2957: option marks the key for signing only.
                   2958: Signing only keys can be used for S/MIME signing, authenticode
                   2959: .Pq ActiveX control signing
                   2960: and SSL client authentication;
                   2961: however, due to a bug only MSIE 5.0 and later support
                   2962: the use of signing only keys for SSL client authentication.
                   2963: .It Fl macalg Ar alg
                   2964: Specify the MAC digest algorithm.
                   2965: If not included then SHA1 is used.
                   2966: .It Fl maciter
                   2967: This option is included for compatibility with previous versions; it used
                   2968: to be needed to use MAC iterations counts but they are now used by default.
                   2969: .It Fl name Ar name
                   2970: This specifies the
                   2971: .Qq friendly name
                   2972: for the certificate and private key.
                   2973: This name is typically displayed in list boxes by software importing the file.
                   2974: .It Fl nomac
                   2975: Don't attempt to provide the MAC integrity.
                   2976: .It Fl nomaciter , noiter
                   2977: These options affect the iteration counts on the MAC and key algorithms.
                   2978: Unless you wish to produce files compatible with MSIE 4.0, you should leave
                   2979: these options alone.
                   2980: .Pp
                   2981: To discourage attacks by using large dictionaries of common passwords,
                   2982: the algorithm that derives keys from passwords can have an iteration count
                   2983: applied to it: this causes a certain part of the algorithm to be repeated
                   2984: and slows it down.
                   2985: The MAC is used to check the file integrity but since it will normally
                   2986: have the same password as the keys and certificates it could also be attacked.
                   2987: By default, both MAC and encryption iteration counts are set to 2048;
                   2988: using these options the MAC and encryption iteration counts can be set to 1.
                   2989: Since this reduces the file security you should not use these options
                   2990: unless you really have to.
                   2991: Most software supports both MAC and key iteration counts.
                   2992: MSIE 4.0 doesn't support MAC iteration counts, so it needs the
                   2993: .Fl nomaciter
                   2994: option.
                   2995: .It Fl out Ar file
                   2996: This specifies
                   2997: .Ar file
                   2998: to write the PKCS#12 file to.
                   2999: Standard output is used by default.
                   3000: .It Fl passin Ar arg
                   3001: The key password source.
                   3002: .It Fl passout Ar arg
                   3003: The output file password source.
                   3004: .El
                   3005: .Sh PKCS12 NOTES
                   3006: Although there are a large number of options,
                   3007: most of them are very rarely used.
                   3008: For PKCS#12 file parsing, only
                   3009: .Fl in
                   3010: and
                   3011: .Fl out
                   3012: need to be used for PKCS#12 file creation.
                   3013: .Fl export
                   3014: and
                   3015: .Fl name
                   3016: are also used.
                   3017: .Pp
                   3018: If none of the
                   3019: .Fl clcerts , cacerts ,
                   3020: or
                   3021: .Fl nocerts
                   3022: options are present, then all certificates will be output in the order
                   3023: they appear in the input PKCS#12 files.
                   3024: There is no guarantee that the first certificate present is
                   3025: the one corresponding to the private key.
                   3026: Certain software which requires a private key and certificate and assumes
                   3027: the first certificate in the file is the one corresponding to the private key:
                   3028: this may not always be the case.
                   3029: Using the
                   3030: .Fl clcerts
                   3031: option will solve this problem by only outputting the certificate
                   3032: corresponding to the private key.
                   3033: If the CA certificates are required, they can be output to a separate
                   3034: file using the
                   3035: .Fl nokeys
                   3036: and
                   3037: .Fl cacerts
                   3038: options to just output CA certificates.
                   3039: .Pp
                   3040: The
                   3041: .Fl keypbe
                   3042: and
                   3043: .Fl certpbe
                   3044: algorithms allow the precise encryption algorithms for private keys
                   3045: and certificates to be specified.
                   3046: Normally, the defaults are fine but occasionally software can't handle
                   3047: triple DES encrypted private keys;
                   3048: then the option
                   3049: .Fl keypbe Ar PBE-SHA1-RC2-40
                   3050: can be used to reduce the private key encryption to 40-bit RC2.
                   3051: A complete description of all algorithms is contained in the
                   3052: .Sx PKCS8
                   3053: section above.
                   3054: .Sh PKCS12 EXAMPLES
                   3055: Parse a PKCS#12 file and output it to a file:
                   3056: .Pp
                   3057: .Dl $ openssl pkcs12 -in file.p12 -out file.pem
                   3058: .Pp
                   3059: Output only client certificates to a file:
                   3060: .Pp
                   3061: .Dl $ openssl pkcs12 -in file.p12 -clcerts -out file.pem
                   3062: .Pp
                   3063: Don't encrypt the private key:
                   3064: .Pp
                   3065: .Dl $ openssl pkcs12 -in file.p12 -out file.pem -nodes
                   3066: .Pp
                   3067: Print some info about a PKCS#12 file:
                   3068: .Pp
                   3069: .Dl $ openssl pkcs12 -in file.p12 -info -noout
                   3070: .Pp
                   3071: Create a PKCS#12 file:
                   3072: .Bd -literal -offset indent
                   3073: $ openssl pkcs12 -export -in file.pem -out file.p12 \e
                   3074:        -name "My Certificate"
                   3075: .Ed
                   3076: .Pp
                   3077: Include some extra certificates:
                   3078: .Bd -literal -offset indent
                   3079: $ openssl pkcs12 -export -in file.pem -out file.p12 \e
                   3080:        -name "My Certificate" -certfile othercerts.pem
                   3081: .Ed
                   3082: .Sh PKCS12 BUGS
                   3083: Some would argue that the PKCS#12 standard is one big bug :\-)
                   3084: .Pp
                   3085: Versions of
                   3086: .Nm OpenSSL
                   3087: before 0.9.6a had a bug in the PKCS#12 key generation routines.
                   3088: Under rare circumstances this could produce a PKCS#12 file encrypted
                   3089: with an invalid key.
                   3090: As a result some PKCS#12 files which triggered this bug
                   3091: from other implementations
                   3092: .Pq MSIE or Netscape
                   3093: could not be decrypted by
                   3094: .Nm OpenSSL
                   3095: and similarly
                   3096: .Nm OpenSSL
                   3097: could produce PKCS#12 files which could not be decrypted by other
                   3098: implementations.
                   3099: The chances of producing such a file are relatively small: less than 1 in 256.
                   3100: .Pp
                   3101: A side effect of fixing this bug is that any old invalidly encrypted PKCS#12
                   3102: files can no longer be parsed by the fixed version.
                   3103: Under such circumstances the
                   3104: .Nm pkcs12
                   3105: utility will report that the MAC is OK but fail with a decryption
                   3106: error when extracting private keys.
                   3107: .Pp
                   3108: This problem can be resolved by extracting the private keys and certificates
                   3109: from the PKCS#12 file using an older version of
                   3110: .Nm OpenSSL
                   3111: and recreating
                   3112: the PKCS#12 file from the keys and certificates using a newer version of
                   3113: .Nm OpenSSL .
                   3114: For example:
                   3115: .Bd -literal -offset indent
                   3116: $ old-openssl -in bad.p12 -out keycerts.pem
                   3117: $ openssl -in keycerts.pem -export -name "My PKCS#12 file" \e
                   3118:        -out fixed.p12
                   3119: .Ed
                   3120: .\"
                   3121: .\" PKEY
                   3122: .\"
                   3123: .Sh PKEY
                   3124: .nr nS 1
                   3125: .Nm "openssl pkey"
                   3126: .Bk -words
                   3127: .Op Ar cipher
                   3128: .Op Fl in Ar file
                   3129: .Op Fl inform Ar DER | PEM
                   3130: .Op Fl noout
                   3131: .Op Fl out Ar file
                   3132: .Op Fl outform Ar DER | PEM
                   3133: .Op Fl passin Ar arg
                   3134: .Op Fl passout Ar arg
                   3135: .Op Fl pubin
                   3136: .Op Fl pubout
                   3137: .Op Fl text
                   3138: .Op Fl text_pub
                   3139: .Ek
                   3140: .nr nS 0
                   3141: .Pp
                   3142: The
                   3143: .Nm pkey
                   3144: command processes public or private keys.
                   3145: They can be converted between various forms
                   3146: and their components printed out.
                   3147: .Pp
                   3148: The options are as follows:
                   3149: .Bl -tag -width Ds
                   3150: .It Ar cipher
                   3151: These options encrypt the private key with the supplied cipher.
                   3152: Any algorithm name accepted by
                   3153: .Fn EVP_get_cipherbyname
                   3154: is acceptable, such as
                   3155: .Cm des3 .
                   3156: .It Fl in Ar file
                   3157: This specifies the input filename to read a key from,
                   3158: or standard input if this option is not specified.
                   3159: If the key is encrypted a pass phrase will be prompted for.
                   3160: .It Fl inform Ar DER | PEM
                   3161: This specifies the input format, DER or PEM.
                   3162: .It Fl noout
                   3163: Do not output the encoded version of the key.
                   3164: .It Fl out Ar file
                   3165: This specifies the output filename to write a key to,
                   3166: or standard output if this option is not specified.
                   3167: If any encryption options are set then a pass phrase
                   3168: will be prompted for.
                   3169: The output filename should
                   3170: .Em not
                   3171: be the same as the input filename.
                   3172: .It Fl outform Ar DER | PEM
                   3173: This specifies the output format;
                   3174: the options have the same meaning as the
                   3175: .Fl inform
                   3176: option.
                   3177: .It Fl passin Ar arg
                   3178: The key password source.
                   3179: .It Fl passout Ar arg
                   3180: The output file password source.
                   3181: .It Fl pubin
                   3182: By default a private key is read from the input file:
                   3183: with this option a public key is read instead.
                   3184: .It Fl pubout
                   3185: By default a private key is output:
                   3186: with this option a public key will be output instead.
                   3187: This option is automatically set if
                   3188: the input is a public key.
                   3189: .It Fl text
                   3190: Print out the various public or private key components in
                   3191: plain text in addition to the encoded version.
                   3192: .It Fl text_pub
                   3193: Print out only public key components
                   3194: even if a private key is being processed.
                   3195: .El
                   3196: .Sh PKEY EXAMPLES
                   3197: To remove the pass phrase on an RSA private key:
                   3198: .Bd -literal -offset indent
                   3199: $ openssl pkey -in key.pem -out keyout.pem
                   3200: .Ed
                   3201: .Pp
                   3202: To encrypt a private key using triple DES:
                   3203: .Bd -literal -offset indent
                   3204: $ openssl pkey -in key.pem -des3 -out keyout.pem
                   3205: .Ed
                   3206: .Pp
                   3207: To convert a private key from PEM to DER format:
                   3208: .Bd -literal -offset indent
                   3209: $ openssl pkey -in key.pem -outform DER -out keyout.der
                   3210: .Ed
                   3211: .Pp
                   3212: To print the components of a private key to standard output:
                   3213: .Bd -literal -offset indent
                   3214: $ openssl pkey -in key.pem -text -noout
                   3215: .Ed
                   3216: .Pp
                   3217: To print the public components of a private key to standard output:
                   3218: .Bd -literal -offset indent
                   3219: $ openssl pkey -in key.pem -text_pub -noout
                   3220: .Ed
                   3221: .Pp
                   3222: To just output the public part of a private key:
                   3223: .Bd -literal -offset indent
                   3224: $ openssl pkey -in key.pem -pubout -out pubkey.pem
                   3225: .Ed
                   3226: .\"
                   3227: .\" PKEYPARAM
                   3228: .\"
                   3229: .Sh PKEYPARAM
                   3230: .Cm openssl pkeyparam
                   3231: .Op Fl in Ar file
                   3232: .Op Fl noout
                   3233: .Op Fl out Ar file
                   3234: .Op Fl text
                   3235: .Pp
                   3236: The
                   3237: .Nm pkey
                   3238: command processes public or private keys.
                   3239: They can be converted between various forms and their components printed out.
                   3240: .Pp
                   3241: The options are as follows:
                   3242: .Bl -tag -width Ds
                   3243: .It Fl in Ar file
                   3244: This specifies the input filename to read parameters from,
                   3245: or standard input if this option is not specified.
                   3246: .It Fl noout
                   3247: Do not output the encoded version of the parameters.
                   3248: .It Fl out Ar file
                   3249: This specifies the output filename to write parameters to,
                   3250: or standard output if this option is not specified.
                   3251: .It Fl text
                   3252: Prints out the parameters in plain text in addition to the encoded version.
                   3253: .El
                   3254: .Sh PKEYPARAM EXAMPLES
                   3255: Print out text version of parameters:
                   3256: .Bd -literal -offset indent
                   3257: $ openssl pkeyparam -in param.pem -text
                   3258: .Ed
                   3259: .Sh PKEYPARAM NOTES
                   3260: There are no
                   3261: .Fl inform
                   3262: or
                   3263: .Fl outform
                   3264: options for this command because only PEM format is supported
                   3265: because the key type is determined by the PEM headers.
                   3266: .\"
                   3267: .\" PKEYUTL
                   3268: .\"
                   3269: .Sh PKEYUTL
                   3270: .nr nS 1
                   3271: .Nm "openssl pkeyutl"
                   3272: .Bk -words
                   3273: .Op Fl asn1parse
                   3274: .Op Fl certin
                   3275: .Op Fl decrypt
                   3276: .Op Fl derive
                   3277: .Op Fl encrypt
                   3278: .Op Fl hexdump
                   3279: .Op Fl in Ar file
                   3280: .Op Fl inkey Ar file
1.22      bcook    3281: .Op Fl keyform Ar DER | PEM
1.1       jsing    3282: .Op Fl out Ar file
                   3283: .Op Fl passin Ar arg
1.22      bcook    3284: .Op Fl peerform Ar DER | PEM
1.1       jsing    3285: .Op Fl peerkey Ar file
                   3286: .Op Fl pkeyopt Ar opt : Ns Ar value
                   3287: .Op Fl pubin
                   3288: .Op Fl rev
                   3289: .Op Fl sigfile Ar file
                   3290: .Op Fl sign
                   3291: .Op Fl verify
                   3292: .Op Fl verifyrecover
                   3293: .Ek
                   3294: .nr nS 0
                   3295: .Pp
                   3296: The
                   3297: .Nm pkeyutl
                   3298: command can be used to perform public key operations using
                   3299: any supported algorithm.
                   3300: .Pp
                   3301: The options are as follows:
                   3302: .Bl -tag -width Ds
                   3303: .It Fl asn1parse
                   3304: ASN1parse the output data.
                   3305: This is useful when combined with the
                   3306: .Fl verifyrecover
                   3307: option when an ASN1 structure is signed.
                   3308: .It Fl certin
                   3309: The input is a certificate containing a public key.
                   3310: .It Fl decrypt
                   3311: Decrypt the input data using a private key.
                   3312: .It Fl derive
                   3313: Derive a shared secret using the peer key.
                   3314: .It Fl encrypt
                   3315: Encrypt the input data using a public key.
                   3316: .It Fl hexdump
                   3317: Hex dump the output data.
                   3318: .It Fl in Ar file
                   3319: Specify the input filename to read data from,
                   3320: or standard input if this option is not specified.
                   3321: .It Fl inkey Ar file
                   3322: The input key file.
                   3323: By default it should be a private key.
1.22      bcook    3324: .It Fl keyform Ar DER | PEM
                   3325: The key format DER or PEM.
1.1       jsing    3326: .It Fl out Ar file
                   3327: Specify the output filename to write to,
                   3328: or standard output by default.
                   3329: .It Fl passin Ar arg
                   3330: The key password source.
1.22      bcook    3331: .It Fl peerform Ar DER | PEM
                   3332: The peer key format DER or PEM.
1.1       jsing    3333: .It Fl peerkey Ar file
                   3334: The peer key file, used by key derivation (agreement) operations.
                   3335: .It Fl pkeyopt Ar opt : Ns Ar value
                   3336: Public key options.
                   3337: .It Fl pubin
                   3338: The input file is a public key.
                   3339: .It Fl rev
                   3340: Reverse the order of the input buffer.
                   3341: This is useful for some libraries (such as CryptoAPI)
                   3342: which represent the buffer in little endian format.
                   3343: .It Fl sigfile Ar file
                   3344: Signature file (verify operation only).
                   3345: .It Fl sign
                   3346: Sign the input data and output the signed result.
                   3347: This requires a private key.
                   3348: .It Fl verify
                   3349: Verify the input data against the signature file and indicate if the
                   3350: verification succeeded or failed.
                   3351: .It Fl verifyrecover
                   3352: Verify the input data and output the recovered data.
                   3353: .El
                   3354: .Sh PKEYUTL NOTES
                   3355: The operations and options supported vary according to the key algorithm
                   3356: and its implementation.
                   3357: The
                   3358: .Nm OpenSSL
                   3359: operations and options are indicated below.
                   3360: .Pp
                   3361: Unless otherwise mentioned all algorithms support the
                   3362: .Ar digest : Ns Ar alg
                   3363: option which specifies the digest in use
                   3364: for sign, verify, and verifyrecover operations.
                   3365: The value
                   3366: .Ar alg
                   3367: should represent a digest name as used in the
                   3368: .Fn EVP_get_digestbyname
                   3369: function, for example
                   3370: .Cm sha1 .
                   3371: .Ss RSA algorithm
                   3372: The RSA algorithm supports the
                   3373: encrypt, decrypt, sign, verify, and verifyrecover operations in general.
                   3374: Some padding modes only support some of these
                   3375: operations however.
                   3376: .Bl -tag -width Ds
                   3377: .It rsa_padding_mode : Ns Ar mode
                   3378: This sets the RSA padding mode.
                   3379: Acceptable values for
                   3380: .Ar mode
                   3381: are
                   3382: .Cm pkcs1
                   3383: for PKCS#1 padding;
                   3384: .Cm none
                   3385: for no padding;
                   3386: .Cm oaep
                   3387: for OAEP mode;
                   3388: .Cm x931
                   3389: for X9.31 mode;
                   3390: and
                   3391: .Cm pss
                   3392: for PSS.
                   3393: .Pp
                   3394: In PKCS#1 padding if the message digest is not set then the supplied data is
                   3395: signed or verified directly instead of using a DigestInfo structure.
                   3396: If a digest is set then a DigestInfo
                   3397: structure is used and its length
                   3398: must correspond to the digest type.
                   3399: .Pp
                   3400: For oeap mode only encryption and decryption is supported.
                   3401: .Pp
                   3402: For x931 if the digest type is set it is used to format the block data;
                   3403: otherwise the first byte is used to specify the X9.31 digest ID.
                   3404: Sign, verify, and verifyrecover can be performed in this mode.
                   3405: .Pp
                   3406: For pss mode only sign and verify are supported and the digest type must be
                   3407: specified.
                   3408: .It rsa_pss_saltlen : Ns Ar len
                   3409: For pss
                   3410: mode only this option specifies the salt length.
                   3411: Two special values are supported:
                   3412: -1 sets the salt length to the digest length.
                   3413: When signing -2 sets the salt length to the maximum permissible value.
                   3414: When verifying -2 causes the salt length to be automatically determined
                   3415: based on the PSS block structure.
                   3416: .El
                   3417: .Ss DSA algorithm
                   3418: The DSA algorithm supports the sign and verify operations.
                   3419: Currently there are no additional options other than
                   3420: .Ar digest .
                   3421: Only the SHA1 digest can be used and this digest is assumed by default.
                   3422: .Ss DH algorithm
                   3423: The DH algorithm supports the derive operation
                   3424: and no additional options.
                   3425: .Ss EC algorithm
                   3426: The EC algorithm supports the sign, verify, and derive operations.
                   3427: The sign and verify operations use ECDSA and derive uses ECDH.
                   3428: Currently there are no additional options other than
                   3429: .Ar digest .
                   3430: Only the SHA1 digest can be used and this digest is assumed by default.
                   3431: .Sh PKEYUTL EXAMPLES
                   3432: Sign some data using a private key:
                   3433: .Bd -literal -offset indent
                   3434: $ openssl pkeyutl -sign -in file -inkey key.pem -out sig
                   3435: .Ed
                   3436: .Pp
                   3437: Recover the signed data (e.g. if an RSA key is used):
                   3438: .Bd -literal -offset indent
                   3439: $ openssl pkeyutl -verifyrecover -in sig -inkey key.pem
                   3440: .Ed
                   3441: .Pp
                   3442: Verify the signature (e.g. a DSA key):
                   3443: .Bd -literal -offset indent
                   3444: $ openssl pkeyutl -verify -in file -sigfile sig \e
                   3445:        -inkey key.pem
                   3446: .Ed
                   3447: .Pp
                   3448: Sign data using a message digest value (this is currently only valid for RSA):
                   3449: .Bd -literal -offset indent
                   3450: $ openssl pkeyutl -sign -in file -inkey key.pem \e
                   3451:        -out sig -pkeyopt digest:sha256
                   3452: .Ed
                   3453: .Pp
                   3454: Derive a shared secret value:
                   3455: .Bd -literal -offset indent
                   3456: $ openssl pkeyutl -derive -inkey key.pem \e
                   3457:        -peerkey pubkey.pem -out secret
                   3458: .Ed
                   3459: .\"
                   3460: .\" PRIME
                   3461: .\"
                   3462: .Sh PRIME
                   3463: .Cm openssl prime
                   3464: .Op Fl bits Ar n
                   3465: .Op Fl checks Ar n
                   3466: .Op Fl generate
                   3467: .Op Fl hex
                   3468: .Op Fl safe
                   3469: .Ar p
                   3470: .Pp
                   3471: The
                   3472: .Nm prime
                   3473: command is used to generate prime numbers,
                   3474: or to check numbers for primality.
                   3475: Results are probabilistic:
                   3476: they have an exceedingly high likelihood of being correct,
                   3477: but are not guaranteed.
                   3478: .Pp
                   3479: The options are as follows:
                   3480: .Bl -tag -width Ds
                   3481: .It Fl bits Ar n
                   3482: Specify the number of bits in the generated prime number.
                   3483: Must be used in conjunction with
                   3484: .Fl generate .
                   3485: .It Fl checks Ar n
                   3486: Perform a Miller-Rabin probabilistic primality test with
                   3487: .Ar n
                   3488: iterations.
                   3489: The default is 20.
                   3490: .It Fl generate
                   3491: Generate a pseudo-random prime number.
                   3492: Must be used in conjunction with
                   3493: .Fl bits .
                   3494: .It Fl hex
                   3495: Output in hex format.
                   3496: .It Fl safe
                   3497: Generate only
                   3498: .Qq safe
                   3499: prime numbers
                   3500: (i.e. a prime p so that (p-1)/2 is also prime).
                   3501: .It Ar p
                   3502: Test if number
                   3503: .Ar p
                   3504: is prime.
                   3505: .El
                   3506: .\"
                   3507: .\" RAND
                   3508: .\"
                   3509: .Sh RAND
                   3510: .nr nS 1
                   3511: .Nm "openssl rand"
                   3512: .Op Fl base64
                   3513: .Op Fl hex
                   3514: .Op Fl out Ar file
                   3515: .Ar num
                   3516: .nr nS 0
                   3517: .Pp
                   3518: The
                   3519: .Nm rand
                   3520: command outputs
                   3521: .Ar num
                   3522: pseudo-random bytes.
                   3523: .Pp
                   3524: The options are as follows:
                   3525: .Bl -tag -width Ds
                   3526: .It Fl base64
                   3527: Perform
                   3528: .Em base64
                   3529: encoding on the output.
                   3530: .It Fl hex
                   3531: Specify hexadecimal output.
                   3532: .It Fl out Ar file
                   3533: Write to
                   3534: .Ar file
                   3535: instead of standard output.
                   3536: .El
                   3537: .\"
                   3538: .\" REQ
                   3539: .\"
                   3540: .Sh REQ
                   3541: .nr nS 1
                   3542: .Nm "openssl req"
                   3543: .Bk -words
                   3544: .Op Fl asn1-kludge
                   3545: .Op Fl batch
                   3546: .Op Fl config Ar file
                   3547: .Op Fl days Ar n
                   3548: .Op Fl extensions Ar section
                   3549: .Op Fl in Ar file
                   3550: .Op Fl inform Ar DER | PEM
                   3551: .Op Fl key Ar keyfile
                   3552: .Op Fl keyform Ar DER | PEM
                   3553: .Op Fl keyout Ar file
1.28      doug     3554: .Op Fl md4 | md5 | sha1
1.1       jsing    3555: .Op Fl modulus
                   3556: .Op Fl nameopt Ar option
                   3557: .Op Fl new
                   3558: .Op Fl newhdr
                   3559: .Op Fl newkey Ar arg
                   3560: .Op Fl no-asn1-kludge
                   3561: .Op Fl nodes
                   3562: .Op Fl noout
                   3563: .Op Fl out Ar file
                   3564: .Op Fl outform Ar DER | PEM
                   3565: .Op Fl passin Ar arg
                   3566: .Op Fl passout Ar arg
                   3567: .Op Fl pubkey
                   3568: .Op Fl reqexts Ar section
                   3569: .Op Fl reqopt Ar option
                   3570: .Op Fl set_serial Ar n
                   3571: .Op Fl subj Ar arg
                   3572: .Op Fl subject
                   3573: .Op Fl text
                   3574: .Op Fl utf8
                   3575: .Op Fl verbose
                   3576: .Op Fl verify
                   3577: .Op Fl x509
                   3578: .Ek
                   3579: .nr nS 0
                   3580: .Pp
                   3581: The
                   3582: .Nm req
                   3583: command primarily creates and processes certificate requests
                   3584: in PKCS#10 format.
                   3585: It can additionally create self-signed certificates,
                   3586: for use as root CAs, for example.
                   3587: .Pp
                   3588: The options are as follows:
                   3589: .Bl -tag -width Ds
                   3590: .It Fl asn1-kludge
                   3591: By default, the
                   3592: .Nm req
                   3593: command outputs certificate requests containing
                   3594: no attributes in the correct PKCS#10 format.
                   3595: However certain CAs will only
                   3596: accept requests containing no attributes in an invalid form: this
                   3597: option produces this invalid format.
                   3598: .Pp
                   3599: More precisely, the
                   3600: .Em Attributes
                   3601: in a PKCS#10 certificate request are defined as a SET OF Attribute.
                   3602: They are
                   3603: .Em not
                   3604: optional, so if no attributes are present then they should be encoded as an
                   3605: empty SET OF.
                   3606: The invalid form does not include the empty
                   3607: SET OF, whereas the correct form does.
                   3608: .Pp
                   3609: It should be noted that very few CAs still require the use of this option.
                   3610: .It Fl batch
                   3611: Non-interactive mode.
                   3612: .It Fl config Ar file
                   3613: This allows an alternative configuration file to be specified;
                   3614: this overrides the compile time filename or any specified in
                   3615: the
                   3616: .Ev OPENSSL_CONF
                   3617: environment variable.
                   3618: .It Fl days Ar n
                   3619: When the
                   3620: .Fl x509
                   3621: option is being used, this specifies the number of
                   3622: days to certify the certificate for.
                   3623: The default is 30 days.
                   3624: .It Fl extensions Ar section , Fl reqexts Ar section
                   3625: These options specify alternative sections to include certificate
                   3626: extensions (if the
                   3627: .Fl x509
                   3628: option is present) or certificate request extensions.
                   3629: This allows several different sections to
                   3630: be used in the same configuration file to specify requests for
                   3631: a variety of purposes.
                   3632: .It Fl in Ar file
                   3633: This specifies the input
                   3634: .Ar file
                   3635: to read a request from, or standard input
                   3636: if this option is not specified.
                   3637: A request is only read if the creation options
                   3638: .Fl new
                   3639: and
                   3640: .Fl newkey
                   3641: are not specified.
                   3642: .It Fl inform Ar DER | PEM
                   3643: This specifies the input format.
                   3644: The
                   3645: .Ar DER
                   3646: argument uses an ASN1 DER-encoded form compatible with the PKCS#10.
                   3647: The
                   3648: .Ar PEM
                   3649: form is the default format:
                   3650: it consists of the DER format base64-encoded with additional header and
                   3651: footer lines.
                   3652: .It Fl key Ar keyfile
                   3653: This specifies the file to read the private key from.
                   3654: It also accepts PKCS#8 format private keys for PEM format files.
                   3655: .It Fl keyform Ar DER | PEM
                   3656: The format of the private key file specified in the
                   3657: .Fl key
                   3658: argument.
                   3659: .Ar PEM
                   3660: is the default.
                   3661: .It Fl keyout Ar file
                   3662: This gives the
                   3663: .Ar file
                   3664: to write the newly created private key to.
                   3665: If this option is not specified, the filename present in the
                   3666: configuration file is used.
1.4       sthen    3667: .It Fl md5 | sha1 | sha256
1.1       jsing    3668: This specifies the message digest to sign the request with.
                   3669: This overrides the digest algorithm specified in the configuration file.
                   3670: .Pp
                   3671: Some public key algorithms may override this choice.
                   3672: For instance, DSA signatures always use SHA1.
                   3673: .It Fl modulus
                   3674: This option prints out the value of the modulus of the public key
                   3675: contained in the request.
                   3676: .It Fl nameopt Ar option , Fl reqopt Ar option
                   3677: These options determine how the subject or issuer names are displayed.
                   3678: The
                   3679: .Ar option
                   3680: argument can be a single option or multiple options separated by commas.
                   3681: Alternatively, these options may be used more than once to set multiple options.
                   3682: See the
                   3683: .Sx X509
                   3684: section below for details.
                   3685: .It Fl new
                   3686: This option generates a new certificate request.
                   3687: It will prompt the user for the relevant field values.
                   3688: The actual fields prompted for and their maximum and minimum sizes
                   3689: are specified in the configuration file and any requested extensions.
                   3690: .Pp
                   3691: If the
                   3692: .Fl key
                   3693: option is not used, it will generate a new RSA private
                   3694: key using information specified in the configuration file.
                   3695: .It Fl newhdr
                   3696: Adds the word NEW to the PEM file header and footer lines
                   3697: on the outputed request.
                   3698: Some software
                   3699: .Pq Netscape certificate server
                   3700: and some CAs need this.
                   3701: .It Fl newkey Ar arg
                   3702: This option creates a new certificate request and a new private key.
                   3703: The argument takes one of several forms.
                   3704: .Ar rsa : Ns Ar nbits ,
                   3705: where
                   3706: .Ar nbits
                   3707: is the number of bits, generates an RSA key
                   3708: .Ar nbits
                   3709: in size.
                   3710: If
                   3711: .Ar nbits
                   3712: is omitted, i.e.\&
                   3713: .Cm -newkey rsa
                   3714: specified,
                   3715: the default key size, specified in the configuration file, is used.
                   3716: .Pp
                   3717: All other algorithms support the
                   3718: .Ar alg : Ns Ar file
                   3719: form,
                   3720: where file may be an algorithm parameter file,
                   3721: created by the
                   3722: .Cm genpkey -genparam
1.14      jmc      3723: command or an X.509 certificate for a key with appropriate algorithm.
1.1       jsing    3724: .Pp
                   3725: .Ar param : Ns Ar file
                   3726: generates a key using the parameter file or certificate
                   3727: .Ar file ;
                   3728: the algorithm is determined by the parameters.
                   3729: .Ar algname : Ns Ar file
                   3730: use algorithm
                   3731: .Ar algname
                   3732: and parameter file
                   3733: .Ar file :
                   3734: the two algorithms must match or an error occurs.
                   3735: .Ar algname
                   3736: just uses algorithm
                   3737: .Ar algname ,
                   3738: and parameters, if necessary,
                   3739: should be specified via the
                   3740: .Fl pkeyopt
                   3741: option.
                   3742: .Pp
                   3743: .Ar dsa : Ns Ar file
                   3744: generates a DSA key using the parameters in the file
                   3745: .Ar file .
                   3746: .It Fl no-asn1-kludge
                   3747: Reverses the effect of
                   3748: .Fl asn1-kludge .
                   3749: .It Fl nodes
                   3750: If this option is specified and a private key is created, it
                   3751: will not be encrypted.
                   3752: .It Fl noout
                   3753: This option prevents output of the encoded version of the request.
                   3754: .It Fl out Ar file
                   3755: This specifies the output
                   3756: .Ar file
                   3757: to write to, or standard output by default.
                   3758: .It Fl outform Ar DER | PEM
                   3759: This specifies the output format; the options have the same meaning as the
                   3760: .Fl inform
                   3761: option.
                   3762: .It Fl passin Ar arg
                   3763: The key password source.
                   3764: .It Fl passout Ar arg
                   3765: The output file password source.
                   3766: .It Fl pubkey
                   3767: Outputs the public key.
                   3768: .It Fl reqopt Ar option
                   3769: Customise the output format used with
                   3770: .Fl text .
                   3771: The
                   3772: .Ar option
                   3773: argument can be a single option or multiple options separated by commas.
                   3774: .Pp
                   3775: See the discussion of the
                   3776: .Fl certopt
                   3777: option in the
                   3778: .Nm x509
                   3779: command.
                   3780: .It Fl set_serial Ar n
                   3781: Serial number to use when outputting a self-signed certificate.
                   3782: This may be specified as a decimal value or a hex value if preceded by
                   3783: .Sq 0x .
                   3784: It is possible to use negative serial numbers but this is not recommended.
                   3785: .It Fl subj Ar arg
                   3786: Replaces subject field of input request with specified data and outputs
                   3787: modified request.
                   3788: The arg must be formatted as
                   3789: .Em /type0=value0/type1=value1/type2=... ;
                   3790: characters may be escaped by
                   3791: .Sq \e
                   3792: .Pq backslash ;
                   3793: no spaces are skipped.
                   3794: .It Fl subject
                   3795: Prints out the request subject (or certificate subject if
                   3796: .Fl x509
                   3797: is specified.
                   3798: .It Fl text
                   3799: Prints out the certificate request in text form.
                   3800: .It Fl utf8
                   3801: This option causes field values to be interpreted as UTF8 strings;
                   3802: by default they are interpreted as ASCII.
                   3803: This means that the field values, whether prompted from a terminal or
                   3804: obtained from a configuration file, must be valid UTF8 strings.
                   3805: .It Fl verbose
                   3806: Print extra details about the operations being performed.
                   3807: .It Fl verify
                   3808: Verifies the signature on the request.
                   3809: .It Fl x509
                   3810: This option outputs a self-signed certificate instead of a certificate
                   3811: request.
                   3812: This is typically used to generate a test certificate or
                   3813: a self-signed root CA.
                   3814: The extensions added to the certificate
                   3815: .Pq if any
                   3816: are specified in the configuration file.
                   3817: Unless specified using the
                   3818: .Fl set_serial
                   3819: option, 0 will be used for the serial number.
                   3820: .El
                   3821: .Sh REQ CONFIGURATION FILE FORMAT
                   3822: The configuration options are specified in the
                   3823: .Em req
                   3824: section of the configuration file.
                   3825: As with all configuration files, if no value is specified in the specific
                   3826: section (i.e.\&
                   3827: .Em req )
                   3828: then the initial unnamed or
                   3829: .Em default
                   3830: section is searched too.
                   3831: .Pp
                   3832: The options available are described in detail below.
                   3833: .Bl -tag -width "XXXX"
                   3834: .It Ar attributes
                   3835: This specifies the section containing any request attributes: its format
                   3836: is the same as
                   3837: .Ar distinguished_name .
                   3838: Typically these may contain the
                   3839: .Em challengePassword
                   3840: or
                   3841: .Em unstructuredName
                   3842: types.
                   3843: They are currently ignored by
                   3844: .Nm OpenSSL Ns Li 's
                   3845: request signing utilities, but some CAs might want them.
                   3846: .It Ar default_bits
                   3847: This specifies the default key size in bits.
1.4       sthen    3848: If not specified, 2048 is used.
1.1       jsing    3849: It is used if the
                   3850: .Fl new
                   3851: option is used.
                   3852: It can be overridden by using the
                   3853: .Fl newkey
                   3854: option.
                   3855: .It Ar default_keyfile
                   3856: This is the default file to write a private key to.
                   3857: If not specified, the key is written to standard output.
                   3858: This can be overridden by the
                   3859: .Fl keyout
                   3860: option.
                   3861: .It Ar default_md
                   3862: This option specifies the digest algorithm to use.
                   3863: Possible values include
1.4       sthen    3864: .Ar md5 ,
                   3865: .Ar sha1
1.1       jsing    3866: and
1.4       sthen    3867: .Ar sha256 .
                   3868: If not present, SHA256 is used.
1.1       jsing    3869: This option can be overridden on the command line.
                   3870: .It Ar distinguished_name
                   3871: This specifies the section containing the distinguished name fields to
                   3872: prompt for when generating a certificate or certificate request.
                   3873: The format is described in the next section.
                   3874: .It Ar encrypt_key
                   3875: If this is set to
                   3876: .Em no
                   3877: and a private key is generated, it is
                   3878: .Em not
                   3879: encrypted.
                   3880: This is equivalent to the
                   3881: .Fl nodes
                   3882: command line option.
                   3883: For compatibility,
                   3884: .Ar encrypt_rsa_key
                   3885: is an equivalent option.
                   3886: .It Ar input_password | output_password
                   3887: The passwords for the input private key file
                   3888: .Pq if present
                   3889: and the output private key file
                   3890: .Pq if one will be created .
                   3891: The command line options
                   3892: .Fl passin
                   3893: and
                   3894: .Fl passout
                   3895: override the configuration file values.
                   3896: .It Ar oid_file
                   3897: This specifies a file containing additional OBJECT IDENTIFIERS.
                   3898: Each line of the file should consist of the numerical form of the
                   3899: object identifier, followed by whitespace, then the short name followed
                   3900: by whitespace and finally the long name.
                   3901: .It Ar oid_section
                   3902: This specifies a section in the configuration file containing extra
                   3903: object identifiers.
                   3904: Each line should consist of the short name of the
                   3905: object identifier followed by
                   3906: .Sq =
                   3907: and the numerical form.
                   3908: The short and long names are the same when this option is used.
                   3909: .It Ar prompt
                   3910: If set to the value
                   3911: .Em no ,
                   3912: this disables prompting of certificate fields
                   3913: and just takes values from the config file directly.
                   3914: It also changes the expected format of the
                   3915: .Em distinguished_name
                   3916: and
                   3917: .Em attributes
                   3918: sections.
                   3919: .It Ar req_extensions
                   3920: This specifies the configuration file section containing a list of
                   3921: extensions to add to the certificate request.
                   3922: It can be overridden by the
                   3923: .Fl reqexts
                   3924: command line switch.
                   3925: .It Ar string_mask
                   3926: This option limits the string types for encoding certain
                   3927: fields.
                   3928: The following values may be used, limiting strings to the indicated types:
                   3929: .Bl -tag -width "MASK:number"
                   3930: .It Ar utf8only
                   3931: .Em UTF8String.
                   3932: This is the default, as recommended by PKIX in RFC 2459.
                   3933: .It Ar default
                   3934: .Em PrintableString , IA5String , T61String , BMPString , UTF8String .
                   3935: .It Ar pkix
                   3936: .Em PrintableString , IA5String , BMPString , UTF8String .
                   3937: This was inspired by the PKIX recommendation in RFC 2459 for certificates
                   3938: generated before 2004, but differs by also permitting
                   3939: .Em IA5String .
                   3940: .It Ar nombstr
                   3941: .Em PrintableString , IA5String , T61String , UniversalString .
                   3942: This was a workaround for some ancient software that had problems
                   3943: with the variable-sized
                   3944: .Em BMPString
                   3945: and
                   3946: .Em UTF8String
                   3947: types.
                   3948: .It Cm MASK : Ns Ar number
                   3949: This is an explicit bitmask of permitted types, where
                   3950: .Ar number
                   3951: is a C-style hex, decimal, or octal number that's a bit-wise OR of
                   3952: .Dv B_ASN1_*
                   3953: values from
                   3954: .In openssl/asn1.h .
                   3955: .El
                   3956: .It Ar utf8
                   3957: If set to the value
                   3958: .Em yes ,
                   3959: then field values are interpreted as UTF8 strings;
                   3960: by default they are interpreted as ASCII.
                   3961: This means that the field values, whether prompted from a terminal or
                   3962: obtained from a configuration file, must be valid UTF8 strings.
                   3963: .It Ar x509_extensions
                   3964: This specifies the configuration file section containing a list of
                   3965: extensions to add to a certificate generated when the
                   3966: .Fl x509
                   3967: switch is used.
                   3968: It can be overridden by the
                   3969: .Fl extensions
                   3970: command line switch.
                   3971: .El
                   3972: .Sh REQ DISTINGUISHED NAME AND ATTRIBUTE SECTION FORMAT
                   3973: There are two separate formats for the distinguished name and attribute
                   3974: sections.
                   3975: If the
                   3976: .Fl prompt
                   3977: option is set to
                   3978: .Em no ,
                   3979: then these sections just consist of field names and values: for example,
                   3980: .Bd -unfilled -offset indent
                   3981: CN=My Name
                   3982: OU=My Organization
                   3983: emailAddress=someone@somewhere.org
                   3984: .Ed
                   3985: .Pp
                   3986: This allows external programs
                   3987: .Pq e.g. GUI based
                   3988: to generate a template file with all the field names and values
                   3989: and just pass it to
                   3990: .Nm req .
                   3991: An example of this kind of configuration file is contained in the
                   3992: .Sx REQ EXAMPLES
                   3993: section.
                   3994: .Pp
                   3995: Alternatively if the
                   3996: .Fl prompt
                   3997: option is absent or not set to
                   3998: .Em no ,
                   3999: then the file contains field prompting information.
                   4000: It consists of lines of the form:
                   4001: .Bd -unfilled -offset indent
                   4002: fieldName="prompt"
                   4003: fieldName_default="default field value"
                   4004: fieldName_min= 2
                   4005: fieldName_max= 4
                   4006: .Ed
                   4007: .Pp
                   4008: .Qq fieldName
                   4009: is the field name being used, for example
                   4010: .Em commonName
                   4011: .Pq or CN .
                   4012: The
                   4013: .Qq prompt
                   4014: string is used to ask the user to enter the relevant details.
                   4015: If the user enters nothing, the default value is used;
                   4016: if no default value is present, the field is omitted.
                   4017: A field can still be omitted if a default value is present,
                   4018: if the user just enters the
                   4019: .Sq \&.
                   4020: character.
                   4021: .Pp
                   4022: The number of characters entered must be between the
                   4023: .Em fieldName_min
                   4024: and
                   4025: .Em fieldName_max
                   4026: limits:
                   4027: there may be additional restrictions based on the field being used
                   4028: (for example
                   4029: .Em countryName
                   4030: can only ever be two characters long and must fit in a
                   4031: .Em PrintableString ) .
                   4032: .Pp
                   4033: Some fields (such as
                   4034: .Em organizationName )
                   4035: can be used more than once in a DN.
                   4036: This presents a problem because configuration files will
                   4037: not recognize the same name occurring twice.
                   4038: To avoid this problem, if the
                   4039: .Em fieldName
                   4040: contains some characters followed by a full stop, they will be ignored.
                   4041: So, for example, a second
                   4042: .Em organizationName
                   4043: can be input by calling it
                   4044: .Qq 1.organizationName .
                   4045: .Pp
                   4046: The actual permitted field names are any object identifier short or
                   4047: long names.
                   4048: These are compiled into
                   4049: .Nm OpenSSL
                   4050: and include the usual values such as
                   4051: .Em commonName , countryName , localityName , organizationName ,
                   4052: .Em organizationUnitName , stateOrProvinceName .
                   4053: Additionally,
                   4054: .Em emailAddress
                   4055: is included as well as
                   4056: .Em name , surname , givenName initials
                   4057: and
                   4058: .Em dnQualifier .
                   4059: .Pp
                   4060: Additional object identifiers can be defined with the
                   4061: .Ar oid_file
                   4062: or
                   4063: .Ar oid_section
                   4064: options in the configuration file.
                   4065: Any additional fields will be treated as though they were a
                   4066: .Em DirectoryString .
                   4067: .Sh REQ EXAMPLES
                   4068: Examine and verify a certificate request:
                   4069: .Pp
                   4070: .Dl $ openssl req -in req.pem -text -verify -noout
                   4071: .Pp
                   4072: Create a private key and then generate a certificate request from it:
                   4073: .Bd -literal -offset indent
                   4074: $ openssl genrsa -out key.pem 2048
                   4075: $ openssl req -new -key key.pem -out req.pem
                   4076: .Ed
                   4077: .Pp
                   4078: The same but just using req:
                   4079: .Pp
                   4080: .Dl $ openssl req -newkey rsa:2048 -keyout key.pem -out req.pem
                   4081: .Pp
                   4082: Generate a self-signed root certificate:
                   4083: .Pp
                   4084: .Dl "$ openssl req -x509 -newkey rsa:2048 -keyout key.pem -out req.pem"
                   4085: .Pp
                   4086: Example of a file pointed to by the
                   4087: .Ar oid_file
                   4088: option:
                   4089: .Bd -unfilled -offset indent
                   4090: 1.2.3.4        shortName       A longer Name
                   4091: 1.2.3.6        otherName       Other longer Name
                   4092: .Ed
                   4093: .Pp
                   4094: Example of a section pointed to by
                   4095: .Ar oid_section
                   4096: making use of variable expansion:
                   4097: .Bd -unfilled -offset indent
                   4098: testoid1=1.2.3.5
                   4099: testoid2=${testoid1}.6
                   4100: .Ed
                   4101: .Pp
                   4102: Sample configuration file prompting for field values:
                   4103: .Bd -literal
                   4104: \& [ req ]
                   4105: \& default_bits           = 1024
                   4106: \& default_keyfile        = privkey.pem
                   4107: \& distinguished_name     = req_distinguished_name
                   4108: \& attributes             = req_attributes
                   4109: \& x509_extensions        = v3_ca
                   4110:
                   4111: \& dirstring_type = nobmp
                   4112:
                   4113: \& [ req_distinguished_name ]
                   4114: \& countryName                    = Country Name (2 letter code)
                   4115: \& countryName_default            = AU
                   4116: \& countryName_min                = 2
                   4117: \& countryName_max                = 2
                   4118:
                   4119: \& localityName                   = Locality Name (eg, city)
                   4120:
                   4121: \& organizationalUnitName         = Organizational Unit Name (eg, section)
                   4122:
                   4123: \& commonName                     = Common Name (eg, YOUR name)
                   4124: \& commonName_max                 = 64
                   4125:
                   4126: \& emailAddress                   = Email Address
                   4127: \& emailAddress_max               = 40
                   4128:
                   4129: \& [ req_attributes ]
                   4130: \& challengePassword              = A challenge password
                   4131: \& challengePassword_min          = 4
                   4132: \& challengePassword_max          = 20
                   4133:
                   4134: \& [ v3_ca ]
                   4135:
                   4136: \& subjectKeyIdentifier=hash
                   4137: \& authorityKeyIdentifier=keyid:always,issuer:always
                   4138: \& basicConstraints = CA:true
                   4139: .Ed
                   4140: .Pp
                   4141: Sample configuration containing all field values:
                   4142: .Bd -literal
                   4143:
                   4144: \& [ req ]
                   4145: \& default_bits           = 1024
                   4146: \& default_keyfile        = keyfile.pem
                   4147: \& distinguished_name     = req_distinguished_name
                   4148: \& attributes             = req_attributes
                   4149: \& prompt                 = no
                   4150: \& output_password        = mypass
                   4151:
                   4152: \& [ req_distinguished_name ]
                   4153: \& C                      = GB
                   4154: \& ST                     = Test State or Province
                   4155: \& L                      = Test Locality
                   4156: \& O                      = Organization Name
                   4157: \& OU                     = Organizational Unit Name
                   4158: \& CN                     = Common Name
                   4159: \& emailAddress           = test@email.address
                   4160:
                   4161: \& [ req_attributes ]
                   4162: \& challengePassword              = A challenge password
                   4163: .Ed
                   4164: .Sh REQ NOTES
                   4165: The header and footer lines in the PEM format are normally:
                   4166: .Bd -unfilled -offset indent
                   4167: -----BEGIN CERTIFICATE REQUEST-----
                   4168: -----END CERTIFICATE REQUEST-----
                   4169: .Ed
                   4170: .Pp
                   4171: Some software
                   4172: .Pq some versions of Netscape certificate server
                   4173: instead needs:
                   4174: .Bd -unfilled -offset indent
                   4175: -----BEGIN NEW CERTIFICATE REQUEST-----
                   4176: -----END NEW CERTIFICATE REQUEST-----
                   4177: .Ed
                   4178: .Pp
                   4179: which is produced with the
                   4180: .Fl newhdr
                   4181: option but is otherwise compatible.
                   4182: Either form is accepted transparently on input.
                   4183: .Pp
                   4184: The certificate requests generated by Xenroll with MSIE have extensions added.
                   4185: It includes the
                   4186: .Em keyUsage
                   4187: extension which determines the type of key
                   4188: .Pq signature only or general purpose
                   4189: and any additional OIDs entered by the script in an
                   4190: .Em extendedKeyUsage
                   4191: extension.
                   4192: .Sh REQ DIAGNOSTICS
                   4193: The following messages are frequently asked about:
                   4194: .Bd -unfilled -offset indent
                   4195: Using configuration from /some/path/openssl.cnf
                   4196: Unable to load config info
                   4197: .Ed
                   4198: .Pp
                   4199: This is followed some time later by...
                   4200: .Bd -unfilled -offset indent
                   4201: unable to find 'distinguished_name' in config
                   4202: problems making Certificate Request
                   4203: .Ed
                   4204: .Pp
                   4205: The first error message is the clue: it can't find the configuration
                   4206: file!
                   4207: Certain operations
                   4208: .Pq like examining a certificate request
                   4209: don't need a configuration file so its use isn't enforced.
                   4210: Generation of certificates or requests, however, do need a configuration file.
                   4211: This could be regarded as a bug.
                   4212: .Pp
                   4213: Another puzzling message is this:
                   4214: .Bd -unfilled -offset indent
                   4215: Attributes:
                   4216:     a0:00
                   4217: .Ed
                   4218: .Pp
                   4219: This is displayed when no attributes are present and the request includes
                   4220: the correct empty SET OF structure
                   4221: .Pq the DER encoding of which is 0xa0 0x00 .
                   4222: If you just see:
                   4223: .Pp
                   4224: .D1 Attributes:
                   4225: .Pp
                   4226: then the SET OF is missing and the encoding is technically invalid
                   4227: .Pq but it is tolerated .
                   4228: See the description of the command line option
                   4229: .Fl asn1-kludge
                   4230: for more information.
                   4231: .Sh REQ ENVIRONMENT VARIABLES
                   4232: The variable
                   4233: .Ev OPENSSL_CONF ,
                   4234: if defined, allows an alternative configuration
                   4235: file location to be specified; it will be overridden by the
                   4236: .Fl config
                   4237: command line switch if it is present.
                   4238: .Sh REQ BUGS
                   4239: .Nm OpenSSL Ns Li 's
                   4240: handling of T61Strings
                   4241: .Pq aka TeletexStrings
                   4242: is broken: it effectively treats them as ISO 8859-1
                   4243: .Pq Latin 1 ;
                   4244: Netscape and MSIE have similar behaviour.
                   4245: This can cause problems if you need characters that aren't available in
                   4246: .Em PrintableStrings
                   4247: and you don't want to or can't use
                   4248: .Em BMPStrings .
                   4249: .Pp
                   4250: As a consequence of the T61String handling, the only correct way to represent
                   4251: accented characters in
                   4252: .Nm OpenSSL
                   4253: is to use a
                   4254: .Em BMPString :
                   4255: unfortunately Netscape currently chokes on these.
                   4256: If you have to use accented characters with Netscape
                   4257: and MSIE then you currently need to use the invalid T61String form.
                   4258: .Pp
                   4259: The current prompting is not very friendly.
                   4260: It doesn't allow you to confirm what you've just entered.
                   4261: Other things, like extensions in certificate requests, are
                   4262: statically defined in the configuration file.
                   4263: Some of these, like an email address in
                   4264: .Em subjectAltName ,
                   4265: should be input by the user.
                   4266: .\"
                   4267: .\" RSA
                   4268: .\"
                   4269: .Sh RSA
                   4270: .nr nS 1
                   4271: .Nm "openssl rsa"
                   4272: .Bk -words
                   4273: .Oo
                   4274: .Fl aes128 | aes192 | aes256 |
                   4275: .Fl des | des3
                   4276: .Oc
                   4277: .Op Fl check
                   4278: .Op Fl in Ar file
                   4279: .Op Fl inform Ar DER | NET | PEM
                   4280: .Op Fl modulus
                   4281: .Op Fl noout
                   4282: .Op Fl out Ar file
                   4283: .Op Fl outform Ar DER | NET | PEM
                   4284: .Op Fl passin Ar arg
                   4285: .Op Fl passout Ar arg
                   4286: .Op Fl pubin
                   4287: .Op Fl pubout
                   4288: .Op Fl sgckey
                   4289: .Op Fl text
                   4290: .nr nS 0
                   4291: .Ek
                   4292: .Pp
                   4293: The
                   4294: .Nm rsa
                   4295: command processes RSA keys.
                   4296: They can be converted between various forms and their components printed out.
                   4297: .Pp
                   4298: .Sy Note :
                   4299: this command uses the traditional
                   4300: .Nm SSLeay
                   4301: compatible format for private key encryption:
                   4302: newer applications should use the more secure PKCS#8 format using the
                   4303: .Nm pkcs8
                   4304: utility.
                   4305: .Pp
                   4306: The options are as follows:
                   4307: .Bl -tag -width Ds
                   4308: .It Xo
                   4309: .Fl aes128 | aes192 | aes256 |
                   4310: .Fl des | des3
                   4311: .Xc
                   4312: These options encrypt the private key with the AES, DES,
                   4313: or the triple DES ciphers, respectively, before outputting it.
                   4314: A pass phrase is prompted for.
                   4315: If none of these options are specified, the key is written in plain text.
                   4316: This means that using the
                   4317: .Nm rsa
                   4318: utility to read in an encrypted key with no encryption option can be used
                   4319: to remove the pass phrase from a key, or by setting the encryption options
                   4320: it can be used to add or change the pass phrase.
                   4321: These options can only be used with PEM format output files.
                   4322: .It Fl check
                   4323: This option checks the consistency of an RSA private key.
                   4324: .It Fl in Ar file
                   4325: This specifies the input
                   4326: .Ar file
                   4327: to read a key from, or standard input if this
                   4328: option is not specified.
                   4329: If the key is encrypted, a pass phrase will be prompted for.
                   4330: .It Fl inform Ar DER | NET | PEM
                   4331: This specifies the input format.
                   4332: The
                   4333: .Ar DER
                   4334: argument
                   4335: uses an ASN1 DER-encoded form compatible with the PKCS#1
                   4336: RSAPrivateKey or SubjectPublicKeyInfo format.
                   4337: The
                   4338: .Ar PEM
                   4339: form is the default format: it consists of the DER format base64-encoded with
                   4340: additional header and footer lines.
                   4341: On input PKCS#8 format private keys are also accepted.
                   4342: The
                   4343: .Ar NET
                   4344: form is a format described in the
                   4345: .Sx RSA NOTES
                   4346: section.
                   4347: .It Fl noout
                   4348: This option prevents output of the encoded version of the key.
                   4349: .It Fl modulus
                   4350: This option prints out the value of the modulus of the key.
                   4351: .It Fl out Ar file
                   4352: This specifies the output
                   4353: .Ar file
                   4354: to write a key to, or standard output if this option is not specified.
                   4355: If any encryption options are set, a pass phrase will be prompted for.
                   4356: The output filename should
                   4357: .Em not
                   4358: be the same as the input filename.
                   4359: .It Fl outform Ar DER | NET | PEM
                   4360: This specifies the output format; the options have the same meaning as the
                   4361: .Fl inform
                   4362: option.
                   4363: .It Fl passin Ar arg
                   4364: The key password source.
                   4365: .It Fl passout Ar arg
                   4366: The output file password source.
                   4367: .It Fl pubin
                   4368: By default, a private key is read from the input file; with this
                   4369: option a public key is read instead.
                   4370: .It Fl pubout
                   4371: By default, a private key is output;
                   4372: with this option a public key will be output instead.
                   4373: This option is automatically set if the input is a public key.
                   4374: .It Fl sgckey
                   4375: Use the modified
                   4376: .Em NET
                   4377: algorithm used with some versions of Microsoft IIS and SGC keys.
                   4378: .It Fl text
                   4379: Prints out the various public or private key components in
                   4380: plain text, in addition to the encoded version.
                   4381: .El
                   4382: .Sh RSA NOTES
                   4383: The PEM private key format uses the header and footer lines:
                   4384: .Bd -unfilled -offset indent
                   4385: -----BEGIN RSA PRIVATE KEY-----
                   4386: -----END RSA PRIVATE KEY-----
                   4387: .Ed
                   4388: .Pp
                   4389: The PEM public key format uses the header and footer lines:
                   4390: .Bd -unfilled -offset indent
                   4391: -----BEGIN PUBLIC KEY-----
                   4392: -----END PUBLIC KEY-----
                   4393: .Ed
                   4394: .Pp
                   4395: The
                   4396: .Em NET
                   4397: form is a format compatible with older Netscape servers
                   4398: and Microsoft IIS .key files; this uses unsalted RC4 for its encryption.
                   4399: It is not very secure and so should only be used when necessary.
                   4400: .Pp
                   4401: Some newer version of IIS have additional data in the exported .key files.
                   4402: To use these with the
                   4403: .Nm rsa
                   4404: utility, view the file with a binary editor
                   4405: and look for the string
                   4406: .Qq private-key ,
                   4407: then trace back to the byte sequence 0x30, 0x82
                   4408: .Pq this is an ASN1 SEQUENCE .
                   4409: Copy all the data from this point onwards to another file and use that as
                   4410: the input to the
                   4411: .Nm rsa
                   4412: utility with the
                   4413: .Fl inform Ar NET
                   4414: option.
                   4415: If there is an error after entering the password, try the
                   4416: .Fl sgckey
                   4417: option.
                   4418: .Sh RSA EXAMPLES
                   4419: To remove the pass phrase on an RSA private key:
                   4420: .Pp
                   4421: .Dl $ openssl rsa -in key.pem -out keyout.pem
                   4422: .Pp
                   4423: To encrypt a private key using triple DES:
                   4424: .Pp
                   4425: .Dl $ openssl rsa -in key.pem -des3 -out keyout.pem
                   4426: .Pp
                   4427: To convert a private key from PEM to DER format:
                   4428: .Pp
                   4429: .Dl $ openssl rsa -in key.pem -outform DER -out keyout.der
                   4430: .Pp
                   4431: To print out the components of a private key to standard output:
                   4432: .Pp
                   4433: .Dl $ openssl rsa -in key.pem -text -noout
                   4434: .Pp
                   4435: To just output the public part of a private key:
                   4436: .Pp
                   4437: .Dl $ openssl rsa -in key.pem -pubout -out pubkey.pem
                   4438: .Sh RSA BUGS
                   4439: The command line password arguments don't currently work with
                   4440: .Em NET
                   4441: format.
                   4442: .Pp
                   4443: There should be an option that automatically handles .key files,
                   4444: without having to manually edit them.
                   4445: .\"
                   4446: .\" RSAUTL
                   4447: .\"
                   4448: .Sh RSAUTL
                   4449: .nr nS 1
                   4450: .Nm "openssl rsautl"
                   4451: .Bk -words
                   4452: .Op Fl asn1parse
                   4453: .Op Fl certin
                   4454: .Op Fl decrypt
                   4455: .Op Fl encrypt
                   4456: .Op Fl hexdump
                   4457: .Op Fl in Ar file
                   4458: .Op Fl inkey Ar file
                   4459: .Op Fl keyform Ar DER | PEM
                   4460: .Op Fl oaep | pkcs | raw | ssl
                   4461: .Op Fl out Ar file
                   4462: .Op Fl pubin
                   4463: .Op Fl sign
                   4464: .Op Fl verify
                   4465: .Ek
                   4466: .nr nS 0
                   4467: .Pp
                   4468: The
                   4469: .Nm rsautl
                   4470: command can be used to sign, verify, encrypt and decrypt
                   4471: data using the RSA algorithm.
                   4472: .Pp
                   4473: The options are as follows:
                   4474: .Bl -tag -width Ds
                   4475: .It Fl asn1parse
                   4476: Asn1parse the output data; this is useful when combined with the
                   4477: .Fl verify
                   4478: option.
                   4479: .It Fl certin
                   4480: The input is a certificate containing an RSA public key.
                   4481: .It Fl decrypt
                   4482: Decrypt the input data using an RSA private key.
                   4483: .It Fl encrypt
                   4484: Encrypt the input data using an RSA public key.
                   4485: .It Fl hexdump
                   4486: Hex dump the output data.
                   4487: .It Fl in Ar file
                   4488: This specifies the input
                   4489: .Ar file
                   4490: to read data from, or standard input
                   4491: if this option is not specified.
                   4492: .It Fl inkey Ar file
                   4493: The input key file, by default it should be an RSA private key.
                   4494: .It Fl keyform Ar DER | PEM
                   4495: Private ket format.
                   4496: Default is
                   4497: .Ar PEM .
                   4498: .It Fl oaep | pkcs | raw | ssl
                   4499: The padding to use:
                   4500: PKCS#1 OAEP, PKCS#1 v1.5
                   4501: .Pq the default ,
                   4502: or no padding, respectively.
                   4503: For signatures, only
                   4504: .Fl pkcs
                   4505: and
                   4506: .Fl raw
                   4507: can be used.
                   4508: .It Fl out Ar file
                   4509: Specifies the output
                   4510: .Ar file
                   4511: to write to, or standard output by
                   4512: default.
                   4513: .It Fl pubin
                   4514: The input file is an RSA public key.
                   4515: .It Fl sign
                   4516: Sign the input data and output the signed result.
                   4517: This requires an RSA private key.
                   4518: .It Fl verify
                   4519: Verify the input data and output the recovered data.
                   4520: .El
                   4521: .Sh RSAUTL NOTES
                   4522: .Nm rsautl ,
                   4523: because it uses the RSA algorithm directly, can only be
                   4524: used to sign or verify small pieces of data.
                   4525: .Sh RSAUTL EXAMPLES
                   4526: Sign some data using a private key:
                   4527: .Pp
                   4528: .Dl "$ openssl rsautl -sign -in file -inkey key.pem -out sig"
                   4529: .Pp
                   4530: Recover the signed data:
                   4531: .Pp
                   4532: .Dl $ openssl rsautl -verify -in sig -inkey key.pem
                   4533: .Pp
                   4534: Examine the raw signed data:
                   4535: .Pp
                   4536: .Li "\ \&$ openssl rsautl -verify -in file -inkey key.pem -raw -hexdump"
                   4537: .Bd -unfilled
                   4538: \& 0000 - 00 01 ff ff ff ff ff ff-ff ff ff ff ff ff ff ff   ................
                   4539: \& 0010 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff   ................
                   4540: \& 0020 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff   ................
                   4541: \& 0030 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff   ................
                   4542: \& 0040 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff   ................
                   4543: \& 0050 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff   ................
                   4544: \& 0060 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff   ................
                   4545: \& 0070 - ff ff ff ff 00 68 65 6c-6c 6f 20 77 6f 72 6c 64   .....hello world
                   4546: .Ed
                   4547: .Pp
                   4548: The PKCS#1 block formatting is evident from this.
                   4549: If this was done using encrypt and decrypt, the block would have been of type 2
                   4550: .Pq the second byte
                   4551: and random padding data visible instead of the 0xff bytes.
                   4552: .Pp
                   4553: It is possible to analyse the signature of certificates using this
                   4554: utility in conjunction with
                   4555: .Nm asn1parse .
                   4556: Consider the self-signed example in
                   4557: .Pa certs/pca-cert.pem :
                   4558: running
                   4559: .Nm asn1parse
                   4560: as follows yields:
                   4561: .Pp
                   4562: .Li "\ \&$ openssl asn1parse -in pca-cert.pem"
                   4563: .Bd -unfilled
                   4564: \&    0:d=0  hl=4 l= 742 cons: SEQUENCE
                   4565: \&    4:d=1  hl=4 l= 591 cons:  SEQUENCE
                   4566: \&    8:d=2  hl=2 l=   3 cons:   cont [ 0 ]
                   4567: \&   10:d=3  hl=2 l=   1 prim:    INTEGER           :02
                   4568: \&   13:d=2  hl=2 l=   1 prim:   INTEGER           :00
                   4569: \&   16:d=2  hl=2 l=  13 cons:   SEQUENCE
                   4570: \&   18:d=3  hl=2 l=   9 prim:    OBJECT            :md5WithRSAEncryption
                   4571: \&   29:d=3  hl=2 l=   0 prim:    NULL
                   4572: \&   31:d=2  hl=2 l=  92 cons:   SEQUENCE
                   4573: \&   33:d=3  hl=2 l=  11 cons:    SET
                   4574: \&   35:d=4  hl=2 l=   9 cons:     SEQUENCE
                   4575: \&   37:d=5  hl=2 l=   3 prim:      OBJECT            :countryName
                   4576: \&   42:d=5  hl=2 l=   2 prim:      PRINTABLESTRING   :AU
                   4577: \&  ....
                   4578: \&  599:d=1  hl=2 l=  13 cons:  SEQUENCE
                   4579: \&  601:d=2  hl=2 l=   9 prim:   OBJECT            :md5WithRSAEncryption
                   4580: \&  612:d=2  hl=2 l=   0 prim:   NULL
                   4581: \&  614:d=1  hl=3 l= 129 prim:  BIT STRING
                   4582: .Ed
                   4583: .Pp
                   4584: The final BIT STRING contains the actual signature.
                   4585: It can be extracted with:
                   4586: .Pp
                   4587: .Dl "$ openssl asn1parse -in pca-cert.pem -out sig -noout -strparse 614"
                   4588: .Pp
                   4589: The certificate public key can be extracted with:
                   4590: .Pp
                   4591: .Dl $ openssl x509 -in test/testx509.pem -pubkey -noout \*(Gtpubkey.pem
                   4592: .Pp
                   4593: The signature can be analysed with:
                   4594: .Pp
                   4595: .Li "\ \&$ openssl rsautl -in sig -verify -asn1parse -inkey pubkey.pem -pubin"
                   4596: .Bd -unfilled
                   4597: \&    0:d=0  hl=2 l=  32 cons: SEQUENCE
                   4598: \&    2:d=1  hl=2 l=  12 cons:  SEQUENCE
                   4599: \&    4:d=2  hl=2 l=   8 prim:   OBJECT            :md5
                   4600: \&   14:d=2  hl=2 l=   0 prim:   NULL
                   4601: \&   16:d=1  hl=2 l=  16 prim:  OCTET STRING
                   4602: \&   0000 - f3 46 9e aa 1a 4a 73 c9-37 ea 93 00 48 25 08 b5  .F...Js.7...H%..
                   4603: .Ed
                   4604: .Pp
                   4605: This is the parsed version of an ASN1
                   4606: .Em DigestInfo
                   4607: structure.
                   4608: It can be seen that the digest used was MD5.
                   4609: The actual part of the certificate that was signed can be extracted with:
                   4610: .Pp
                   4611: .Dl "$ openssl asn1parse -in pca-cert.pem -out tbs -noout -strparse 4"
                   4612: .Pp
                   4613: and its digest computed with:
                   4614: .Pp
                   4615: .Dl $ openssl md5 -c tbs
                   4616: .D1 MD5(tbs)= f3:46:9e:aa:1a:4a:73:c9:37:ea:93:00:48:25:08:b5
                   4617: .Pp
                   4618: which it can be seen agrees with the recovered value above.
                   4619: .\"
                   4620: .\" S_CLIENT
                   4621: .\"
                   4622: .Sh S_CLIENT
                   4623: .nr nS 1
                   4624: .Nm "openssl s_client"
                   4625: .Bk -words
                   4626: .Op Fl 4 | 6
                   4627: .Op Fl bugs
                   4628: .Op Fl CAfile Ar file
                   4629: .Op Fl CApath Ar directory
                   4630: .Op Fl cert Ar file
                   4631: .Op Fl check_ss_sig
                   4632: .Op Fl cipher Ar cipherlist
                   4633: .Oo
                   4634: .Fl connect Ar host : Ns Ar port |
                   4635: .Ar host Ns / Ns Ar port
                   4636: .Oc
                   4637: .Op Fl crl_check
                   4638: .Op Fl crl_check_all
                   4639: .Op Fl crlf
                   4640: .Op Fl debug
                   4641: .Op Fl extended_crl
                   4642: .Op Fl ign_eof
                   4643: .Op Fl ignore_critical
                   4644: .Op Fl issuer_checks
                   4645: .Op Fl key Ar keyfile
                   4646: .Op Fl msg
                   4647: .Op Fl nbio
                   4648: .Op Fl nbio_test
                   4649: .Op Fl no_ticket
                   4650: .Op Fl no_tls1
1.6       guenther 4651: .Op Fl no_tls1_1
                   4652: .Op Fl no_tls1_2
1.1       jsing    4653: .Op Fl pause
                   4654: .Op Fl policy_check
                   4655: .Op Fl prexit
1.11      bluhm    4656: .Op Fl proxy Ar host : Ns Ar port
1.1       jsing    4657: .Op Fl psk Ar key
                   4658: .Op Fl psk_identity Ar identity
                   4659: .Op Fl quiet
                   4660: .Op Fl reconnect
1.5       jsing    4661: .Op Fl servername Ar name
1.1       jsing    4662: .Op Fl showcerts
                   4663: .Op Fl starttls Ar protocol
                   4664: .Op Fl state
                   4665: .Op Fl tls1
1.31      jmc      4666: .Op Fl tls1_1
                   4667: .Op Fl tls1_2
1.1       jsing    4668: .Op Fl tlsextdebug
                   4669: .Op Fl verify Ar depth
                   4670: .Op Fl x509_strict
1.19      landry   4671: .Op Fl xmpphost Ar host
1.1       jsing    4672: .Ek
                   4673: .nr nS 0
                   4674: .Pp
                   4675: The
                   4676: .Nm s_client
                   4677: command implements a generic SSL/TLS client which connects
                   4678: to a remote host using SSL/TLS.
                   4679: It is a
                   4680: .Em very
                   4681: useful diagnostic tool for SSL servers.
                   4682: .Pp
                   4683: The options are as follows:
                   4684: .Bl -tag -width Ds
                   4685: .It Fl 4
                   4686: Specify that
                   4687: .Nm s_client
                   4688: should attempt connections using IPv4 only.
                   4689: .It Fl 6
                   4690: Specify that
                   4691: .Nm s_client
                   4692: should attempt connections using IPv6 only.
                   4693: .It Fl bugs
                   4694: There are several known bugs in SSL and TLS implementations.
                   4695: Adding this option enables various workarounds.
                   4696: .It Fl CAfile Ar file
                   4697: A
                   4698: .Ar file
                   4699: containing trusted certificates to use during server authentication
                   4700: and to use when attempting to build the client certificate chain.
                   4701: .It Fl CApath Ar directory
                   4702: The
                   4703: .Ar directory
                   4704: to use for server certificate verification.
                   4705: This directory must be in
                   4706: .Qq hash format ;
                   4707: see
                   4708: .Fl verify
                   4709: for more information.
                   4710: These are also used when building the client certificate chain.
                   4711: .It Fl cert Ar file
                   4712: The certificate to use, if one is requested by the server.
                   4713: The default is not to use a certificate.
                   4714: .It Xo
                   4715: .Fl check_ss_sig ,
                   4716: .Fl crl_check ,
                   4717: .Fl crl_check_all ,
                   4718: .Fl extended_crl ,
                   4719: .Fl ignore_critical ,
                   4720: .Fl issuer_checks ,
                   4721: .Fl policy_check ,
                   4722: .Fl x509_strict
                   4723: .Xc
                   4724: Set various certificate chain validation options.
                   4725: See the
                   4726: .Nm VERIFY
                   4727: command for details.
                   4728: .It Fl cipher Ar cipherlist
                   4729: This allows the cipher list sent by the client to be modified.
                   4730: Although the server determines which cipher suite is used, it should take
                   4731: the first supported cipher in the list sent by the client.
                   4732: See the
                   4733: .Sx CIPHERS
                   4734: section above for more information.
                   4735: .It Xo
                   4736: .Fl connect Ar host : Ns Ar port |
                   4737: .Ar host Ns / Ns Ar port
                   4738: .Xc
                   4739: This specifies the
                   4740: .Ar host
                   4741: and optional
                   4742: .Ar port
                   4743: to connect to.
                   4744: If not specified, an attempt is made to connect to the local host
                   4745: on port 4433.
                   4746: Alternatively, the host and port pair may be separated using a forward-slash
                   4747: character.
                   4748: This form is useful for numeric IPv6 addresses.
                   4749: .It Fl crlf
                   4750: This option translates a line feed from the terminal into CR+LF as required
                   4751: by some servers.
                   4752: .It Fl debug
                   4753: Print extensive debugging information including a hex dump of all traffic.
                   4754: .It Fl ign_eof
                   4755: Inhibit shutting down the connection when end of file is reached in the
                   4756: input.
                   4757: .It Fl key Ar keyfile
                   4758: The private key to use.
                   4759: If not specified, the certificate file will be used.
                   4760: .It Fl msg
                   4761: Show all protocol messages with hex dump.
                   4762: .It Fl nbio
                   4763: Turns on non-blocking I/O.
                   4764: .It Fl nbio_test
                   4765: Tests non-blocking I/O.
1.31      jmc      4766: .It Fl no_tls1 | no_tls1_1 | no_tls1_2
1.1       jsing    4767: By default, the initial handshake uses a method which should be compatible
1.31      jmc      4768: with servers supporting any version of TLS.
                   4769: These options disable the use of TLS1.0, 1.1, and 1.2, respectively.
1.1       jsing    4770: .Pp
                   4771: Unfortunately there are a lot of ancient and broken servers in use which
                   4772: cannot handle this technique and will fail to connect.
                   4773: .It Fl no_ticket
                   4774: Disable RFC 4507 session ticket support.
                   4775: .It Fl pause
                   4776: Pauses 1 second between each read and write call.
                   4777: .It Fl prexit
                   4778: Print session information when the program exits.
                   4779: This will always attempt
                   4780: to print out information even if the connection fails.
                   4781: Normally, information will only be printed out once if the connection succeeds.
                   4782: This option is useful because the cipher in use may be renegotiated
                   4783: or the connection may fail because a client certificate is required or is
                   4784: requested only after an attempt is made to access a certain URL.
                   4785: .Sy Note :
                   4786: the output produced by this option is not always accurate because a
                   4787: connection might never have been established.
1.11      bluhm    4788: .It Fl proxy Ar host : Ns Ar port
                   4789: Use the HTTP proxy at
                   4790: .Ar host
                   4791: and
                   4792: .Ar port .
                   4793: The connection to the proxy is done in cleartext and the
                   4794: .Fl connect
                   4795: argument is given to the proxy.
                   4796: If not specified, localhost is used as final destination.
                   4797: After that, switch the connection through the proxy to the destination
                   4798: to TLS.
1.1       jsing    4799: .It Fl psk Ar key
                   4800: Use the PSK key
                   4801: .Ar key
                   4802: when using a PSK cipher suite.
                   4803: The key is given as a hexadecimal number without the leading 0x,
                   4804: for example -psk 1a2b3c4d.
                   4805: .It Fl psk_identity Ar identity
                   4806: Use the PSK identity
                   4807: .Ar identity
                   4808: when using a PSK cipher suite.
                   4809: .It Fl quiet
                   4810: Inhibit printing of session and certificate information.
                   4811: This implicitly turns on
                   4812: .Fl ign_eof
                   4813: as well.
                   4814: .It Fl reconnect
                   4815: Reconnects to the same server 5 times using the same session ID; this can
                   4816: be used as a test that session caching is working.
1.5       jsing    4817: .It Fl servername Ar name
                   4818: Include the TLS Server Name Indication (SNI) extension in the ClientHello
                   4819: message, using the specified server
                   4820: .Ar name .
1.1       jsing    4821: .It Fl showcerts
                   4822: Display the whole server certificate chain: normally only the server
                   4823: certificate itself is displayed.
                   4824: .It Fl starttls Ar protocol
                   4825: Send the protocol-specific message(s) to switch to TLS for communication.
                   4826: .Ar protocol
                   4827: is a keyword for the intended protocol.
                   4828: Currently, the supported keywords are
                   4829: .Qq ftp ,
                   4830: .Qq imap ,
                   4831: .Qq smtp ,
                   4832: .Qq pop3 ,
                   4833: and
                   4834: .Qq xmpp .
                   4835: .It Fl state
                   4836: Prints out the SSL session states.
1.31      jmc      4837: .It Fl tls1 | tls1_1 | tls1_2
                   4838: Permit only TLS1.0, 1.1, or 1.2, respectively.
1.1       jsing    4839: .It Fl tlsextdebug
                   4840: Print out a hex dump of any TLS extensions received from the server.
                   4841: .It Fl verify Ar depth
                   4842: The verify
                   4843: .Ar depth
                   4844: to use.
                   4845: This specifies the maximum length of the
                   4846: server certificate chain and turns on server certificate verification.
                   4847: Currently the verify operation continues after errors so all the problems
                   4848: with a certificate chain can be seen.
                   4849: As a side effect the connection will never fail due to a server
                   4850: certificate verify failure.
1.19      landry   4851: .It Fl xmpphost Ar hostname
                   4852: This option, when used with
                   4853: .Fl starttls Ar xmpp ,
                   4854: specifies the host for the "to" attribute of the stream element.
                   4855: If this option is not specified then the host specified with
                   4856: .Fl connect
                   4857: will be used.
1.1       jsing    4858: .El
                   4859: .Sh S_CLIENT CONNECTED COMMANDS
                   4860: If a connection is established with an SSL server, any data received
                   4861: from the server is displayed and any key presses will be sent to the
                   4862: server.
                   4863: When used interactively (which means neither
                   4864: .Fl quiet
                   4865: nor
                   4866: .Fl ign_eof
                   4867: have been given), the session will be renegotiated if the line begins with an
                   4868: .Em R ;
                   4869: if the line begins with a
                   4870: .Em Q
                   4871: or if end of file is reached, the connection will be closed down.
                   4872: .Sh S_CLIENT NOTES
                   4873: .Nm s_client
                   4874: can be used to debug SSL servers.
                   4875: To connect to an SSL HTTP server the command:
                   4876: .Pp
                   4877: .Dl $ openssl s_client -connect servername:443
                   4878: .Pp
                   4879: would typically be used
                   4880: .Pq HTTPS uses port 443 .
                   4881: If the connection succeeds, an HTTP command can be given such as
                   4882: .Qq GET
                   4883: to retrieve a web page.
                   4884: .Pp
                   4885: If the handshake fails, there are several possible causes; if it is
                   4886: nothing obvious like no client certificate, then the
1.31      jmc      4887: .Fl bugs , tls1 , tls1_1, tls1_2 , no_tls1 , no_tls1_1 ,
1.1       jsing    4888: and
1.6       guenther 4889: .Fl no_tls1_2
1.1       jsing    4890: options can be tried in case it is a buggy server.
                   4891: .Pp
                   4892: A frequent problem when attempting to get client certificates working
                   4893: is that a web client complains it has no certificates or gives an empty
                   4894: list to choose from.
                   4895: This is normally because the server is not sending the client's certificate
                   4896: authority in its
                   4897: .Qq acceptable CA list
                   4898: when it requests a certificate.
                   4899: By using
                   4900: .Nm s_client
                   4901: the CA list can be viewed and checked.
                   4902: However some servers only request client authentication
                   4903: after a specific URL is requested.
                   4904: To obtain the list in this case it is necessary to use the
                   4905: .Fl prexit
                   4906: option and send an HTTP request for an appropriate page.
                   4907: .Pp
                   4908: If a certificate is specified on the command line using the
                   4909: .Fl cert
                   4910: option, it will not be used unless the server specifically requests
                   4911: a client certificate.
                   4912: Therefore merely including a client certificate
                   4913: on the command line is no guarantee that the certificate works.
                   4914: .Pp
                   4915: If there are problems verifying a server certificate, the
                   4916: .Fl showcerts
                   4917: option can be used to show the whole chain.
                   4918: .Pp
                   4919: Compression methods are only supported for
                   4920: .Fl tls1 .
                   4921: .Sh S_CLIENT BUGS
                   4922: Because this program has a lot of options and also because some of
                   4923: the techniques used are rather old, the C source of
                   4924: .Nm s_client
                   4925: is rather hard to read and not a model of how things should be done.
                   4926: A typical SSL client program would be much simpler.
                   4927: .Pp
                   4928: The
                   4929: .Fl verify
                   4930: option should really exit if the server verification fails.
                   4931: .Pp
                   4932: The
                   4933: .Fl prexit
                   4934: option is a bit of a hack.
                   4935: We should really report information whenever a session is renegotiated.
                   4936: .\"
                   4937: .\" S_SERVER
                   4938: .\"
                   4939: .Sh S_SERVER
                   4940: .nr nS 1
                   4941: .Nm "openssl s_server"
                   4942: .Bk -words
                   4943: .Op Fl accept Ar port
                   4944: .Op Fl bugs
                   4945: .Op Fl CAfile Ar file
                   4946: .Op Fl CApath Ar directory
                   4947: .Op Fl cert Ar file
                   4948: .Op Fl cipher Ar cipherlist
                   4949: .Op Fl context Ar id
                   4950: .Op Fl crl_check
                   4951: .Op Fl crl_check_all
                   4952: .Op Fl crlf
                   4953: .Op Fl dcert Ar file
                   4954: .Op Fl debug
                   4955: .Op Fl dhparam Ar file
                   4956: .Op Fl dkey Ar file
                   4957: .Op Fl hack
                   4958: .Op Fl HTTP
                   4959: .Op Fl id_prefix Ar arg
                   4960: .Op Fl key Ar keyfile
                   4961: .Op Fl msg
                   4962: .Op Fl nbio
                   4963: .Op Fl nbio_test
                   4964: .Op Fl no_dhe
                   4965: .Op Fl no_tls1
1.6       guenther 4966: .Op Fl no_tls1_1
                   4967: .Op Fl no_tls1_2
1.1       jsing    4968: .Op Fl no_tmp_rsa
                   4969: .Op Fl nocert
                   4970: .Op Fl psk Ar key
                   4971: .Op Fl psk_hint Ar hint
                   4972: .Op Fl quiet
                   4973: .Op Fl serverpref
                   4974: .Op Fl state
                   4975: .Op Fl tls1
1.31      jmc      4976: .Op Fl tls1_1
                   4977: .Op Fl tls1_2
1.1       jsing    4978: .Op Fl Verify Ar depth
                   4979: .Op Fl verify Ar depth
                   4980: .Op Fl WWW
                   4981: .Op Fl www
                   4982: .Ek
                   4983: .nr nS 0
                   4984: .Pp
                   4985: The
                   4986: .Nm s_server
                   4987: command implements a generic SSL/TLS server which listens
                   4988: for connections on a given port using SSL/TLS.
                   4989: .Pp
                   4990: The options are as follows:
                   4991: .Bl -tag -width Ds
                   4992: .It Fl accept Ar port
                   4993: The TCP
                   4994: .Ar port
                   4995: to listen on for connections.
                   4996: If not specified, 4433 is used.
                   4997: .It Fl bugs
                   4998: There are several known bugs in SSL and TLS implementations.
                   4999: Adding this option enables various workarounds.
                   5000: .It Fl CAfile Ar file
                   5001: A file containing trusted certificates to use during client authentication
                   5002: and to use when attempting to build the server certificate chain.
                   5003: The list is also used in the list of acceptable client CAs passed to the
                   5004: client when a certificate is requested.
                   5005: .It Fl CApath Ar directory
                   5006: The
                   5007: .Ar directory
                   5008: to use for client certificate verification.
                   5009: This directory must be in
                   5010: .Qq hash format ;
                   5011: see
                   5012: .Fl verify
                   5013: for more information.
                   5014: These are also used when building the server certificate chain.
                   5015: .It Fl cert Ar file
                   5016: The certificate to use; most server's cipher suites require the use of a
                   5017: certificate and some require a certificate with a certain public key type:
                   5018: for example the DSS cipher suites require a certificate containing a DSS
                   5019: .Pq DSA
                   5020: key.
                   5021: If not specified, the file
                   5022: .Pa server.pem
                   5023: will be used.
                   5024: .It Fl cipher Ar cipherlist
                   5025: This allows the cipher list used by the server to be modified.
                   5026: When the client sends a list of supported ciphers, the first client cipher
                   5027: also included in the server list is used.
                   5028: Because the client specifies the preference order, the order of the server
                   5029: cipherlist is irrelevant.
                   5030: See the
                   5031: .Sx CIPHERS
                   5032: section for more information.
                   5033: .It Fl context Ar id
                   5034: Sets the SSL context ID.
                   5035: It can be given any string value.
                   5036: If this option is not present, a default value will be used.
                   5037: .It Fl crl_check , crl_check_all
                   5038: Check the peer certificate has not been revoked by its CA.
                   5039: The CRLs are appended to the certificate file.
                   5040: With the
                   5041: .Fl crl_check_all
                   5042: option, all CRLs of all CAs in the chain are checked.
                   5043: .It Fl crlf
                   5044: This option translates a line feed from the terminal into CR+LF.
                   5045: .It Fl dcert Ar file , Fl dkey Ar file
                   5046: Specify an additional certificate and private key; these behave in the
                   5047: same manner as the
                   5048: .Fl cert
                   5049: and
                   5050: .Fl key
                   5051: options except there is no default if they are not specified
                   5052: .Pq no additional certificate or key is used .
                   5053: As noted above some cipher suites require a certificate containing a key of
                   5054: a certain type.
                   5055: Some cipher suites need a certificate carrying an RSA key
                   5056: and some a DSS
                   5057: .Pq DSA
                   5058: key.
                   5059: By using RSA and DSS certificates and keys,
                   5060: a server can support clients which only support RSA or DSS cipher suites
                   5061: by using an appropriate certificate.
                   5062: .It Fl debug
                   5063: Print extensive debugging information including a hex dump of all traffic.
                   5064: .It Fl dhparam Ar file
                   5065: The DH parameter file to use.
                   5066: The ephemeral DH cipher suites generate keys
                   5067: using a set of DH parameters.
                   5068: If not specified, an attempt is made to
                   5069: load the parameters from the server certificate file.
                   5070: If this fails, a static set of parameters hard coded into the
                   5071: .Nm s_server
                   5072: program will be used.
                   5073: .It Fl hack
                   5074: This option enables a further workaround for some early Netscape
                   5075: SSL code
                   5076: .Pq \&? .
                   5077: .It Fl HTTP
                   5078: Emulates a simple web server.
                   5079: Pages will be resolved relative to the current directory;
                   5080: for example if the URL
                   5081: .Pa https://myhost/page.html
                   5082: is requested, the file
                   5083: .Pa ./page.html
                   5084: will be loaded.
                   5085: The files loaded are assumed to contain a complete and correct HTTP
                   5086: response (lines that are part of the HTTP response line and headers
                   5087: must end with CRLF).
                   5088: .It Fl id_prefix Ar arg
                   5089: Generate SSL/TLS session IDs prefixed by
                   5090: .Ar arg .
                   5091: This is mostly useful for testing any SSL/TLS code
                   5092: .Pq e.g. proxies
                   5093: that wish to deal with multiple servers, when each of which might be
                   5094: generating a unique range of session IDs
                   5095: .Pq e.g. with a certain prefix .
                   5096: .It Fl key Ar keyfile
                   5097: The private key to use.
                   5098: If not specified, the certificate file will be used.
                   5099: .It Fl msg
                   5100: Show all protocol messages with hex dump.
                   5101: .It Fl nbio
                   5102: Turns on non-blocking I/O.
                   5103: .It Fl nbio_test
                   5104: Tests non-blocking I/O.
                   5105: .It Fl no_dhe
                   5106: If this option is set, no DH parameters will be loaded, effectively
                   5107: disabling the ephemeral DH cipher suites.
1.31      jmc      5108: .It Fl no_tls1 | no_tls1_1 | no_tls1_2
1.1       jsing    5109: By default, the initial handshake uses a method which should be compatible
1.32      jmc      5110: with clients supporting any version of TLS.
1.31      jmc      5111: These options disable the use of TLS1.0, 1.1, and 1.2, respectively.
1.1       jsing    5112: .It Fl no_tmp_rsa
                   5113: Certain export cipher suites sometimes use a temporary RSA key; this option
                   5114: disables temporary RSA key generation.
                   5115: .It Fl nocert
                   5116: If this option is set, no certificate is used.
                   5117: This restricts the cipher suites available to the anonymous ones
                   5118: .Pq currently just anonymous DH .
                   5119: .It Fl psk Ar key
                   5120: Use the PSK key
                   5121: .Ar key
                   5122: when using a PSK cipher suite.
                   5123: The key is given as a hexadecimal number without the leading 0x,
                   5124: for example -psk 1a2b3c4d.
                   5125: .It Fl psk_hint Ar hint
                   5126: Use the PSK identity hint
                   5127: .Ar hint
                   5128: when using a PSK cipher suite.
                   5129: .It Fl quiet
                   5130: Inhibit printing of session and certificate information.
                   5131: .It Fl serverpref
                   5132: Use server's cipher preferences.
                   5133: .It Fl state
                   5134: Prints out the SSL session states.
1.31      jmc      5135: .It Fl tls1 | tls1_1 | tls1_2
                   5136: Permit only TLS1.0, 1.1, or 1.2, respectively.
1.1       jsing    5137: .It Fl WWW
                   5138: Emulates a simple web server.
                   5139: Pages will be resolved relative to the current directory;
                   5140: for example if the URL
                   5141: .Pa https://myhost/page.html
                   5142: is requested, the file
                   5143: .Pa ./page.html
                   5144: will be loaded.
                   5145: .It Fl www
                   5146: Sends a status message back to the client when it connects.
                   5147: This includes lots of information about the ciphers used and various
                   5148: session parameters.
                   5149: The output is in HTML format so this option will normally be used with a
                   5150: web browser.
                   5151: .It Fl Verify Ar depth , Fl verify Ar depth
                   5152: The verify
                   5153: .Ar depth
                   5154: to use.
                   5155: This specifies the maximum length of the client certificate chain
                   5156: and makes the server request a certificate from the client.
                   5157: With the
                   5158: .Fl Verify
                   5159: option, the client must supply a certificate or an error occurs.
                   5160: With the
                   5161: .Fl verify
                   5162: option, a certificate is requested but the client does not have to send one.
                   5163: .El
                   5164: .Sh S_SERVER CONNECTED COMMANDS
                   5165: If a connection request is established with an SSL client and neither the
                   5166: .Fl www
                   5167: nor the
                   5168: .Fl WWW
                   5169: option has been used, then normally any data received
                   5170: from the client is displayed and any key presses will be sent to the client.
                   5171: .Pp
                   5172: Certain single letter commands are also recognized which perform special
                   5173: operations: these are listed below.
                   5174: .Bl -tag -width "XXXX"
                   5175: .It Ar P
                   5176: Send some plain text down the underlying TCP connection: this should
                   5177: cause the client to disconnect due to a protocol violation.
                   5178: .It Ar Q
                   5179: End the current SSL connection and exit.
                   5180: .It Ar q
                   5181: End the current SSL connection, but still accept new connections.
                   5182: .It Ar R
                   5183: Renegotiate the SSL session and request a client certificate.
                   5184: .It Ar r
                   5185: Renegotiate the SSL session.
                   5186: .It Ar S
                   5187: Print out some session cache status information.
                   5188: .El
                   5189: .Sh S_SERVER NOTES
                   5190: .Nm s_server
                   5191: can be used to debug SSL clients.
                   5192: To accept connections from a web browser the command:
                   5193: .Pp
                   5194: .Dl $ openssl s_server -accept 443 -www
                   5195: .Pp
                   5196: can be used, for example.
                   5197: .Pp
                   5198: Most web browsers
                   5199: .Pq in particular Netscape and MSIE
                   5200: only support RSA cipher suites, so they cannot connect to servers
                   5201: which don't use a certificate carrying an RSA key or a version of
                   5202: .Nm OpenSSL
                   5203: with RSA disabled.
                   5204: .Pp
                   5205: Although specifying an empty list of CAs when requesting a client certificate
                   5206: is strictly speaking a protocol violation, some SSL
                   5207: clients interpret this to mean any CA is acceptable.
                   5208: This is useful for debugging purposes.
                   5209: .Pp
                   5210: The session parameters can printed out using the
                   5211: .Nm sess_id
                   5212: program.
                   5213: .Sh S_SERVER BUGS
                   5214: Because this program has a lot of options and also because some of
                   5215: the techniques used are rather old, the C source of
                   5216: .Nm s_server
                   5217: is rather hard to read and not a model of how things should be done.
                   5218: A typical SSL server program would be much simpler.
                   5219: .Pp
                   5220: The output of common ciphers is wrong: it just gives the list of ciphers that
                   5221: .Nm OpenSSL
                   5222: recognizes and the client supports.
                   5223: .Pp
                   5224: There should be a way for the
                   5225: .Nm s_server
                   5226: program to print out details of any
                   5227: unknown cipher suites a client says it supports.
                   5228: .\"
                   5229: .\" S_TIME
                   5230: .\"
                   5231: .Sh S_TIME
                   5232: .nr nS 1
                   5233: .Nm "openssl s_time"
                   5234: .Bk -words
                   5235: .Op Fl bugs
                   5236: .Op Fl CAfile Ar file
                   5237: .Op Fl CApath Ar directory
                   5238: .Op Fl cert Ar file
                   5239: .Op Fl cipher Ar cipherlist
                   5240: .Op Fl connect Ar host : Ns Ar port
                   5241: .Op Fl key Ar keyfile
                   5242: .Op Fl nbio
                   5243: .Op Fl new
1.20      lteo     5244: .Op Fl no_shutdown
1.1       jsing    5245: .Op Fl reuse
                   5246: .Op Fl time Ar seconds
                   5247: .Op Fl verify Ar depth
                   5248: .Op Fl www Ar page
                   5249: .Ek
                   5250: .nr nS 0
                   5251: .Pp
                   5252: The
                   5253: .Nm s_client
                   5254: command implements a generic SSL/TLS client which connects to a
                   5255: remote host using SSL/TLS.
                   5256: It can request a page from the server and includes
                   5257: the time to transfer the payload data in its timing measurements.
                   5258: It measures the number of connections within a given timeframe,
                   5259: the amount of data transferred
                   5260: .Pq if any ,
                   5261: and calculates the average time spent for one connection.
                   5262: .Pp
                   5263: The options are as follows:
                   5264: .Bl -tag -width Ds
                   5265: .It Fl bugs
                   5266: There are several known bugs in SSL and TLS implementations.
                   5267: Adding this option enables various workarounds.
                   5268: .It Fl CAfile Ar file
                   5269: A file containing trusted certificates to use during server authentication
                   5270: and to use when attempting to build the client certificate chain.
                   5271: .It Fl CApath Ar directory
                   5272: The directory to use for server certificate verification.
                   5273: This directory must be in
                   5274: .Qq hash format ;
                   5275: see
                   5276: .Nm verify
                   5277: for more information.
                   5278: These are also used when building the client certificate chain.
                   5279: .It Fl cert Ar file
                   5280: The certificate to use, if one is requested by the server.
                   5281: The default is not to use a certificate.
                   5282: The file is in PEM format.
                   5283: .It Fl cipher Ar cipherlist
                   5284: This allows the cipher list sent by the client to be modified.
                   5285: Although the server determines which cipher suite is used,
                   5286: it should take the first supported cipher in the list sent by the client.
                   5287: See the
                   5288: .Nm ciphers
                   5289: command for more information.
                   5290: .It Fl connect Ar host : Ns Ar port
                   5291: This specifies the host and optional port to connect to.
                   5292: .It Fl key Ar keyfile
                   5293: The private key to use.
                   5294: If not specified, the certificate file will be used.
                   5295: The file is in PEM format.
                   5296: .It Fl nbio
                   5297: Turns on non-blocking I/O.
                   5298: .It Fl new
                   5299: Performs the timing test using a new session ID for each connection.
                   5300: If neither
                   5301: .Fl new
                   5302: nor
                   5303: .Fl reuse
                   5304: are specified,
                   5305: they are both on by default and executed in sequence.
1.20      lteo     5306: .It Fl no_shutdown
1.21      jmc      5307: Shut down the connection without sending a
1.20      lteo     5308: .Dq close notify
                   5309: shutdown alert to the server.
1.1       jsing    5310: .It Fl reuse
                   5311: Performs the timing test using the same session ID;
                   5312: this can be used as a test that session caching is working.
                   5313: If neither
                   5314: .Fl new
                   5315: nor
                   5316: .Fl reuse
                   5317: are specified,
                   5318: they are both on by default and executed in sequence.
                   5319: .It Fl time Ar seconds
                   5320: Specifies how long
                   5321: .Pq in seconds
                   5322: .Nm s_time
                   5323: should establish connections and
                   5324: optionally transfer payload data from a server.
                   5325: The default is 30 seconds.
                   5326: Server and client performance and the link speed
                   5327: determine how many connections
                   5328: .Nm s_time
                   5329: can establish.
                   5330: .It Fl verify Ar depth
                   5331: The verify depth to use.
                   5332: This specifies the maximum length of the server certificate chain
                   5333: and turns on server certificate verification.
                   5334: Currently the verify operation continues after errors, so all the problems
                   5335: with a certificate chain can be seen.
                   5336: As a side effect,
                   5337: the connection will never fail due to a server certificate verify failure.
                   5338: .It Fl www Ar page
                   5339: This specifies the page to GET from the server.
                   5340: A value of
                   5341: .Sq /
                   5342: gets the index.htm[l] page.
                   5343: If this parameter is not specified,
                   5344: .Nm s_time
                   5345: will only perform the handshake to establish SSL connections
                   5346: but not transfer any payload data.
                   5347: .El
                   5348: .Sh S_TIME NOTES
                   5349: .Nm s_client
                   5350: can be used to measure the performance of an SSL connection.
                   5351: To connect to an SSL HTTP server and get the default page the command
                   5352: .Bd -literal -offset indent
                   5353: $ openssl s_time -connect servername:443 -www / -CApath yourdir \e
1.18      jmc      5354:        -CAfile yourfile.pem -cipher commoncipher
1.1       jsing    5355: .Ed
                   5356: .Pp
                   5357: would typically be used
                   5358: .Pq HTTPS uses port 443 .
                   5359: .Dq commoncipher
                   5360: is a cipher to which both client and server can agree;
                   5361: see the
                   5362: .Nm ciphers
                   5363: command for details.
                   5364: .Pp
                   5365: If the handshake fails, there are several possible causes:
                   5366: if it is nothing obvious like no client certificate, the
                   5367: .Fl bugs
1.18      jmc      5368: option can be tried in case it is a buggy server.
1.1       jsing    5369: .Pp
                   5370: A frequent problem when attempting to get client certificates working
                   5371: is that a web client complains it has no certificates or gives an empty
                   5372: list to choose from.
                   5373: This is normally because the server is not sending
                   5374: the clients certificate authority in its
                   5375: .Qq acceptable CA list
                   5376: when it requests a certificate.
                   5377: By using
                   5378: .Nm s_client ,
                   5379: the CA list can be viewed and checked.
                   5380: However some servers only request client authentication
                   5381: after a specific URL is requested.
                   5382: To obtain the list in this case, it is necessary to use the
                   5383: .Fl prexit
                   5384: option of
                   5385: .Nm s_client
                   5386: and send an HTTP request for an appropriate page.
                   5387: .Pp
                   5388: If a certificate is specified on the command line using the
                   5389: .Fl cert
                   5390: option,
                   5391: it will not be used unless the server specifically requests
                   5392: a client certificate.
                   5393: Therefore merely including a client certificate
                   5394: on the command line is no guarantee that the certificate works.
                   5395: .Sh S_TIME BUGS
                   5396: Because this program does not have all the options of the
                   5397: .Nm s_client
                   5398: program to turn protocols on and off,
                   5399: you may not be able to measure the performance
                   5400: of all protocols with all servers.
                   5401: .Pp
                   5402: The
                   5403: .Fl verify
                   5404: option should really exit if the server verification fails.
                   5405: .\"
                   5406: .\" SESS_ID
                   5407: .\"
                   5408: .Sh SESS_ID
                   5409: .nr nS 1
                   5410: .Nm "openssl sess_id"
                   5411: .Bk -words
                   5412: .Op Fl cert
                   5413: .Op Fl context Ar ID
                   5414: .Op Fl in Ar file
                   5415: .Op Fl inform Ar DER | PEM
                   5416: .Op Fl noout
                   5417: .Op Fl out Ar file
                   5418: .Op Fl outform Ar DER | PEM
                   5419: .Op Fl text
                   5420: .Ek
                   5421: .nr nS 0
                   5422: .Pp
                   5423: The
                   5424: .Nm sess_id
                   5425: program processes the encoded version of the SSL session structure and
                   5426: optionally prints out SSL session details
                   5427: .Pq for example the SSL session master key
                   5428: in human readable format.
                   5429: Since this is a diagnostic tool that needs some knowledge of the SSL
                   5430: protocol to use properly, most users will not need to use it.
                   5431: .Pp
                   5432: The options are as follows:
                   5433: .Bl -tag -width Ds
                   5434: .It Fl cert
                   5435: If a certificate is present in the session,
                   5436: it will be output using this option;
                   5437: if the
                   5438: .Fl text
                   5439: option is also present, then it will be printed out in text form.
                   5440: .It Fl context Ar ID
                   5441: This option can set the session ID so the output session information uses the
                   5442: supplied
                   5443: .Ar ID .
                   5444: The
                   5445: .Ar ID
                   5446: can be any string of characters.
                   5447: This option won't normally be used.
                   5448: .It Fl in Ar file
                   5449: This specifies the input
                   5450: .Ar file
                   5451: to read session information from, or standard input by default.
                   5452: .It Fl inform Ar DER | PEM
                   5453: This specifies the input format.
                   5454: The
                   5455: .Ar DER
                   5456: argument uses an ASN1 DER-encoded
                   5457: format containing session details.
                   5458: The precise format can vary from one version to the next.
                   5459: The
                   5460: .Ar PEM
                   5461: form is the default format: it consists of the DER
                   5462: format base64-encoded with additional header and footer lines.
                   5463: .It Fl noout
                   5464: This option prevents output of the encoded version of the session.
                   5465: .It Fl out Ar file
                   5466: This specifies the output
                   5467: .Ar file
                   5468: to write session information to, or standard
                   5469: output if this option is not specified.
                   5470: .It Fl outform Ar DER | PEM
                   5471: This specifies the output format; the options have the same meaning as the
                   5472: .Fl inform
                   5473: option.
                   5474: .It Fl text
                   5475: Prints out the various public or private key components in
                   5476: plain text in addition to the encoded version.
                   5477: .El
                   5478: .Sh SESS_ID OUTPUT
                   5479: Typical output:
                   5480: .Bd -literal
                   5481: SSL-Session:
                   5482:     Protocol  : TLSv1
                   5483:     Cipher    : 0016
                   5484:     Session-ID: 871E62626C554CE95488823752CBD5F3673A3EF3DCE9C67BD916C809914B40ED
                   5485:     Session-ID-ctx: 01000000
                   5486:     Master-Key: A7CEFC571974BE02CAC305269DC59F76EA9F0B180CB6642697A68251F2D2BB57E51DBBB4C7885573192AE9AEE220FACD
                   5487:     Key-Arg   : None
                   5488:     Start Time: 948459261
                   5489:     Timeout   : 300 (sec)
                   5490:     Verify return code 0 (ok)
                   5491: .Ed
                   5492: .Pp
                   5493: These are described below in more detail.
                   5494: .Pp
                   5495: .Bl -tag -width "Verify return code " -compact
                   5496: .It Ar Protocol
1.18      jmc      5497: This is the protocol in use.
1.1       jsing    5498: .It Ar Cipher
                   5499: The cipher used is the actual raw SSL or TLS cipher code;
                   5500: see the SSL or TLS specifications for more information.
                   5501: .It Ar Session-ID
                   5502: The SSL session ID in hex format.
                   5503: .It Ar Session-ID-ctx
                   5504: The session ID context in hex format.
                   5505: .It Ar Master-Key
                   5506: This is the SSL session master key.
                   5507: .It Ar Key-Arg
                   5508: The key argument; this is only used in SSL v2.
                   5509: .It Ar Start Time
                   5510: This is the session start time, represented as an integer in standard
                   5511: .Ux
                   5512: format.
                   5513: .It Ar Timeout
                   5514: The timeout in seconds.
                   5515: .It Ar Verify return code
                   5516: This is the return code when an SSL client certificate is verified.
                   5517: .El
                   5518: .Sh SESS_ID NOTES
                   5519: The PEM-encoded session format uses the header and footer lines:
                   5520: .Bd -unfilled -offset indent
                   5521: -----BEGIN SSL SESSION PARAMETERS-----
                   5522: -----END SSL SESSION PARAMETERS-----
                   5523: .Ed
                   5524: .Pp
                   5525: Since the SSL session output contains the master key, it is possible to read
                   5526: the contents of an encrypted session using this information.
                   5527: Therefore appropriate security precautions
                   5528: should be taken if the information is being output by a
                   5529: .Qq real
                   5530: application.
                   5531: This is, however, strongly discouraged and should only be used for
                   5532: debugging purposes.
                   5533: .Sh SESS_ID BUGS
                   5534: The cipher and start time should be printed out in human readable form.
                   5535: .\"
                   5536: .\" SMIME
                   5537: .\"
                   5538: .Sh SMIME
                   5539: .nr nS 1
                   5540: .Nm "openssl smime"
                   5541: .Bk -words
                   5542: .Oo
                   5543: .Fl aes128 | aes192 | aes256 | des |
                   5544: .Fl des3 | rc2-40 | rc2-64 | rc2-128
                   5545: .Oc
                   5546: .Op Fl binary
                   5547: .Op Fl CAfile Ar file
                   5548: .Op Fl CApath Ar directory
                   5549: .Op Fl certfile Ar file
                   5550: .Op Fl check_ss_sig
                   5551: .Op Fl content Ar file
                   5552: .Op Fl crl_check
                   5553: .Op Fl crl_check_all
                   5554: .Op Fl decrypt
                   5555: .Op Fl encrypt
                   5556: .Op Fl extended_crl
                   5557: .Op Fl from Ar addr
                   5558: .Op Fl ignore_critical
                   5559: .Op Fl in Ar file
                   5560: .Op Fl indef
                   5561: .Op Fl inform Ar DER | PEM | SMIME
                   5562: .Op Fl inkey Ar file
                   5563: .Op Fl issuer_checks
1.22      bcook    5564: .Op Fl keyform Ar PEM
1.1       jsing    5565: .Op Fl md Ar digest
                   5566: .Op Fl noattr
                   5567: .Op Fl nocerts
                   5568: .Op Fl nochain
                   5569: .Op Fl nodetach
                   5570: .Op Fl noindef
                   5571: .Op Fl nointern
                   5572: .Op Fl nosigs
                   5573: .Op Fl noverify
                   5574: .Op Fl out Ar file
                   5575: .Op Fl outform Ar DER | PEM | SMIME
                   5576: .Op Fl passin Ar arg
                   5577: .Op Fl pk7out
                   5578: .Op Fl policy_check
                   5579: .Op Fl recip Ar file
                   5580: .Op Fl resign
                   5581: .Op Fl sign
                   5582: .Op Fl signer Ar file
                   5583: .Op Fl stream
                   5584: .Op Fl subject Ar s
                   5585: .Op Fl text
                   5586: .Op Fl to Ar addr
                   5587: .Op Fl verify
                   5588: .Op Fl x509_strict
                   5589: .Op Ar cert.pem ...
                   5590: .Ek
                   5591: .nr nS 0
                   5592: .Pp
                   5593: The
                   5594: .Nm smime
                   5595: command handles
                   5596: .Em S/MIME
                   5597: mail.
                   5598: It can encrypt, decrypt, sign, and verify
                   5599: .Em S/MIME
                   5600: messages.
                   5601: .Pp
                   5602: There are six operation options that set the type of operation to be performed.
                   5603: The meaning of the other options varies according to the operation type.
                   5604: .Pp
                   5605: The six operation options are as follows:
                   5606: .Bl -tag -width "XXXX"
                   5607: .It Fl decrypt
                   5608: Decrypt mail using the supplied certificate and private key.
                   5609: Expects an encrypted mail message in
                   5610: .Em MIME
                   5611: format for the input file.
                   5612: The decrypted mail is written to the output file.
                   5613: .It Fl encrypt
                   5614: Encrypt mail for the given recipient certificates.
                   5615: Input file is the message to be encrypted.
                   5616: The output file is the encrypted mail in
                   5617: .Em MIME
                   5618: format.
                   5619: .It Fl pk7out
                   5620: Takes an input message and writes out a PEM-encoded PKCS#7 structure.
                   5621: .It Fl resign
                   5622: Resign a message: take an existing message and one or more new signers.
                   5623: .It Fl sign
                   5624: Sign mail using the supplied certificate and private key.
                   5625: Input file is the message to be signed.
                   5626: The signed message in
                   5627: .Em MIME
                   5628: format is written to the output file.
                   5629: .It Fl verify
                   5630: Verify signed mail.
                   5631: Expects a signed mail message on input and outputs the signed data.
                   5632: Both clear text and opaque signing is supported.
                   5633: .El
                   5634: .Pp
1.14      jmc      5635: The remaining options are as follows:
1.1       jsing    5636: .Bl -tag -width "XXXX"
                   5637: .It Xo
                   5638: .Fl aes128 | aes192 | aes256 | des |
                   5639: .Fl des3 | rc2-40 | rc2-64 | rc2-128
                   5640: .Xc
                   5641: The encryption algorithm to use.
                   5642: 128-, 192-, or 256-bit AES,
                   5643: DES
                   5644: .Pq 56 bits ,
                   5645: triple DES
                   5646: .Pq 168 bits ,
                   5647: or 40-, 64-, or 128-bit RC2, respectively;
                   5648: if not specified, 40-bit RC2 is
                   5649: used.
                   5650: Only used with
                   5651: .Fl encrypt .
                   5652: .It Fl binary
                   5653: Normally, the input message is converted to
                   5654: .Qq canonical
                   5655: format which is effectively using CR and LF as end of line \-
                   5656: as required by the
                   5657: .Em S/MIME
                   5658: specification.
                   5659: When this option is present no translation occurs.
                   5660: This is useful when handling binary data which may not be in
                   5661: .Em MIME
                   5662: format.
                   5663: .It Fl CAfile Ar file
                   5664: A
                   5665: .Ar file
                   5666: containing trusted CA certificates; only used with
                   5667: .Fl verify .
                   5668: .It Fl CApath Ar directory
                   5669: A
                   5670: .Ar directory
                   5671: containing trusted CA certificates; only used with
                   5672: .Fl verify .
                   5673: This directory must be a standard certificate directory:
                   5674: that is, a hash of each subject name (using
                   5675: .Nm x509 -hash )
                   5676: should be linked to each certificate.
                   5677: .It Ar cert.pem ...
                   5678: One or more certificates of message recipients: used when encrypting
                   5679: a message.
                   5680: .It Fl certfile Ar file
                   5681: Allows additional certificates to be specified.
                   5682: When signing, these will be included with the message.
                   5683: When verifying, these will be searched for the signers' certificates.
                   5684: The certificates should be in PEM format.
                   5685: .It Xo
                   5686: .Fl check_ss_sig ,
                   5687: .Fl crl_check ,
                   5688: .Fl crl_check_all ,
                   5689: .Fl extended_crl ,
                   5690: .Fl ignore_critical ,
                   5691: .Fl issuer_checks ,
                   5692: .Fl policy_check ,
                   5693: .Fl x509_strict
                   5694: .Xc
                   5695: Set various certificate chain validation options.
                   5696: See the
                   5697: .Nm VERIFY
                   5698: command for details.
                   5699: .It Fl content Ar file
                   5700: This specifies a file containing the detached content.
                   5701: This is only useful with the
                   5702: .Fl verify
                   5703: command.
                   5704: This is only usable if the PKCS#7 structure is using the detached
                   5705: signature form where the content is not included.
                   5706: This option will override any content if the input format is
                   5707: .Em S/MIME
                   5708: and it uses the multipart/signed
                   5709: .Em MIME
                   5710: content type.
                   5711: .It Xo
                   5712: .Fl from Ar addr ,
                   5713: .Fl subject Ar s ,
                   5714: .Fl to Ar addr
                   5715: .Xc
                   5716: The relevant mail headers.
                   5717: These are included outside the signed
                   5718: portion of a message so they may be included manually.
                   5719: When signing, many
                   5720: .Em S/MIME
                   5721: mail clients check that the signer's certificate email
                   5722: address matches the From: address.
                   5723: .It Fl in Ar file
                   5724: The input message to be encrypted or signed or the
                   5725: .Em MIME
                   5726: message to
                   5727: be decrypted or verified.
                   5728: .It Fl indef
                   5729: Enable streaming I/O for encoding operations.
                   5730: This permits single pass processing of data without
                   5731: the need to hold the entire contents in memory,
                   5732: potentially supporting very large files.
                   5733: Streaming is automatically set for S/MIME signing with detached
                   5734: data if the output format is SMIME;
                   5735: it is currently off by default for all other operations.
                   5736: .It Fl inform Ar DER | PEM | SMIME
                   5737: This specifies the input format for the PKCS#7 structure.
                   5738: The default is
                   5739: .Em SMIME ,
                   5740: which reads an
                   5741: .Em S/MIME
                   5742: format message.
                   5743: .Ar PEM
                   5744: and
                   5745: .Ar DER
                   5746: format change this to expect PEM and DER format PKCS#7 structures
                   5747: instead.
                   5748: This currently only affects the input format of the PKCS#7
                   5749: structure; if no PKCS#7 structure is being input (for example with
                   5750: .Fl encrypt
                   5751: or
                   5752: .Fl sign ) ,
                   5753: this option has no effect.
                   5754: .It Fl inkey Ar file
                   5755: The private key to use when signing or decrypting.
                   5756: This must match the corresponding certificate.
                   5757: If this option is not specified, the private key must be included
                   5758: in the certificate file specified with
                   5759: the
                   5760: .Fl recip
                   5761: or
                   5762: .Fl signer
                   5763: file.
                   5764: When signing,
                   5765: this option can be used multiple times to specify successive keys.
1.22      bcook    5766: .It Fl keyform Ar PEM
1.1       jsing    5767: Input private key format.
                   5768: .It Fl md Ar digest
                   5769: The digest algorithm to use when signing or resigning.
                   5770: If not present then the default digest algorithm for the signing key is used
                   5771: (usually SHA1).
                   5772: .It Fl noattr
                   5773: Normally, when a message is signed a set of attributes are included which
                   5774: include the signing time and supported symmetric algorithms.
                   5775: With this option they are not included.
                   5776: .It Fl nocerts
                   5777: When signing a message, the signer's certificate is normally included;
                   5778: with this option it is excluded.
                   5779: This will reduce the size of the signed message but the verifier must
                   5780: have a copy of the signer's certificate available locally (passed using the
                   5781: .Fl certfile
                   5782: option, for example).
                   5783: .It Fl nochain
                   5784: Do not do chain verification of signers' certificates: that is,
                   5785: don't use the certificates in the signed message as untrusted CAs.
                   5786: .It Fl nodetach
                   5787: When signing a message use opaque signing: this form is more resistant
                   5788: to translation by mail relays but it cannot be read by mail agents that
                   5789: do not support
                   5790: .Em S/MIME .
                   5791: Without this option cleartext signing with the
                   5792: .Em MIME
                   5793: type multipart/signed is used.
                   5794: .It Fl noindef
                   5795: Disable streaming I/O where it would produce an encoding of indefinite length.
                   5796: This option currently has no effect.
                   5797: In future streaming will be enabled by default on all relevant operations
                   5798: and this option will disable it.
                   5799: .It Fl nointern
                   5800: When verifying a message, normally certificates
                   5801: .Pq if any
                   5802: included in the message are searched for the signing certificate.
                   5803: With this option, only the certificates specified in the
                   5804: .Fl certfile
                   5805: option are used.
                   5806: The supplied certificates can still be used as untrusted CAs however.
                   5807: .It Fl nosigs
                   5808: Don't try to verify the signatures on the message.
                   5809: .It Fl noverify
                   5810: Do not verify the signer's certificate of a signed message.
                   5811: .It Fl out Ar file
                   5812: The message text that has been decrypted or verified, or the output
                   5813: .Em MIME
                   5814: format message that has been signed or verified.
                   5815: .It Fl outform Ar DER | PEM | SMIME
                   5816: This specifies the output format for the PKCS#7 structure.
                   5817: The default is
                   5818: .Em SMIME ,
                   5819: which writes an
                   5820: .Em S/MIME
                   5821: format message.
                   5822: .Ar PEM
                   5823: and
                   5824: .Ar DER
                   5825: format change this to write PEM and DER format PKCS#7 structures
                   5826: instead.
                   5827: This currently only affects the output format of the PKCS#7
                   5828: structure; if no PKCS#7 structure is being output (for example with
                   5829: .Fl verify
                   5830: or
                   5831: .Fl decrypt )
                   5832: this option has no effect.
                   5833: .It Fl passin Ar arg
                   5834: The key password source.
                   5835: .It Fl recip Ar file
                   5836: The recipients certificate when decrypting a message.
                   5837: This certificate
                   5838: must match one of the recipients of the message or an error occurs.
                   5839: .It Fl signer Ar file
                   5840: A signing certificate when signing or resigning a message;
                   5841: this option can be used multiple times if more than one signer is required.
                   5842: If a message is being verified, the signer's certificates will be
                   5843: written to this file if the verification was successful.
                   5844: .It Fl stream
                   5845: The same as
                   5846: .Fl indef .
                   5847: .It Fl text
                   5848: This option adds plain text
                   5849: .Pq text/plain
                   5850: .Em MIME
                   5851: headers to the supplied message if encrypting or signing.
                   5852: If decrypting or verifying, it strips off text headers:
                   5853: if the decrypted or verified message is not of
                   5854: .Em MIME
                   5855: type text/plain then an error occurs.
                   5856: .El
                   5857: .Sh SMIME NOTES
                   5858: The
                   5859: .Em MIME
                   5860: message must be sent without any blank lines between the
                   5861: headers and the output.
                   5862: Some mail programs will automatically add a blank line.
1.3       jmc      5863: Piping the mail directly to an MTA is one way to
1.1       jsing    5864: achieve the correct format.
                   5865: .Pp
                   5866: The supplied message to be signed or encrypted must include the
                   5867: necessary
                   5868: .Em MIME
                   5869: headers or many
                   5870: .Em S/MIME
                   5871: clients won't display it properly
                   5872: .Pq if at all .
                   5873: You can use the
                   5874: .Fl text
                   5875: option to automatically add plain text headers.
                   5876: .Pp
                   5877: A
                   5878: .Qq signed and encrypted
                   5879: message is one where a signed message is then encrypted.
                   5880: This can be produced by encrypting an already signed message:
                   5881: see the
                   5882: .Sx SMIME EXAMPLES
                   5883: section.
                   5884: .Pp
                   5885: This version of the program only allows one signer per message, but it
                   5886: will verify multiple signers on received messages.
                   5887: Some
                   5888: .Em S/MIME
                   5889: clients choke if a message contains multiple signers.
                   5890: It is possible to sign messages
                   5891: .Qq in parallel
                   5892: by signing an already signed message.
                   5893: .Pp
                   5894: The options
                   5895: .Fl encrypt
                   5896: and
                   5897: .Fl decrypt
                   5898: reflect common usage in
                   5899: .Em S/MIME
                   5900: clients.
                   5901: Strictly speaking these process PKCS#7 enveloped data: PKCS#7
                   5902: encrypted data is used for other purposes.
                   5903: .Pp
                   5904: The
                   5905: .Fl resign
                   5906: option uses an existing message digest when adding a new signer.
                   5907: This means that attributes must be present in at least one existing
                   5908: signer using the same message digest or this operation will fail.
                   5909: .Pp
                   5910: The
                   5911: .Fl stream
                   5912: and
                   5913: .Fl indef
                   5914: options enable experimental streaming I/O support.
                   5915: As a result the encoding is BER using indefinite length constructed encoding
                   5916: and no longer DER.
                   5917: Streaming is supported for the
                   5918: .Fl encrypt
                   5919: and
                   5920: .Fl sign
                   5921: operations if the content is not detached.
                   5922: .Pp
                   5923: Streaming is always used for the
                   5924: .Fl sign
                   5925: operation with detached data
                   5926: but since the content is no longer part of the PKCS#7 structure
                   5927: the encoding remains DER.
                   5928: .Sh SMIME EXIT CODES
                   5929: .Bl -tag -width "XXXX"
                   5930: .It Ar 0
                   5931: The operation was completely successful.
                   5932: .It Ar 1
                   5933: An error occurred parsing the command options.
                   5934: .It Ar 2
                   5935: One of the input files could not be read.
                   5936: .It Ar 3
                   5937: An error occurred creating the PKCS#7 file or when reading the
                   5938: .Em MIME
                   5939: message.
                   5940: .It Ar 4
                   5941: An error occurred decrypting or verifying the message.
                   5942: .It Ar 5
                   5943: The message was verified correctly, but an error occurred writing out
                   5944: the signer's certificates.
                   5945: .El
                   5946: .Sh SMIME EXAMPLES
                   5947: Create a cleartext signed message:
                   5948: .Bd -literal -offset indent
                   5949: $ openssl smime -sign -in message.txt -text -out mail.msg \e
                   5950:        -signer mycert.pem
                   5951: .Ed
                   5952: .Pp
                   5953: Create an opaque signed message:
                   5954: .Bd -literal -offset indent
                   5955: $ openssl smime -sign -in message.txt -text -out mail.msg \e
                   5956:        -nodetach -signer mycert.pem
                   5957: .Ed
                   5958: .Pp
                   5959: Create a signed message, include some additional certificates and
                   5960: read the private key from another file:
                   5961: .Bd -literal -offset indent
                   5962: $ openssl smime -sign -in in.txt -text -out mail.msg \e
                   5963:        -signer mycert.pem -inkey mykey.pem -certfile mycerts.pem
                   5964: .Ed
                   5965: .Pp
                   5966: Create a signed message with two signers:
                   5967: .Bd -literal -offset indent
                   5968: openssl smime -sign -in message.txt -text -out mail.msg \e
                   5969:        -signer mycert.pem -signer othercert.pem
                   5970: .Ed
                   5971: .Pp
                   5972: Send a signed message under
                   5973: .Ux
                   5974: directly to
                   5975: .Xr sendmail 8 ,
                   5976: including headers:
                   5977: .Bd -literal -offset indent
                   5978: $ openssl smime -sign -in in.txt -text -signer mycert.pem \e
                   5979:        -from steve@openssl.org -to someone@somewhere \e
                   5980:        -subject "Signed message" | sendmail someone@somewhere
                   5981: .Ed
                   5982: .Pp
                   5983: Verify a message and extract the signer's certificate if successful:
                   5984: .Bd -literal -offset indent
                   5985: $ openssl smime -verify -in mail.msg -signer user.pem \e
                   5986:        -out signedtext.txt
                   5987: .Ed
                   5988: .Pp
                   5989: Send encrypted mail using triple DES:
                   5990: .Bd -literal -offset indent
                   5991: $ openssl smime -encrypt -in in.txt -from steve@openssl.org \e
                   5992:        -to someone@somewhere -subject "Encrypted message" \e
                   5993:        -des3 -out mail.msg user.pem
                   5994: .Ed
                   5995: .Pp
                   5996: Sign and encrypt mail:
                   5997: .Bd -literal -offset indent
                   5998: $ openssl smime -sign -in ml.txt -signer my.pem -text | \e
                   5999:        openssl smime -encrypt -out mail.msg \e
                   6000:        -from steve@openssl.org -to someone@somewhere \e
                   6001:        -subject "Signed and Encrypted message" -des3 user.pem
                   6002: .Ed
                   6003: .Pp
                   6004: .Sy Note :
                   6005: The encryption command does not include the
                   6006: .Fl text
                   6007: option because the message being encrypted already has
                   6008: .Em MIME
                   6009: headers.
                   6010: .Pp
                   6011: Decrypt mail:
                   6012: .Bd -literal -offset indent
                   6013: $ openssl smime -decrypt -in mail.msg -recip mycert.pem \e
                   6014:        -inkey key.pem"
                   6015: .Ed
                   6016: .Pp
                   6017: The output from Netscape form signing is a PKCS#7 structure with the
                   6018: detached signature format.
                   6019: You can use this program to verify the signature by line wrapping the
                   6020: base64-encoded structure and surrounding it with:
                   6021: .Bd -unfilled -offset indent
                   6022: -----BEGIN PKCS7-----
                   6023: -----END PKCS7-----
                   6024: .Ed
                   6025: .Pp
                   6026: and using the command:
                   6027: .Bd -literal -offset indent
                   6028: $ openssl smime -verify -inform PEM -in signature.pem \e
                   6029:        -content content.txt
                   6030: .Ed
                   6031: .Pp
                   6032: Alternatively, you can base64 decode the signature and use:
                   6033: .Bd -literal -offset indent
                   6034: $ openssl smime -verify -inform DER -in signature.der \e
                   6035:        -content content.txt
                   6036: .Ed
                   6037: .Pp
                   6038: Create an encrypted message using 128-bit AES:
                   6039: .Bd -literal -offset indent
                   6040: openssl smime -encrypt -in plain.txt -aes128 \e
                   6041:        -out mail.msg cert.pem
                   6042: .Ed
                   6043: .Pp
                   6044: Add a signer to an existing message:
                   6045: .Bd -literal -offset indent
                   6046: openssl smime -resign -in mail.msg -signer newsign.pem \e
                   6047:        -out mail2.msg
                   6048: .Ed
                   6049: .Sh SMIME BUGS
                   6050: The
                   6051: .Em MIME
                   6052: parser isn't very clever: it seems to handle most messages that I've thrown
                   6053: at it, but it may choke on others.
                   6054: .Pp
                   6055: The code currently will only write out the signer's certificate to a file:
                   6056: if the signer has a separate encryption certificate this must be manually
                   6057: extracted.
                   6058: There should be some heuristic that determines the correct encryption
                   6059: certificate.
                   6060: .Pp
                   6061: Ideally, a database should be maintained of a certificate for each email
                   6062: address.
                   6063: .Pp
                   6064: The code doesn't currently take note of the permitted symmetric encryption
                   6065: algorithms as supplied in the
                   6066: .Em SMIMECapabilities
                   6067: signed attribute.
                   6068: This means the user has to manually include the correct encryption algorithm.
                   6069: It should store the list of permitted ciphers in a database and only use those.
                   6070: .Pp
                   6071: No revocation checking is done on the signer's certificate.
                   6072: .Pp
                   6073: The current code can only handle
                   6074: .Em S/MIME
                   6075: v2 messages; the more complex
                   6076: .Em S/MIME
                   6077: v3 structures may cause parsing errors.
                   6078: .Sh SMIME HISTORY
                   6079: The use of multiple
                   6080: .Fl signer
                   6081: options and the
                   6082: .Fl resign
                   6083: command were first added in
                   6084: .Nm OpenSSL
                   6085: 1.0.0.
                   6086: .\"
                   6087: .\" SPEED
                   6088: .\"
                   6089: .Sh SPEED
                   6090: .nr nS 1
                   6091: .Nm "openssl speed"
                   6092: .Bk -words
                   6093: .Op Cm aes
                   6094: .Op Cm aes-128-cbc
                   6095: .Op Cm aes-192-cbc
                   6096: .Op Cm aes-256-cbc
1.25      bcook    6097: .Op Cm aes-128-gcm
                   6098: .Op Cm aes-256-gcm
1.1       jsing    6099: .Op Cm blowfish
                   6100: .Op Cm bf-cbc
                   6101: .Op Cm cast
                   6102: .Op Cm cast-cbc
1.25      bcook    6103: .Op Cm chacha20-poly1305
1.1       jsing    6104: .Op Cm des
                   6105: .Op Cm des-cbc
                   6106: .Op Cm des-ede3
                   6107: .Op Cm dsa
                   6108: .Op Cm dsa512
                   6109: .Op Cm dsa1024
                   6110: .Op Cm dsa2048
                   6111: .Op Cm hmac
1.28      doug     6112: .Op Cm md4
1.1       jsing    6113: .Op Cm md5
                   6114: .Op Cm rc2
                   6115: .Op Cm rc2-cbc
                   6116: .Op Cm rc4
                   6117: .Op Cm rmd160
                   6118: .Op Cm rsa
                   6119: .Op Cm rsa512
                   6120: .Op Cm rsa1024
                   6121: .Op Cm rsa2048
                   6122: .Op Cm rsa4096
                   6123: .Op Cm sha1
                   6124: .Op Fl decrypt
                   6125: .Op Fl elapsed
                   6126: .Op Fl evp Ar e
                   6127: .Op Fl mr
                   6128: .Op Fl multi Ar number
                   6129: .Ek
                   6130: .nr nS 0
                   6131: .Pp
                   6132: The
                   6133: .Nm speed
                   6134: command is used to test the performance of cryptographic algorithms.
                   6135: .Bl -tag -width "XXXX"
                   6136: .It Bq Cm zero or more test algorithms
                   6137: If any options are given,
                   6138: .Nm speed
                   6139: tests those algorithms, otherwise all of the above are tested.
                   6140: .It Fl decrypt
                   6141: Time decryption instead of encryption
                   6142: .Pq only EVP .
                   6143: .It Fl elapsed
                   6144: Measure time in real time instead of CPU user time.
                   6145: .It Fl evp Ar e
                   6146: Use EVP
                   6147: .Ar e .
                   6148: .It Fl mr
                   6149: Produce machine readable output.
                   6150: .It Fl multi Ar number
                   6151: Run
                   6152: .Ar number
                   6153: benchmarks in parallel.
                   6154: .El
                   6155: .\"
                   6156: .\" TS
                   6157: .\"
                   6158: .Sh TS
                   6159: .nr nS 1
                   6160: .Nm "openssl ts"
                   6161: .Bk -words
                   6162: .Fl query
1.29      bcook    6163: .Op Fl md4 | md5 | ripemd160 | sha1
1.1       jsing    6164: .Op Fl cert
                   6165: .Op Fl config Ar configfile
                   6166: .Op Fl data Ar file_to_hash
                   6167: .Op Fl digest Ar digest_bytes
                   6168: .Op Fl in Ar request.tsq
                   6169: .Op Fl no_nonce
                   6170: .Op Fl out Ar request.tsq
                   6171: .Op Fl policy Ar object_id
                   6172: .Op Fl text
                   6173: .Ek
                   6174: .nr nS 0
                   6175: .Pp
                   6176: .nr nS 1
                   6177: .Nm "openssl ts"
                   6178: .Bk -words
                   6179: .Fl reply
                   6180: .Op Fl chain Ar certs_file.pem
                   6181: .Op Fl config Ar configfile
                   6182: .Op Fl in Ar response.tsr
                   6183: .Op Fl inkey Ar private.pem
                   6184: .Op Fl out Ar response.tsr
                   6185: .Op Fl passin Ar arg
                   6186: .Op Fl policy Ar object_id
                   6187: .Op Fl queryfile Ar request.tsq
                   6188: .Op Fl section Ar tsa_section
                   6189: .Op Fl signer Ar tsa_cert.pem
                   6190: .Op Fl text
                   6191: .Op Fl token_in
                   6192: .Op Fl token_out
                   6193: .Ek
                   6194: .nr nS 0
                   6195: .Pp
                   6196: .nr nS 1
                   6197: .Nm "openssl ts"
                   6198: .Bk -words
                   6199: .Fl verify
                   6200: .Op Fl CAfile Ar trusted_certs.pem
                   6201: .Op Fl CApath Ar trusted_cert_path
                   6202: .Op Fl data Ar file_to_hash
                   6203: .Op Fl digest Ar digest_bytes
                   6204: .Op Fl in Ar response.tsr
                   6205: .Op Fl queryfile Ar request.tsq
                   6206: .Op Fl token_in
                   6207: .Op Fl untrusted Ar cert_file.pem
                   6208: .Ek
                   6209: .nr nS 0
                   6210: .Pp
                   6211: The
                   6212: .Nm ts
                   6213: command is a basic Time Stamping Authority (TSA) client and server
                   6214: application as specified in RFC 3161 (Time-Stamp Protocol, TSP).
                   6215: A TSA can be part of a PKI deployment and its role is to provide long
                   6216: term proof of the existence of a certain datum before a particular time.
                   6217: Here is a brief description of the protocol:
                   6218: .Bl -enum
                   6219: .It
                   6220: The TSA client computes a one-way hash value for a data file and sends
                   6221: the hash to the TSA.
                   6222: .It
                   6223: The TSA attaches the current date and time to the received hash value,
                   6224: signs them and sends the time stamp token back to the client.
                   6225: By creating this token the TSA certifies the existence of the original
                   6226: data file at the time of response generation.
                   6227: .It
                   6228: The TSA client receives the time stamp token and verifies the
                   6229: signature on it.
                   6230: It also checks if the token contains the same hash
                   6231: value that it had sent to the TSA.
                   6232: .El
                   6233: .Pp
                   6234: There is one DER-encoded protocol data unit defined for transporting a time
                   6235: stamp request to the TSA and one for sending the time stamp response
                   6236: back to the client.
                   6237: The
                   6238: .Nm ts
                   6239: command has three main functions:
                   6240: creating a time stamp request based on a data file;
                   6241: creating a time stamp response based on a request;
                   6242: and verifying if a response corresponds
                   6243: to a particular request or a data file.
                   6244: .Pp
                   6245: There is no support for sending the requests/responses automatically
                   6246: over HTTP or TCP yet as suggested in RFC 3161.
                   6247: Users must send the requests either by FTP or email.
                   6248: .Pp
                   6249: The
                   6250: .Fl query
                   6251: switch can be used for creating and printing a time stamp
                   6252: request with the following options:
                   6253: .Bl -tag -width Ds
                   6254: .It Fl cert
                   6255: The TSA is expected to include its signing certificate in the
                   6256: response.
                   6257: .It Fl config Ar configfile
                   6258: The configuration file to use.
                   6259: This option overrides the
                   6260: .Ev OPENSSL_CONF
                   6261: environment variable.
                   6262: Only the OID section of the config file is used with the
                   6263: .Fl query
                   6264: command.
                   6265: .It Fl data Ar file_to_hash
                   6266: The data file for which the time stamp request needs to be created.
                   6267: stdin is the default if neither the
                   6268: .Fl data
                   6269: nor the
                   6270: .Fl digest
                   6271: option is specified.
                   6272: .It Fl digest Ar digest_bytes
                   6273: It is possible to specify the message imprint explicitly without the data
                   6274: file.
                   6275: The imprint must be specified in a hexadecimal format,
                   6276: two characters per byte,
                   6277: the bytes optionally separated by colons (e.g. 1A:F6:01:... or 1AF601...).
                   6278: The number of bytes must match the message digest algorithm in use.
                   6279: .It Fl in Ar request.tsq
                   6280: This option specifies a previously created time stamp request in DER
                   6281: format that will be printed into the output file.
                   6282: Useful when you need to examine the content of a request in human-readable
                   6283: format.
1.28      doug     6284: .It Fl md4|md5|ripemd160|sha|sha1
1.1       jsing    6285: The message digest to apply to the data file.
                   6286: It supports all the message digest algorithms that are supported by the
                   6287: .Nm dgst
                   6288: command.
                   6289: The default is SHA-1.
                   6290: .It Fl no_nonce
                   6291: No nonce is specified in the request if this option is given.
                   6292: Otherwise a 64-bit long pseudo-random none is
                   6293: included in the request.
                   6294: It is recommended to use nonce to protect against replay-attacks.
                   6295: .It Fl out Ar request.tsq
                   6296: Name of the output file to which the request will be written.
                   6297: The default is stdout.
                   6298: .It Fl policy Ar object_id
                   6299: The policy that the client expects the TSA to use for creating the
                   6300: time stamp token.
                   6301: Either the dotted OID notation or OID names defined
                   6302: in the config file can be used.
                   6303: If no policy is requested the TSA will
                   6304: use its own default policy.
                   6305: .It Fl text
                   6306: If this option is specified the output is in human-readable text format
                   6307: instead of DER.
                   6308: .El
                   6309: .Pp
                   6310: A time stamp response (TimeStampResp) consists of a response status
                   6311: and the time stamp token itself (ContentInfo),
                   6312: if the token generation was successful.
                   6313: The
                   6314: .Fl reply
                   6315: command is for creating a time stamp
                   6316: response or time stamp token based on a request and printing the
                   6317: response/token in human-readable format.
                   6318: If
                   6319: .Fl token_out
                   6320: is not specified the output is always a time stamp response (TimeStampResp),
                   6321: otherwise it is a time stamp token (ContentInfo).
                   6322: .Bl -tag -width Ds
                   6323: .It Fl chain Ar certs_file.pem
                   6324: The collection of certificates, in PEM format,
                   6325: that will be included in the response
                   6326: in addition to the signer certificate if the
                   6327: .Fl cert
                   6328: option was used for the request.
                   6329: This file is supposed to contain the certificate chain
                   6330: for the signer certificate from its issuer upwards.
                   6331: The
                   6332: .Fl reply
                   6333: command does not build a certificate chain automatically.
                   6334: .It Fl config Ar configfile
                   6335: The configuration file to use.
                   6336: This option overrides the
                   6337: .Ev OPENSSL_CONF
                   6338: environment variable.
                   6339: See
                   6340: .Sx TS CONFIGURATION FILE OPTIONS
                   6341: for configurable variables.
                   6342: .It Fl in Ar response.tsr
                   6343: Specifies a previously created time stamp response or time stamp token, if
                   6344: .Fl token_in
                   6345: is also specified,
                   6346: in DER format that will be written to the output file.
                   6347: This option does not require a request;
                   6348: it is useful, for example,
                   6349: when you need to examine the content of a response or token
                   6350: or you want to extract the time stamp token from a response.
                   6351: If the input is a token and the output is a time stamp response a default
                   6352: .Dq granted
                   6353: status info is added to the token.
                   6354: .It Fl inkey Ar private.pem
                   6355: The signer private key of the TSA in PEM format.
                   6356: Overrides the
                   6357: .Cm signer_key
                   6358: config file option.
                   6359: .It Fl out Ar response.tsr
                   6360: The response is written to this file.
                   6361: The format and content of the file depends on other options (see
                   6362: .Fl text
                   6363: and
                   6364: .Fl token_out ) .
                   6365: The default is stdout.
                   6366: .It Fl passin Ar arg
                   6367: The key password source.
                   6368: .It Fl policy Ar object_id
                   6369: The default policy to use for the response unless the client
                   6370: explicitly requires a particular TSA policy.
                   6371: The OID can be specified either in dotted notation or with its name.
                   6372: Overrides the
                   6373: .Cm default_policy
                   6374: config file option.
                   6375: .It Fl queryfile Ar request.tsq
                   6376: The name of the file containing a DER-encoded time stamp request.
                   6377: .It Fl section Ar tsa_section
                   6378: The name of the config file section containing the settings for the
                   6379: response generation.
                   6380: If not specified the default TSA section is used; see
                   6381: .Sx TS CONFIGURATION FILE OPTIONS
                   6382: for details.
                   6383: .It Fl signer Ar tsa_cert.pem
                   6384: The signer certificate of the TSA in PEM format.
                   6385: The TSA signing certificate must have exactly one extended key usage
                   6386: assigned to it: timeStamping.
                   6387: The extended key usage must also be critical,
                   6388: otherwise the certificate is going to be refused.
                   6389: Overrides the
                   6390: .Cm signer_cert
                   6391: variable of the config file.
                   6392: .It Fl text
                   6393: If this option is specified the output is human-readable text format
                   6394: instead of DER.
                   6395: .It Fl token_in
                   6396: This flag can be used together with the
                   6397: .Fl in
                   6398: option and indicates that the input is a DER-encoded time stamp token
                   6399: (ContentInfo) instead of a time stamp response (TimeStampResp).
                   6400: .It Fl token_out
                   6401: The output is a time stamp token (ContentInfo) instead of time stamp
                   6402: response (TimeStampResp).
                   6403: .El
                   6404: .Pp
                   6405: The
                   6406: .Fl verify
                   6407: command is for verifying if a time stamp response or time stamp token
                   6408: is valid and matches a particular time stamp request or data file.
                   6409: The
                   6410: .Fl verify
                   6411: command does not use the configuration file.
                   6412: .Bl -tag -width Ds
                   6413: .It Fl CAfile Ar trusted_certs.pem
                   6414: The name of the file containing a set of trusted self-signed CA
                   6415: certificates in PEM format.
                   6416: See the similar option of
                   6417: .Nm verify
                   6418: for additional details.
                   6419: Either this option or
                   6420: .Fl CApath
                   6421: must be specified.
                   6422: .It Fl CApath Ar trusted_cert_path
                   6423: The name of the directory containing the trused CA certificates of the
                   6424: client.
                   6425: See the similar option of
                   6426: .Nm verify
                   6427: for additional details.
                   6428: Either this option or
                   6429: .Fl CAfile
                   6430: must be specified.
                   6431: .It Fl data Ar file_to_hash
                   6432: The response or token must be verified against
                   6433: .Ar file_to_hash .
                   6434: The file is hashed with the message digest algorithm specified in the token.
                   6435: The
                   6436: .Fl digest
                   6437: and
                   6438: .Fl queryfile
                   6439: options must not be specified with this one.
                   6440: .It Fl digest Ar digest_bytes
                   6441: The response or token must be verified against the message digest specified
                   6442: with this option.
                   6443: The number of bytes must match the message digest algorithm
                   6444: specified in the token.
                   6445: The
                   6446: .Fl data
                   6447: and
                   6448: .Fl queryfile
                   6449: options must not be specified with this one.
                   6450: .It Fl in Ar response.tsr
                   6451: The time stamp response that needs to be verified, in DER format.
                   6452: This option in mandatory.
                   6453: .It Fl queryfile Ar request.tsq
                   6454: The original time stamp request, in DER format.
                   6455: The
                   6456: .Fl data
                   6457: and
                   6458: .Fl digest
                   6459: options must not be specified with this one.
                   6460: .It Fl token_in
                   6461: This flag can be used together with the
                   6462: .Fl in
                   6463: option and indicates that the input is a DER-encoded time stamp token
                   6464: (ContentInfo) instead of a time stamp response (TimeStampResp).
                   6465: .It Fl untrusted Ar cert_file.pem
                   6466: Set of additional untrusted certificates in PEM format which may be
                   6467: needed when building the certificate chain for the TSA's signing
                   6468: certificate.
                   6469: This file must contain the TSA signing certificate and
                   6470: all intermediate CA certificates unless the response includes them.
                   6471: .El
                   6472: .Sh TS CONFIGURATION FILE OPTIONS
                   6473: The
                   6474: .Fl query
                   6475: and
                   6476: .Fl reply
                   6477: options make use of a configuration file defined by the
                   6478: .Ev OPENSSL_CONF
                   6479: environment variable.
                   6480: The
                   6481: .Fl query
                   6482: option uses only the symbolic OID names section
                   6483: and it can work without it.
                   6484: However, the
                   6485: .Fl reply
                   6486: option needs the config file for its operation.
                   6487: .Pp
                   6488: When there is a command line switch equivalent of a variable the
                   6489: switch always overrides the settings in the config file.
                   6490: .Bl -tag -width Ds
                   6491: .It Cm tsa Ar section , Cm default_tsa
                   6492: This is the main section and it specifies the name of another section
                   6493: that contains all the options for the
                   6494: .Fl reply
                   6495: option.
                   6496: This default section can be overridden with the
                   6497: .Fl section
                   6498: command line switch.
                   6499: .It Cm oid_file
                   6500: See
                   6501: .Nm ca
                   6502: for a description.
                   6503: .It Cm oid_section
                   6504: See
                   6505: .Nm ca
                   6506: for a description.
                   6507: .It Cm serial
                   6508: The name of the file containing the hexadecimal serial number of the
                   6509: last time stamp response created.
                   6510: This number is incremented by 1 for each response.
                   6511: If the file does not exist at the time of response
                   6512: generation a new file is created with serial number 1.
                   6513: This parameter is mandatory.
                   6514: .It Cm signer_cert
                   6515: TSA signing certificate, in PEM format.
                   6516: The same as the
                   6517: .Fl signer
                   6518: command line option.
                   6519: .It Cm certs
                   6520: A file containing a set of PEM-encoded certificates that need to be
                   6521: included in the response.
                   6522: The same as the
                   6523: .Fl chain
                   6524: command line option.
                   6525: .It Cm signer_key
                   6526: The private key of the TSA, in PEM format.
                   6527: The same as the
                   6528: .Fl inkey
                   6529: command line option.
                   6530: .It Cm default_policy
                   6531: The default policy to use when the request does not mandate any policy.
                   6532: The same as the
                   6533: .Fl policy
                   6534: command line option.
                   6535: .It Cm other_policies
                   6536: Comma separated list of policies that are also acceptable by the TSA
                   6537: and used only if the request explicitly specifies one of them.
                   6538: .It Cm digests
                   6539: The list of message digest algorithms that the TSA accepts.
                   6540: At least one algorithm must be specified.
                   6541: This parameter is mandatory.
                   6542: .It Cm accuracy
                   6543: The accuracy of the time source of the TSA in seconds, milliseconds
                   6544: and microseconds.
                   6545: For example, secs:1, millisecs:500, microsecs:100.
                   6546: If any of the components is missing,
                   6547: zero is assumed for that field.
                   6548: .It Cm clock_precision_digits
                   6549: Specifies the maximum number of digits, which represent the fraction of
                   6550: seconds, that need to be included in the time field.
                   6551: The trailing zeroes must be removed from the time,
                   6552: so there might actually be fewer digits,
                   6553: or no fraction of seconds at all.
                   6554: The maximum value is 6;
                   6555: the default is 0.
                   6556: .It Cm ordering
                   6557: If this option is yes,
                   6558: the responses generated by this TSA can always be ordered,
                   6559: even if the time difference between two responses is less
                   6560: than the sum of their accuracies.
                   6561: The default is no.
                   6562: .It Cm tsa_name
                   6563: Set this option to yes if the subject name of the TSA must be included in
                   6564: the TSA name field of the response.
                   6565: The default is no.
                   6566: .It Cm ess_cert_id_chain
                   6567: The SignedData objects created by the TSA always contain the
                   6568: certificate identifier of the signing certificate in a signed
                   6569: attribute (see RFC 2634, Enhanced Security Services).
                   6570: If this option is set to yes and either the
                   6571: .Cm certs
                   6572: variable or the
                   6573: .Fl chain
                   6574: option is specified then the certificate identifiers of the chain will also
                   6575: be included in the SigningCertificate signed attribute.
                   6576: If this variable is set to no,
                   6577: only the signing certificate identifier is included.
                   6578: The default is no.
                   6579: .El
                   6580: .Sh TS ENVIRONMENT VARIABLES
                   6581: .Ev OPENSSL_CONF
                   6582: contains the path of the configuration file and can be
                   6583: overridden by the
                   6584: .Fl config
                   6585: command line option.
                   6586: .Sh TS EXAMPLES
                   6587: All the examples below presume that
                   6588: .Ev OPENSSL_CONF
                   6589: is set to a proper configuration file,
                   6590: e.g. the example configuration file
                   6591: .Pa openssl/apps/openssl.cnf
                   6592: will do.
                   6593: .Pp
                   6594: To create a time stamp request for design1.txt with SHA-1
                   6595: without nonce and policy and no certificate is required in the response:
                   6596: .Bd -literal -offset indent
                   6597: $ openssl ts -query -data design1.txt -no_nonce \e
                   6598:        -out design1.tsq
                   6599: .Ed
                   6600: .Pp
                   6601: To create a similar time stamp request but specifying the message imprint
                   6602: explicitly:
                   6603: .Bd -literal -offset indent
                   6604: $ openssl ts -query \e
                   6605:        -digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \e
                   6606:        -no_nonce -out design1.tsq
                   6607: .Ed
                   6608: .Pp
                   6609: To print the content of the previous request in human readable format:
                   6610: .Bd -literal -offset indent
                   6611: $ openssl ts -query -in design1.tsq -text
                   6612: .Ed
                   6613: .Pp
                   6614: To create a time stamp request which includes the MD5 digest
                   6615: of design2.txt, requests the signer certificate and nonce,
                   6616: specifies a policy ID
                   6617: (assuming the tsa_policy1 name is defined in the
                   6618: OID section of the config file):
                   6619: .Bd -literal -offset indent
                   6620: $ openssl ts -query -data design2.txt -md5 \e
                   6621:        -policy tsa_policy1 -cert -out design2.tsq
                   6622: .Ed
                   6623: .Pp
                   6624: Before generating a response,
                   6625: a signing certificate must be created for the TSA that contains the
                   6626: .Cm timeStamping
                   6627: critical extended key usage extension
                   6628: without any other key usage extensions.
                   6629: You can add the
                   6630: .Dq extendedKeyUsage = critical,timeStamping
                   6631: line to the user certificate section
                   6632: of the config file to generate a proper certificate.
                   6633: See the
                   6634: .Nm req ,
                   6635: .Nm ca ,
                   6636: and
                   6637: .Nm x509
                   6638: commands for instructions.
                   6639: The examples below assume that cacert.pem contains the certificate of the CA,
                   6640: tsacert.pem is the signing certificate issued by cacert.pem and
                   6641: tsakey.pem is the private key of the TSA.
                   6642: .Pp
                   6643: To create a time stamp response for a request:
                   6644: .Bd -literal -offset indent
                   6645: $ openssl ts -reply -queryfile design1.tsq -inkey tsakey.pem \e
                   6646:        -signer tsacert.pem -out design1.tsr
                   6647: .Ed
                   6648: .Pp
                   6649: If you want to use the settings in the config file you could just write:
                   6650: .Bd -literal -offset indent
                   6651: $ openssl ts -reply -queryfile design1.tsq -out design1.tsr
                   6652: .Ed
                   6653: .Pp
                   6654: To print a time stamp reply to stdout in human readable format:
                   6655: .Bd -literal -offset indent
                   6656: $ openssl ts -reply -in design1.tsr -text
                   6657: .Ed
                   6658: .Pp
                   6659: To create a time stamp token instead of time stamp response:
                   6660: .Bd -literal -offset indent
                   6661: $ openssl ts -reply -queryfile design1.tsq \e
                   6662:        -out design1_token.der -token_out
                   6663: .Ed
                   6664: .Pp
                   6665: To print a time stamp token to stdout in human readable format:
                   6666: .Bd -literal -offset indent
                   6667: $ openssl ts -reply -in design1_token.der -token_in \e
                   6668:        -text -token_out
                   6669: .Ed
                   6670: .Pp
                   6671: To extract the time stamp token from a response:
                   6672: .Bd -literal -offset indent
                   6673: $ openssl ts -reply -in design1.tsr -out design1_token.der \e
                   6674:        -token_out
                   6675: .Ed
                   6676: .Pp
                   6677: To add
                   6678: .Dq granted
                   6679: status info to a time stamp token thereby creating a valid response:
                   6680: .Bd -literal -offset indent
                   6681: $ openssl ts -reply -in design1_token.der \e
                   6682:        -token_in -out design1.tsr
                   6683: .Ed
                   6684: .Pp
                   6685: To verify a time stamp reply against a request:
                   6686: .Bd -literal -offset indent
                   6687: $ openssl ts -verify -queryfile design1.tsq -in design1.tsr \e
                   6688:        -CAfile cacert.pem -untrusted tsacert.pem
                   6689: .Ed
                   6690: .Pp
                   6691: To verify a time stamp reply that includes the certificate chain:
                   6692: .Bd -literal -offset indent
                   6693: $ openssl ts -verify -queryfile design2.tsq -in design2.tsr \e
                   6694:        -CAfile cacert.pem
                   6695: .Ed
                   6696: .Pp
                   6697: To verify a time stamp token against the original data file:
                   6698: .Bd -literal -offset indent
                   6699: $ openssl ts -verify -data design2.txt -in design2.tsr \e
                   6700:        -CAfile cacert.pem
                   6701: .Ed
                   6702: .Pp
                   6703: To verify a time stamp token against a message imprint:
                   6704: .Bd -literal -offset indent
                   6705: $ openssl ts -verify \e
                   6706:        -digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \e
                   6707:        -in design2.tsr -CAfile cacert.pem
                   6708: .Ed
                   6709: .Sh TS BUGS
                   6710: No support for time stamps over SMTP, though it is quite easy
                   6711: to implement an automatic email-based TSA with
                   6712: .Xr procmail
                   6713: and
                   6714: .Xr perl 1 .
                   6715: Pure TCP/IP is not supported.
                   6716: .Pp
                   6717: The file containing the last serial number of the TSA is not
                   6718: locked when being read or written.
                   6719: This is a problem if more than one instance of
                   6720: .Nm OpenSSL
                   6721: is trying to create a time stamp
                   6722: response at the same time.
                   6723: .Pp
                   6724: Look for the FIXME word in the source files.
                   6725: .Pp
                   6726: The source code should really be reviewed by somebody else, too.
                   6727: .Pp
                   6728: More testing is needed.
                   6729: .Sh TS AUTHORS
                   6730: .An Zoltan Glozik Aq Mt zglozik@opentsa.org ,
                   6731: OpenTSA project
                   6732: .Pq Lk http://www.opentsa.org .
                   6733: .\"
                   6734: .\" SPKAC
                   6735: .\"
                   6736: .Sh SPKAC
                   6737: .nr nS 1
                   6738: .Nm "openssl spkac"
                   6739: .Bk -words
                   6740: .Op Fl challenge Ar string
                   6741: .Op Fl in Ar file
                   6742: .Op Fl key Ar keyfile
                   6743: .Op Fl noout
                   6744: .Op Fl out Ar file
                   6745: .Op Fl passin Ar arg
                   6746: .Op Fl pubkey
                   6747: .Op Fl spkac Ar spkacname
                   6748: .Op Fl spksect Ar section
                   6749: .Op Fl verify
                   6750: .Ek
                   6751: .nr nS 0
                   6752: .Pp
                   6753: The
                   6754: .Nm spkac
                   6755: command processes Netscape signed public key and challenge
                   6756: .Pq SPKAC
                   6757: files.
                   6758: It can print out their contents, verify the signature,
                   6759: and produce its own SPKACs from a supplied private key.
                   6760: .Pp
                   6761: The options are as follows:
                   6762: .Bl -tag -width Ds
                   6763: .It Fl challenge Ar string
                   6764: Specifies the challenge string if an SPKAC is being created.
                   6765: .It Fl in Ar file
                   6766: This specifies the input
                   6767: .Ar file
                   6768: to read from, or standard input if this option is not specified.
                   6769: Ignored if the
                   6770: .Fl key
                   6771: option is used.
                   6772: .It Fl key Ar keyfile
                   6773: Create an SPKAC file using the private key in
                   6774: .Ar keyfile .
                   6775: The
                   6776: .Fl in , noout , spksect ,
                   6777: and
                   6778: .Fl verify
                   6779: options are ignored if present.
                   6780: .It Fl noout
                   6781: Don't output the text version of the SPKAC
                   6782: .Pq not used if an SPKAC is being created .
                   6783: .It Fl out Ar file
                   6784: Specifies the output
                   6785: .Ar file
                   6786: to write to, or standard output by default.
                   6787: .It Fl passin Ar arg
                   6788: The key password source.
                   6789: .It Fl pubkey
                   6790: Output the public key of an SPKAC
                   6791: .Pq not used if an SPKAC is being created .
                   6792: .It Fl spkac Ar spkacname
                   6793: Allows an alternative name for the variable containing the SPKAC.
                   6794: The default is "SPKAC".
                   6795: This option affects both generated and input SPKAC files.
                   6796: .It Fl spksect Ar section
                   6797: Allows an alternative name for the
                   6798: .Ar section
                   6799: containing the SPKAC.
                   6800: The default is the default section.
                   6801: .It Fl verify
                   6802: Verifies the digital signature on the supplied SPKAC.
                   6803: .El
                   6804: .Sh SPKAC EXAMPLES
                   6805: Print out the contents of an SPKAC:
                   6806: .Pp
                   6807: .Dl $ openssl spkac -in spkac.cnf
                   6808: .Pp
                   6809: Verify the signature of an SPKAC:
                   6810: .Pp
                   6811: .Dl $ openssl spkac -in spkac.cnf -noout -verify
                   6812: .Pp
                   6813: Create an SPKAC using the challenge string
                   6814: .Qq hello :
                   6815: .Pp
                   6816: .Dl $ openssl spkac -key key.pem -challenge hello -out spkac.cnf
                   6817: .Pp
                   6818: Example of an SPKAC,
                   6819: .Pq long lines split up for clarity :
                   6820: .Bd -unfilled -offset indent
                   6821: SPKAC=MIG5MGUwXDANBgkqhkiG9w0BAQEFAANLADBIAkEA1cCoq2Wa3Ixs47uI7F\e
                   6822: PVwHVIPDx5yso105Y6zpozam135a8R0CpoRvkkigIyXfcCjiVi5oWk+6FfPaD03u\e
                   6823: PFoQIDAQABFgVoZWxsbzANBgkqhkiG9w0BAQQFAANBAFpQtY/FojdwkJh1bEIYuc\e
                   6824: 2EeM2KHTWPEepWYeawvHD0gQ3DngSC75YCWnnDdq+NQ3F+X4deMx9AaEglZtULwV\e
                   6825: 4=
                   6826: .Ed
                   6827: .Sh SPKAC NOTES
                   6828: A created SPKAC with suitable DN components appended can be fed into
                   6829: the
                   6830: .Nm ca
                   6831: utility.
                   6832: .Pp
                   6833: SPKACs are typically generated by Netscape when a form is submitted
                   6834: containing the
                   6835: .Em KEYGEN
                   6836: tag as part of the certificate enrollment process.
                   6837: .Pp
                   6838: The challenge string permits a primitive form of proof of possession
                   6839: of private key.
                   6840: By checking the SPKAC signature and a random challenge
                   6841: string, some guarantee is given that the user knows the private key
                   6842: corresponding to the public key being certified.
                   6843: This is important in some applications.
                   6844: Without this it is possible for a previous SPKAC
                   6845: to be used in a
                   6846: .Qq replay attack .
                   6847: .\"
                   6848: .\" VERIFY
                   6849: .\"
                   6850: .Sh VERIFY
                   6851: .nr nS 1
                   6852: .Nm "openssl verify"
                   6853: .Bk -words
                   6854: .Op Fl CAfile Ar file
                   6855: .Op Fl CApath Ar directory
                   6856: .Op Fl check_ss_sig
                   6857: .Op Fl crl_check
                   6858: .Op Fl crl_check_all
                   6859: .Op Fl explicit_policy
                   6860: .Op Fl extended_crl
                   6861: .Op Fl help
                   6862: .Op Fl ignore_critical
                   6863: .Op Fl inhibit_any
                   6864: .Op Fl inhibit_map
                   6865: .Op Fl issuer_checks
                   6866: .Op Fl policy_check
                   6867: .Op Fl purpose Ar purpose
                   6868: .Op Fl untrusted Ar file
                   6869: .Op Fl verbose
                   6870: .Op Fl x509_strict
                   6871: .Op Fl
                   6872: .Op Ar certificates
                   6873: .Ek
                   6874: .nr nS 0
                   6875: .Pp
                   6876: The
                   6877: .Nm verify
                   6878: command verifies certificate chains.
                   6879: .Pp
                   6880: The options are as follows:
                   6881: .Bl -tag -width Ds
                   6882: .It Fl check_ss_sig
                   6883: Verify the signature on the self-signed root CA.
                   6884: This is disabled by default
                   6885: because it doesn't add any security.
                   6886: .It Fl CAfile Ar file
                   6887: A
                   6888: .Ar file
                   6889: of trusted certificates.
                   6890: The
                   6891: .Ar file
                   6892: should contain multiple certificates in PEM format, concatenated together.
                   6893: .It Fl CApath Ar directory
                   6894: A
                   6895: .Ar directory
                   6896: of trusted certificates.
                   6897: The certificates should have names of the form
                   6898: .Em hash.0 ,
                   6899: or have symbolic links to them of this form
                   6900: ("hash" is the hashed certificate subject name: see the
                   6901: .Fl hash
                   6902: option of the
                   6903: .Nm x509
                   6904: utility).
                   6905: The
                   6906: .Nm c_rehash
                   6907: script distributed with OpenSSL
                   6908: will automatically create symbolic links to a directory of certificates.
                   6909: .It Fl crl_check
                   6910: Checks end entity certificate validity by attempting to look up a valid CRL.
                   6911: If a valid CRL cannot be found an error occurs.
                   6912: .It Fl crl_check_all
                   6913: Checks the validity of all certificates in the chain by attempting
                   6914: to look up valid CRLs.
                   6915: .It Fl explicit_policy
                   6916: Set policy variable require-explicit-policy (see RFC 3280 et al).
                   6917: .It Fl extended_crl
                   6918: Enable extended CRL features such as indirect CRLs and alternate CRL
                   6919: signing keys.
                   6920: .It Fl help
                   6921: Prints out a usage message.
                   6922: .It Fl ignore_critical
                   6923: Normally if an unhandled critical extension is present which is not
                   6924: supported by
                   6925: .Nm OpenSSL ,
                   6926: the certificate is rejected (as required by RFC 3280 et al).
                   6927: If this option is set, critical extensions are ignored.
                   6928: .It Fl inhibit_any
                   6929: Set policy variable inhibit-any-policy (see RFC 3280 et al).
                   6930: .It Fl inhibit_map
                   6931: Set policy variable inhibit-policy-mapping (see RFC 3280 et al).
                   6932: .It Fl issuer_checks
                   6933: Print out diagnostics relating to searches for the issuer certificate
                   6934: of the current certificate.
                   6935: This shows why each candidate issuer certificate was rejected.
                   6936: However the presence of rejection messages
                   6937: does not itself imply that anything is wrong: during the normal
                   6938: verify process several rejections may take place.
                   6939: .It Fl policy_check
                   6940: Enables certificate policy processing.
                   6941: .It Fl purpose Ar purpose
                   6942: The intended use for the certificate.
                   6943: Without this option no chain verification will be done.
                   6944: Currently accepted uses are
                   6945: .Ar sslclient , sslserver ,
                   6946: .Ar nssslserver , smimesign ,
                   6947: .Ar smimeencrypt , crlsign ,
                   6948: .Ar any ,
                   6949: and
                   6950: .Ar ocsphelper .
                   6951: See the
                   6952: .Sx VERIFY OPERATION
                   6953: section for more information.
                   6954: .It Fl untrusted Ar file
                   6955: A
                   6956: .Ar file
                   6957: of untrusted certificates.
                   6958: The
                   6959: .Ar file
                   6960: should contain multiple certificates.
                   6961: .It Fl verbose
                   6962: Print extra information about the operations being performed.
                   6963: .It Fl x509_strict
                   6964: Disable workarounds for broken certificates which have to be disabled
                   6965: for strict X.509 compliance.
                   6966: .It Fl
                   6967: Marks the last option.
                   6968: All arguments following this are assumed to be certificate files.
                   6969: This is useful if the first certificate filename begins with a
                   6970: .Sq - .
                   6971: .It Ar certificates
                   6972: One or more
                   6973: .Ar certificates
                   6974: to verify.
                   6975: If no certificate files are included, an attempt is made to read
                   6976: a certificate from standard input.
                   6977: They should all be in PEM format.
                   6978: .El
                   6979: .Sh VERIFY OPERATION
                   6980: The
                   6981: .Nm verify
                   6982: program uses the same functions as the internal SSL and S/MIME verification,
                   6983: therefore this description applies to these verify operations too.
                   6984: .Pp
                   6985: There is one crucial difference between the verify operations performed
                   6986: by the
                   6987: .Nm verify
                   6988: program: wherever possible an attempt is made to continue
                   6989: after an error, whereas normally the verify operation would halt on the
                   6990: first error.
                   6991: This allows all the problems with a certificate chain to be determined.
                   6992: .Pp
                   6993: The verify operation consists of a number of separate steps:
                   6994: .Pp
                   6995: Firstly a certificate chain is built up starting from the supplied certificate
                   6996: and ending in the root CA.
                   6997: It is an error if the whole chain cannot be built up.
                   6998: The chain is built up by looking up the issuer's certificate of the current
                   6999: certificate.
                   7000: If a certificate is found which is its own issuer, it is assumed
                   7001: to be the root CA.
                   7002: .Pp
                   7003: The process of
                   7004: .Qq looking up the issuer's certificate
                   7005: itself involves a number of steps.
                   7006: In versions of
                   7007: .Nm OpenSSL
                   7008: before 0.9.5a the first certificate whose subject name matched the issuer
                   7009: of the current certificate was assumed to be the issuer's certificate.
                   7010: In
                   7011: .Nm OpenSSL
                   7012: 0.9.6 and later all certificates whose subject name matches the issuer name
                   7013: of the current certificate are subject to further tests.
                   7014: The relevant authority key identifier components of the current certificate
                   7015: .Pq if present
                   7016: must match the subject key identifier
                   7017: .Pq if present
                   7018: and issuer and serial number of the candidate issuer; in addition the
                   7019: .Em keyUsage
                   7020: extension of the candidate issuer
                   7021: .Pq if present
                   7022: must permit certificate signing.
                   7023: .Pp
                   7024: The lookup first looks in the list of untrusted certificates and if no match
                   7025: is found the remaining lookups are from the trusted certificates.
                   7026: The root CA is always looked up in the trusted certificate list: if the
                   7027: certificate to verify is a root certificate, then an exact match must be
                   7028: found in the trusted list.
                   7029: .Pp
                   7030: The second operation is to check every untrusted certificate's extensions for
                   7031: consistency with the supplied purpose.
                   7032: If the
                   7033: .Fl purpose
                   7034: option is not included, then no checks are done.
                   7035: The supplied or
                   7036: .Qq leaf
                   7037: certificate must have extensions compatible with the supplied purpose
                   7038: and all other certificates must also be valid CA certificates.
                   7039: The precise extensions required are described in more detail in
                   7040: the
                   7041: .Sx X.509 CERTIFICATE EXTENSIONS
                   7042: section below.
                   7043: .Pp
                   7044: The third operation is to check the trust settings on the root CA.
                   7045: The root CA should be trusted for the supplied purpose.
                   7046: For compatibility with previous versions of
                   7047: .Nm SSLeay
                   7048: and
                   7049: .Nm OpenSSL ,
                   7050: a certificate with no trust settings is considered to be valid for
                   7051: all purposes.
                   7052: .Pp
                   7053: The final operation is to check the validity of the certificate chain.
                   7054: The validity period is checked against the current system time and the
                   7055: .Em notBefore
                   7056: and
                   7057: .Em notAfter
                   7058: dates in the certificate.
                   7059: The certificate signatures are also checked at this point.
                   7060: .Pp
                   7061: If all operations complete successfully, the certificate is considered
                   7062: valid.
                   7063: If any operation fails then the certificate is not valid.
                   7064: .Sh VERIFY DIAGNOSTICS
                   7065: When a verify operation fails, the output messages can be somewhat cryptic.
                   7066: The general form of the error message is:
                   7067: .Bd -unfilled
                   7068: \& server.pem: /C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test CA (1024-bit)
                   7069: \& error 24 at 1 depth lookup:invalid CA certificate
                   7070: .Ed
                   7071: .Pp
                   7072: The first line contains the name of the certificate being verified, followed by
                   7073: the subject name of the certificate.
                   7074: The second line contains the error number and the depth.
                   7075: The depth is the number of the certificate being verified when a
                   7076: problem was detected starting with zero for the certificate being verified
                   7077: itself, then 1 for the CA that signed the certificate and so on.
                   7078: Finally a text version of the error number is presented.
                   7079: .Pp
                   7080: An exhaustive list of the error codes and messages is shown below; this also
                   7081: includes the name of the error code as defined in the header file
1.12      bentley  7082: .In openssl/x509_vfy.h .
1.1       jsing    7083: Some of the error codes are defined but never returned: these are described
                   7084: as
                   7085: .Qq unused .
                   7086: .Bl -tag -width "XXXX"
                   7087: .It Ar "0 X509_V_OK: ok"
                   7088: The operation was successful.
                   7089: .It Ar 2 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: unable to get issuer certificate
                   7090: The issuer certificate could not be found: this occurs if the issuer certificate
                   7091: of an untrusted certificate cannot be found.
                   7092: .It Ar 3 X509_V_ERR_UNABLE_TO_GET_CRL: unable to get certificate CRL
                   7093: The CRL of a certificate could not be found.
                   7094: .It Ar 4 X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE: unable to decrypt certificate's signature
                   7095: The certificate signature could not be decrypted.
                   7096: This means that the actual signature value could not be determined rather
                   7097: than it not matching the expected value.
                   7098: This is only meaningful for RSA keys.
                   7099: .It Ar 5 X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE: unable to decrypt CRL's signature
                   7100: The CRL signature could not be decrypted: this means that the actual
                   7101: signature value could not be determined rather than it not matching the
                   7102: expected value.
                   7103: Unused.
                   7104: .It Ar 6 X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY: unable to decode issuer public key
                   7105: The public key in the certificate
                   7106: .Em SubjectPublicKeyInfo
                   7107: could not be read.
                   7108: .It Ar 7 X509_V_ERR_CERT_SIGNATURE_FAILURE: certificate signature failure
                   7109: The signature of the certificate is invalid.
                   7110: .It Ar 8 X509_V_ERR_CRL_SIGNATURE_FAILURE: CRL signature failure
                   7111: The signature of the certificate is invalid.
                   7112: .It Ar 9 X509_V_ERR_CERT_NOT_YET_VALID: certificate is not yet valid
                   7113: The certificate is not yet valid: the
                   7114: .Em notBefore
                   7115: date is after the current time.
                   7116: .It Ar 10 X509_V_ERR_CERT_HAS_EXPIRED: certificate has expired
                   7117: The certificate has expired; that is, the
                   7118: .Em notAfter
                   7119: date is before the current time.
                   7120: .It Ar 11 X509_V_ERR_CRL_NOT_YET_VALID: CRL is not yet valid
                   7121: The CRL is not yet valid.
                   7122: .It Ar 12 X509_V_ERR_CRL_HAS_EXPIRED: CRL has expired
                   7123: The CRL has expired.
                   7124: .It Ar 13 X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: format error in certificate's notBefore field
                   7125: The certificate
                   7126: .Em notBefore
                   7127: field contains an invalid time.
                   7128: .It Ar 14 X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD: format error in certificate's notAfter field
                   7129: The certificate
                   7130: .Em notAfter
                   7131: field contains an invalid time.
                   7132: .It Ar 15 X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD: format error in CRL's lastUpdate field
                   7133: The CRL
                   7134: .Em lastUpdate
                   7135: field contains an invalid time.
                   7136: .It Ar 16 X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD: format error in CRL's nextUpdate field
                   7137: The CRL
                   7138: .Em nextUpdate
                   7139: field contains an invalid time.
                   7140: .It Ar 17 X509_V_ERR_OUT_OF_MEM: out of memory
                   7141: An error occurred trying to allocate memory.
                   7142: This should never happen.
                   7143: .It Ar 18 X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: self signed certificate
                   7144: The passed certificate is self-signed and the same certificate cannot be
                   7145: found in the list of trusted certificates.
                   7146: .It Ar 19 X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: self signed certificate in certificate chain
                   7147: The certificate chain could be built up using the untrusted certificates but
                   7148: the root could not be found locally.
                   7149: .It Ar 20 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: unable to get local issuer certificate
                   7150: The issuer certificate of a locally looked up certificate could not be found.
                   7151: This normally means the list of trusted certificates is not complete.
                   7152: .It Ar 21 X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: unable to verify the first certificate
                   7153: No signatures could be verified because the chain contains only one
                   7154: certificate and it is not self-signed.
                   7155: .It Ar 22 X509_V_ERR_CERT_CHAIN_TOO_LONG: certificate chain too long
                   7156: The certificate chain length is greater than the supplied maximum depth.
                   7157: Unused.
                   7158: .It Ar 23 X509_V_ERR_CERT_REVOKED: certificate revoked
                   7159: The certificate has been revoked.
                   7160: .It Ar 24 X509_V_ERR_INVALID_CA: invalid CA certificate
                   7161: A CA certificate is invalid.
                   7162: Either it is not a CA or its extensions are not consistent
                   7163: with the supplied purpose.
                   7164: .It Ar 25 X509_V_ERR_PATH_LENGTH_EXCEEDED: path length constraint exceeded
                   7165: The
                   7166: .Em basicConstraints
                   7167: pathlength parameter has been exceeded.
                   7168: .It Ar 26 X509_V_ERR_INVALID_PURPOSE: unsupported certificate purpose
                   7169: The supplied certificate cannot be used for the specified purpose.
                   7170: .It Ar 27 X509_V_ERR_CERT_UNTRUSTED: certificate not trusted
                   7171: The root CA is not marked as trusted for the specified purpose.
                   7172: .It Ar 28 X509_V_ERR_CERT_REJECTED: certificate rejected
                   7173: The root CA is marked to reject the specified purpose.
                   7174: .It Ar 29 X509_V_ERR_SUBJECT_ISSUER_MISMATCH: subject issuer mismatch
                   7175: The current candidate issuer certificate was rejected because its subject name
                   7176: did not match the issuer name of the current certificate.
                   7177: Only displayed when the
                   7178: .Fl issuer_checks
                   7179: option is set.
                   7180: .It Ar 30 X509_V_ERR_AKID_SKID_MISMATCH: authority and subject key identifier mismatch
                   7181: The current candidate issuer certificate was rejected because its subject key
                   7182: identifier was present and did not match the authority key identifier current
                   7183: certificate.
                   7184: Only displayed when the
                   7185: .Fl issuer_checks
                   7186: option is set.
                   7187: .It Ar 31 X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH: authority and issuer serial number mismatch
                   7188: The current candidate issuer certificate was rejected because its issuer name
                   7189: and serial number were present and did not match the authority key identifier
                   7190: of the current certificate.
                   7191: Only displayed when the
                   7192: .Fl issuer_checks
                   7193: option is set.
                   7194: .It Ar 32 X509_V_ERR_KEYUSAGE_NO_CERTSIGN:key usage does not include certificate signing
                   7195: The current candidate issuer certificate was rejected because its
                   7196: .Em keyUsage
                   7197: extension does not permit certificate signing.
                   7198: .It Ar 50 X509_V_ERR_APPLICATION_VERIFICATION: application verification failure
                   7199: An application specific error.
                   7200: Unused.
                   7201: .El
                   7202: .Sh VERIFY BUGS
                   7203: Although the issuer checks are a considerable improvement over the old
                   7204: technique, they still suffer from limitations in the underlying
                   7205: X509_LOOKUP API.
                   7206: One consequence of this is that trusted certificates with matching subject
                   7207: name must either appear in a file (as specified by the
                   7208: .Fl CAfile
                   7209: option) or a directory (as specified by
                   7210: .Fl CApath ) .
                   7211: If they occur in both, only the certificates in the file will
                   7212: be recognised.
                   7213: .Pp
                   7214: Previous versions of
                   7215: .Nm OpenSSL
                   7216: assumed certificates with matching subject name were identical and
                   7217: mishandled them.
                   7218: .\"
                   7219: .\" VERSION
                   7220: .\"
                   7221: .Sh VERSION
                   7222: .Nm openssl version
                   7223: .Op Fl abdfopv
                   7224: .Pp
                   7225: The
                   7226: .Nm version
                   7227: command is used to print out version information about
                   7228: .Nm OpenSSL .
                   7229: .Pp
                   7230: The options are as follows:
                   7231: .Bl -tag -width Ds
                   7232: .It Fl a
                   7233: All information: this is the same as setting all the other flags.
                   7234: .It Fl b
                   7235: The date the current version of
                   7236: .Nm OpenSSL
                   7237: was built.
                   7238: .It Fl d
                   7239: .Ev OPENSSLDIR
                   7240: setting.
                   7241: .It Fl f
                   7242: Compilation flags.
                   7243: .It Fl o
                   7244: Option information: various options set when the library was built.
                   7245: .It Fl p
                   7246: Platform setting.
                   7247: .It Fl v
                   7248: The current
                   7249: .Nm OpenSSL
                   7250: version.
                   7251: .El
                   7252: .Sh VERSION NOTES
                   7253: The output of
                   7254: .Nm openssl version -a
                   7255: would typically be used when sending in a bug report.
                   7256: .Sh VERSION HISTORY
                   7257: The
                   7258: .Fl d
                   7259: option was added in
                   7260: .Nm OpenSSL
                   7261: 0.9.7.
                   7262: .\"
                   7263: .\" X509
                   7264: .\"
                   7265: .Sh X509
                   7266: .nr nS 1
                   7267: .Nm "openssl x509"
                   7268: .Bk -words
                   7269: .Op Fl C
                   7270: .Op Fl addreject Ar arg
                   7271: .Op Fl addtrust Ar arg
                   7272: .Op Fl alias
                   7273: .Op Fl CA Ar file
                   7274: .Op Fl CAcreateserial
                   7275: .Op Fl CAform Ar DER | PEM
                   7276: .Op Fl CAkey Ar file
                   7277: .Op Fl CAkeyform Ar DER | PEM
                   7278: .Op Fl CAserial Ar file
                   7279: .Op Fl certopt Ar option
                   7280: .Op Fl checkend Ar arg
                   7281: .Op Fl clrext
                   7282: .Op Fl clrreject
                   7283: .Op Fl clrtrust
                   7284: .Op Fl dates
                   7285: .Op Fl days Ar arg
                   7286: .Op Fl email
                   7287: .Op Fl enddate
                   7288: .Op Fl extensions Ar section
                   7289: .Op Fl extfile Ar file
                   7290: .Op Fl fingerprint
                   7291: .Op Fl hash
                   7292: .Op Fl in Ar file
                   7293: .Op Fl inform Ar DER | NET | PEM
                   7294: .Op Fl issuer
                   7295: .Op Fl issuer_hash
                   7296: .Op Fl issuer_hash_old
                   7297: .Op Fl keyform Ar DER | PEM
1.29      bcook    7298: .Op Fl md5 | sha1
1.1       jsing    7299: .Op Fl modulus
                   7300: .Op Fl nameopt Ar option
                   7301: .Op Fl noout
                   7302: .Op Fl ocsp_uri
                   7303: .Op Fl ocspid
                   7304: .Op Fl out Ar file
                   7305: .Op Fl outform Ar DER | NET | PEM
                   7306: .Op Fl passin Ar arg
                   7307: .Op Fl pubkey
                   7308: .Op Fl purpose
                   7309: .Op Fl req
                   7310: .Op Fl serial
                   7311: .Op Fl set_serial Ar n
                   7312: .Op Fl setalias Ar arg
                   7313: .Op Fl signkey Ar file
                   7314: .Op Fl startdate
                   7315: .Op Fl subject
                   7316: .Op Fl subject_hash
                   7317: .Op Fl subject_hash_old
                   7318: .Op Fl text
                   7319: .Op Fl trustout
                   7320: .Op Fl x509toreq
                   7321: .Ek
                   7322: .nr nS 0
                   7323: .Pp
                   7324: The
                   7325: .Nm x509
                   7326: command is a multi-purpose certificate utility.
                   7327: It can be used to display certificate information, convert certificates to
                   7328: various forms, sign certificate requests like a
                   7329: .Qq mini CA ,
                   7330: or edit certificate trust settings.
                   7331: .Pp
                   7332: Since there are a large number of options, they are split up into
                   7333: various sections.
                   7334: .Sh X509 INPUT, OUTPUT, AND GENERAL PURPOSE OPTIONS
                   7335: .Bl -tag -width "XXXX"
                   7336: .It Fl in Ar file
                   7337: This specifies the input
                   7338: .Ar file
                   7339: to read a certificate from, or standard input if this option is not specified.
                   7340: .It Fl inform Ar DER | NET | PEM
                   7341: This specifies the input format.
                   7342: Normally, the command will expect an X.509 certificate,
                   7343: but this can change if other options such as
                   7344: .Fl req
                   7345: are present.
                   7346: The
                   7347: .Ar DER
                   7348: format is the DER encoding of the certificate and
                   7349: .Ar PEM
                   7350: is the base64 encoding of the DER encoding with header and footer lines added.
                   7351: The
                   7352: .Ar NET
                   7353: option is an obscure Netscape server format that is now
                   7354: obsolete.
1.29      bcook    7355: .It Fl md5 | sha1
1.1       jsing    7356: The digest to use.
                   7357: This affects any signing or display option that uses a message digest,
                   7358: such as the
                   7359: .Fl fingerprint , signkey ,
                   7360: and
                   7361: .Fl CA
                   7362: options.
                   7363: If not specified, MD5 is used.
                   7364: If the key being used to sign with is a DSA key,
                   7365: this option has no effect: SHA1 is always used with DSA keys.
                   7366: .It Fl out Ar file
                   7367: This specifies the output
                   7368: .Ar file
                   7369: to write to, or standard output by default.
                   7370: .It Fl outform Ar DER | NET | PEM
                   7371: This specifies the output format; the options have the same meaning as the
                   7372: .Fl inform
                   7373: option.
                   7374: .It Fl passin Ar arg
                   7375: The key password source.
                   7376: .El
                   7377: .Sh X509 DISPLAY OPTIONS
                   7378: .Sy Note :
                   7379: The
                   7380: .Fl alias
                   7381: and
                   7382: .Fl purpose
                   7383: options are also display options but are described in the
                   7384: .Sx X509 TRUST SETTINGS
                   7385: section.
                   7386: .Bl -tag -width "XXXX"
                   7387: .It Fl C
                   7388: This outputs the certificate in the form of a C source file.
                   7389: .It Fl certopt Ar option
                   7390: Customise the output format used with
                   7391: .Fl text .
                   7392: The
                   7393: .Ar option
                   7394: argument can be a single option or multiple options separated by commas.
                   7395: The
                   7396: .Fl certopt
                   7397: switch may also be used more than once to set multiple options.
                   7398: See the
                   7399: .Sx X509 TEXT OPTIONS
                   7400: section for more information.
                   7401: .It Fl dates
                   7402: Prints out the start and expiry dates of a certificate.
                   7403: .It Fl email
                   7404: Outputs the email address(es), if any.
                   7405: .It Fl enddate
                   7406: Prints out the expiry date of the certificate; that is, the
                   7407: .Em notAfter
                   7408: date.
                   7409: .It Fl fingerprint
                   7410: Prints out the digest of the DER-encoded version of the whole certificate
                   7411: (see
                   7412: .Sx DIGEST OPTIONS ) .
                   7413: .It Fl hash
                   7414: A synonym for
                   7415: .Fl subject_hash ,
                   7416: for backwards compatibility.
                   7417: .It Fl issuer
                   7418: Outputs the issuer name.
                   7419: .It Fl issuer_hash
                   7420: Outputs the
                   7421: .Qq hash
                   7422: of the certificate issuer name.
                   7423: .It Fl issuer_hash_old
                   7424: Outputs the
                   7425: .Qq hash
                   7426: of the certificate issuer name using the older algorithm
                   7427: as used by
                   7428: .Nm OpenSSL
                   7429: versions before 1.0.0.
                   7430: .It Fl modulus
                   7431: This option prints out the value of the modulus of the public key
                   7432: contained in the certificate.
                   7433: .It Fl nameopt Ar option
                   7434: Option which determines how the subject or issuer names are displayed.
                   7435: The
                   7436: .Ar option
                   7437: argument can be a single option or multiple options separated by commas.
                   7438: Alternatively, the
                   7439: .Fl nameopt
                   7440: switch may be used more than once to set multiple options.
                   7441: See the
                   7442: .Sx X509 NAME OPTIONS
                   7443: section for more information.
                   7444: .It Fl noout
                   7445: This option prevents output of the encoded version of the request.
                   7446: .It Fl ocsp_uri
                   7447: Outputs the OCSP responder addresses, if any.
                   7448: .It Fl ocspid
                   7449: Print OCSP hash values for the subject name and public key.
                   7450: .It Fl pubkey
                   7451: Output the public key.
                   7452: .It Fl serial
                   7453: Outputs the certificate serial number.
                   7454: .It Fl startdate
                   7455: Prints out the start date of the certificate; that is, the
                   7456: .Em notBefore
                   7457: date.
                   7458: .It Fl subject
                   7459: Outputs the subject name.
                   7460: .It Fl subject_hash
                   7461: Outputs the
                   7462: .Qq hash
                   7463: of the certificate subject name.
                   7464: This is used in
                   7465: .Nm OpenSSL
                   7466: to form an index to allow certificates in a directory to be looked up
                   7467: by subject name.
                   7468: .It Fl subject_hash_old
                   7469: Outputs the
                   7470: .Qq hash
                   7471: of the certificate subject name using the older algorithm
                   7472: as used by
                   7473: .Nm OpenSSL
                   7474: versions before 1.0.0.
                   7475: .It Fl text
                   7476: Prints out the certificate in text form.
                   7477: Full details are output including the public key, signature algorithms,
                   7478: issuer and subject names, serial number, any extensions present,
                   7479: and any trust settings.
                   7480: .El
                   7481: .Sh X509 TRUST SETTINGS
                   7482: Please note these options are currently experimental and may well change.
                   7483: .Pp
                   7484: A
                   7485: .Em trusted certificate
                   7486: is an ordinary certificate which has several
                   7487: additional pieces of information attached to it such as the permitted
                   7488: and prohibited uses of the certificate and an
                   7489: .Qq alias .
                   7490: .Pp
                   7491: Normally, when a certificate is being verified at least one certificate
                   7492: must be
                   7493: .Qq trusted .
                   7494: By default, a trusted certificate must be stored
                   7495: locally and must be a root CA: any certificate chain ending in this CA
                   7496: is then usable for any purpose.
                   7497: .Pp
                   7498: Trust settings currently are only used with a root CA.
                   7499: They allow a finer control over the purposes the root CA can be used for.
                   7500: For example, a CA may be trusted for an SSL client but not for
                   7501: SSL server use.
                   7502: .Pp
                   7503: See the description of the
                   7504: .Nm verify
                   7505: utility for more information on the meaning of trust settings.
                   7506: .Pp
                   7507: Future versions of
                   7508: .Nm OpenSSL
                   7509: will recognize trust settings on any certificate: not just root CAs.
                   7510: .Bl -tag -width "XXXX"
                   7511: .It Fl addreject Ar arg
                   7512: Adds a prohibited use.
                   7513: It accepts the same values as the
                   7514: .Fl addtrust
                   7515: option.
                   7516: .It Fl addtrust Ar arg
                   7517: Adds a trusted certificate use.
                   7518: Any object name can be used here, but currently only
                   7519: .Ar clientAuth
                   7520: .Pq SSL client use ,
                   7521: .Ar serverAuth
                   7522: .Pq SSL server use ,
                   7523: and
                   7524: .Ar emailProtection
                   7525: .Pq S/MIME email
                   7526: are used.
                   7527: Other
                   7528: .Nm OpenSSL
                   7529: applications may define additional uses.
                   7530: .It Fl alias
                   7531: Outputs the certificate alias, if any.
                   7532: .It Fl clrreject
                   7533: Clears all the prohibited or rejected uses of the certificate.
                   7534: .It Fl clrtrust
                   7535: Clears all the permitted or trusted uses of the certificate.
                   7536: .It Fl purpose
                   7537: This option performs tests on the certificate extensions and outputs
                   7538: the results.
                   7539: For a more complete description, see the
                   7540: .Sx X.509 CERTIFICATE EXTENSIONS
                   7541: section.
                   7542: .It Fl setalias Ar arg
                   7543: Sets the alias of the certificate.
                   7544: This will allow the certificate to be referred to using a nickname,
                   7545: for example
                   7546: .Qq Steve's Certificate .
                   7547: .It Fl trustout
                   7548: This causes
                   7549: .Nm x509
                   7550: to output a
                   7551: .Em trusted certificate .
                   7552: An ordinary or trusted certificate can be input, but by default an ordinary
                   7553: certificate is output and any trust settings are discarded.
                   7554: With the
                   7555: .Fl trustout
                   7556: option a trusted certificate is output.
                   7557: A trusted certificate is automatically output if any trust settings
                   7558: are modified.
                   7559: .El
                   7560: .Sh X509 SIGNING OPTIONS
                   7561: The
                   7562: .Nm x509
                   7563: utility can be used to sign certificates and requests: it
                   7564: can thus behave like a
                   7565: .Qq mini CA .
                   7566: .Bl -tag -width "XXXX"
                   7567: .It Fl CA Ar file
                   7568: Specifies the CA certificate to be used for signing.
                   7569: When this option is present,
                   7570: .Nm x509
                   7571: behaves like a
                   7572: .Qq mini CA .
                   7573: The input file is signed by the CA using this option;
                   7574: that is, its issuer name is set to the subject name of the CA and it is
                   7575: digitally signed using the CA's private key.
                   7576: .Pp
                   7577: This option is normally combined with the
                   7578: .Fl req
                   7579: option.
                   7580: Without the
                   7581: .Fl req
                   7582: option, the input is a certificate which must be self-signed.
                   7583: .It Fl CAcreateserial
                   7584: With this option the CA serial number file is created if it does not exist:
                   7585: it will contain the serial number
                   7586: .Sq 02
                   7587: and the certificate being signed will have
                   7588: .Sq 1
                   7589: as its serial number.
                   7590: Normally, if the
                   7591: .Fl CA
                   7592: option is specified and the serial number file does not exist, it is an error.
                   7593: .It Fl CAform Ar DER | PEM
                   7594: The format of the CA certificate file.
                   7595: The default is
                   7596: .Ar PEM .
                   7597: .It Fl CAkey Ar file
                   7598: Sets the CA private key to sign a certificate with.
                   7599: If this option is not specified, it is assumed that the CA private key
                   7600: is present in the CA certificate file.
                   7601: .It Fl CAkeyform Ar DER | PEM
                   7602: The format of the CA private key.
                   7603: The default is
                   7604: .Ar PEM .
                   7605: .It Fl CAserial Ar file
                   7606: Sets the CA serial number file to use.
                   7607: .Pp
                   7608: When the
                   7609: .Fl CA
                   7610: option is used to sign a certificate,
                   7611: it uses a serial number specified in a file.
                   7612: This file consists of one line containing an even number of hex digits
                   7613: with the serial number to use.
                   7614: After each use the serial number is incremented and written out
                   7615: to the file again.
                   7616: .Pp
                   7617: The default filename consists of the CA certificate file base name with
                   7618: .Pa .srl
                   7619: appended.
                   7620: For example, if the CA certificate file is called
                   7621: .Pa mycacert.pem ,
                   7622: it expects to find a serial number file called
                   7623: .Pa mycacert.srl .
                   7624: .It Fl checkend Ar arg
                   7625: Check whether the certificate expires in the next
                   7626: .Ar arg
                   7627: seconds.
                   7628: If so, exit with return value 1;
                   7629: otherwise exit with return value 0.
                   7630: .It Fl clrext
                   7631: Delete any extensions from a certificate.
                   7632: This option is used when a certificate is being created from another
                   7633: certificate (for example with the
                   7634: .Fl signkey
                   7635: or the
                   7636: .Fl CA
                   7637: options).
                   7638: Normally, all extensions are retained.
                   7639: .It Fl days Ar arg
                   7640: Specifies the number of days to make a certificate valid for.
                   7641: The default is 30 days.
                   7642: .It Fl extensions Ar section
                   7643: The section to add certificate extensions from.
                   7644: If this option is not specified, the extensions should either be
                   7645: contained in the unnamed
                   7646: .Pq default
                   7647: section or the default section should contain a variable called
                   7648: .Qq extensions
                   7649: which contains the section to use.
                   7650: .It Fl extfile Ar file
                   7651: File containing certificate extensions to use.
                   7652: If not specified, no extensions are added to the certificate.
                   7653: .It Fl keyform Ar DER | PEM
                   7654: Specifies the format
                   7655: .Pq DER or PEM
                   7656: of the private key file used in the
                   7657: .Fl signkey
                   7658: option.
                   7659: .It Fl req
                   7660: By default, a certificate is expected on input.
                   7661: With this option a certificate request is expected instead.
                   7662: .It Fl set_serial Ar n
                   7663: Specifies the serial number to use.
                   7664: This option can be used with either the
                   7665: .Fl signkey
                   7666: or
                   7667: .Fl CA
                   7668: options.
                   7669: If used in conjunction with the
                   7670: .Fl CA
                   7671: option, the serial number file (as specified by the
                   7672: .Fl CAserial
                   7673: or
                   7674: .Fl CAcreateserial
                   7675: options) is not used.
                   7676: .Pp
                   7677: The serial number can be decimal or hex (if preceded by
                   7678: .Sq 0x ) .
                   7679: Negative serial numbers can also be specified but their use is not recommended.
                   7680: .It Fl signkey Ar file
                   7681: This option causes the input file to be self-signed using the supplied
                   7682: private key.
                   7683: .Pp
                   7684: If the input file is a certificate, it sets the issuer name to the
                   7685: subject name
                   7686: .Pq i.e. makes it self-signed ,
                   7687: changes the public key to the supplied value,
                   7688: and changes the start and end dates.
                   7689: The start date is set to the current time and the end date is set to
                   7690: a value determined by the
                   7691: .Fl days
                   7692: option.
                   7693: Any certificate extensions are retained unless the
                   7694: .Fl clrext
                   7695: option is supplied.
                   7696: .Pp
                   7697: If the input is a certificate request, a self-signed certificate
                   7698: is created using the supplied private key using the subject name in
                   7699: the request.
                   7700: .It Fl x509toreq
                   7701: Converts a certificate into a certificate request.
                   7702: The
                   7703: .Fl signkey
                   7704: option is used to pass the required private key.
                   7705: .El
                   7706: .Sh X509 NAME OPTIONS
                   7707: The
                   7708: .Fl nameopt
                   7709: command line switch determines how the subject and issuer
                   7710: names are displayed.
                   7711: If no
                   7712: .Fl nameopt
                   7713: switch is present, the default
                   7714: .Qq oneline
                   7715: format is used which is compatible with previous versions of
                   7716: .Nm OpenSSL .
                   7717: Each option is described in detail below; all options can be preceded by a
                   7718: .Sq -
                   7719: to turn the option off.
                   7720: Only
                   7721: .Ar compat ,
                   7722: .Ar RFC2253 ,
                   7723: .Ar oneline ,
                   7724: and
                   7725: .Ar multiline
                   7726: will normally be used.
                   7727: .Bl -tag -width "XXXX"
                   7728: .It Ar align
                   7729: Align field values for a more readable output.
                   7730: Only usable with
                   7731: .Ar sep_multiline .
                   7732: .It Ar compat
                   7733: Use the old format.
                   7734: This is equivalent to specifying no name options at all.
                   7735: .It Ar dn_rev
                   7736: Reverse the fields of the DN.
                   7737: This is required by RFC 2253.
                   7738: As a side effect, this also reverses the order of multiple AVAs but this is
                   7739: permissible.
                   7740: .It Ar dump_all
                   7741: Dump all fields.
                   7742: This option, when used with
                   7743: .Ar dump_der ,
                   7744: allows the DER encoding of the structure to be unambiguously determined.
                   7745: .It Ar dump_der
                   7746: When this option is set, any fields that need to be hexdumped will
                   7747: be dumped using the DER encoding of the field.
                   7748: Otherwise just the content octets will be displayed.
                   7749: Both options use the RFC 2253 #XXXX... format.
                   7750: .It Ar dump_nostr
                   7751: Dump non-character string types
                   7752: .Pq for example OCTET STRING ;
                   7753: if this option is not set, non-character string types will be displayed
                   7754: as though each content octet represents a single character.
                   7755: .It Ar dump_unknown
                   7756: Dump any field whose OID is not recognised by
                   7757: .Nm OpenSSL .
                   7758: .It Ar esc_2253
                   7759: Escape the
                   7760: .Qq special
                   7761: characters required by RFC 2253 in a field that is
                   7762: .Dq \& ,+"\*(Lt\*(Gt; .
                   7763: Additionally,
                   7764: .Sq #
                   7765: is escaped at the beginning of a string
                   7766: and a space character at the beginning or end of a string.
                   7767: .It Ar esc_ctrl
                   7768: Escape control characters.
                   7769: That is, those with ASCII values less than 0x20
                   7770: .Pq space
                   7771: and the delete
                   7772: .Pq 0x7f
                   7773: character.
                   7774: They are escaped using the RFC 2253 \eXX notation (where XX are two hex
                   7775: digits representing the character value).
                   7776: .It Ar esc_msb
                   7777: Escape characters with the MSB set; that is, with ASCII values larger than
                   7778: 127.
                   7779: .It Ar multiline
                   7780: A multiline format.
                   7781: It is equivalent to
                   7782: .Ar esc_ctrl , esc_msb , sep_multiline ,
                   7783: .Ar space_eq , lname ,
                   7784: and
                   7785: .Ar align .
                   7786: .It Ar no_type
                   7787: This option does not attempt to interpret multibyte characters in any
                   7788: way.
                   7789: That is, their content octets are merely dumped as though one octet
                   7790: represents each character.
                   7791: This is useful for diagnostic purposes but will result in rather odd
                   7792: looking output.
                   7793: .It Ar nofname , sname , lname , oid
                   7794: These options alter how the field name is displayed.
                   7795: .Ar nofname
                   7796: does not display the field at all.
                   7797: .Ar sname
                   7798: uses the
                   7799: .Qq short name
                   7800: form (CN for
                   7801: .Ar commonName ,
                   7802: for example).
                   7803: .Ar lname
                   7804: uses the long form.
                   7805: .Ar oid
                   7806: represents the OID in numerical form and is useful for diagnostic purpose.
                   7807: .It Ar oneline
                   7808: A oneline format which is more readable than
                   7809: .Ar RFC2253 .
                   7810: It is equivalent to specifying the
                   7811: .Ar esc_2253 , esc_ctrl , esc_msb , utf8 ,
                   7812: .Ar dump_nostr , dump_der , use_quote , sep_comma_plus_spc ,
                   7813: .Ar space_eq ,
                   7814: and
                   7815: .Ar sname
                   7816: options.
                   7817: .It Ar RFC2253
                   7818: Displays names compatible with RFC 2253; equivalent to
                   7819: .Ar esc_2253 , esc_ctrl ,
                   7820: .Ar esc_msb , utf8 , dump_nostr , dump_unknown ,
                   7821: .Ar dump_der , sep_comma_plus , dn_rev ,
                   7822: and
                   7823: .Ar sname .
                   7824: .It Ar sep_comma_plus , sep_comma_plus_space , sep_semi_plus_space , sep_multiline
                   7825: These options determine the field separators.
                   7826: The first character is between RDNs and the second between multiple AVAs
                   7827: (multiple AVAs are very rare and their use is discouraged).
                   7828: The options ending in
                   7829: .Qq space
                   7830: additionally place a space after the separator to make it more readable.
                   7831: The
                   7832: .Ar sep_multiline
                   7833: uses a linefeed character for the RDN separator and a spaced
                   7834: .Sq +
                   7835: for the AVA separator.
                   7836: It also indents the fields by four characters.
                   7837: .It Ar show_type
                   7838: Show the type of the ASN1 character string.
                   7839: The type precedes the field contents.
                   7840: For example
                   7841: .Qq BMPSTRING: Hello World .
                   7842: .It Ar space_eq
                   7843: Places spaces round the
                   7844: .Sq =
                   7845: character which follows the field name.
                   7846: .It Ar use_quote
                   7847: Escapes some characters by surrounding the whole string with
                   7848: .Sq \&"
                   7849: characters.
                   7850: Without the option, all escaping is done with the
                   7851: .Sq \e
                   7852: character.
                   7853: .It Ar utf8
                   7854: Convert all strings to UTF8 format first.
                   7855: This is required by RFC 2253.
                   7856: If you are lucky enough to have a UTF8 compatible terminal,
                   7857: the use of this option (and
                   7858: .Em not
                   7859: setting
                   7860: .Ar esc_msb )
                   7861: may result in the correct display of multibyte
                   7862: .Pq international
                   7863: characters.
                   7864: If this option is not present, multibyte characters larger than 0xff
                   7865: will be represented using the format \eUXXXX for 16 bits and \eWXXXXXXXX
                   7866: for 32 bits.
                   7867: Also, if this option is off, any UTF8Strings will be converted to their
                   7868: character form first.
                   7869: .El
                   7870: .Sh X509 TEXT OPTIONS
                   7871: As well as customising the name output format, it is also possible to
                   7872: customise the actual fields printed using the
                   7873: .Fl certopt
                   7874: options when the
                   7875: .Fl text
                   7876: option is present.
                   7877: The default behaviour is to print all fields.
                   7878: .Bl -tag -width "XXXX"
                   7879: .It Ar ca_default
                   7880: The value used by the
                   7881: .Nm ca
                   7882: utility; equivalent to
                   7883: .Ar no_issuer , no_pubkey , no_header ,
                   7884: .Ar no_version , no_sigdump ,
                   7885: and
                   7886: .Ar no_signame .
                   7887: .It Ar compatible
                   7888: Use the old format.
                   7889: This is equivalent to specifying no output options at all.
                   7890: .It Ar ext_default
                   7891: Retain default extension behaviour: attempt to print out unsupported
                   7892: certificate extensions.
                   7893: .It Ar ext_dump
                   7894: Hex dump unsupported extensions.
                   7895: .It Ar ext_error
                   7896: Print an error message for unsupported certificate extensions.
                   7897: .It Ar ext_parse
                   7898: ASN1 parse unsupported extensions.
                   7899: .It Ar no_aux
                   7900: Don't print out certificate trust information.
                   7901: .It Ar no_extensions
                   7902: Don't print out any X509V3 extensions.
                   7903: .It Ar no_header
                   7904: Don't print header information: that is, the lines saying
                   7905: .Qq Certificate
                   7906: and
                   7907: .Qq Data .
                   7908: .It Ar no_issuer
                   7909: Don't print out the issuer name.
                   7910: .It Ar no_pubkey
                   7911: Don't print out the public key.
                   7912: .It Ar no_serial
                   7913: Don't print out the serial number.
                   7914: .It Ar no_sigdump
                   7915: Don't give a hexadecimal dump of the certificate signature.
                   7916: .It Ar no_signame
                   7917: Don't print out the signature algorithm used.
                   7918: .It Ar no_subject
                   7919: Don't print out the subject name.
                   7920: .It Ar no_validity
                   7921: Don't print the validity; that is, the
                   7922: .Em notBefore
                   7923: and
                   7924: .Em notAfter
                   7925: fields.
                   7926: .It Ar no_version
                   7927: Don't print out the version number.
                   7928: .El
                   7929: .Sh X509 EXAMPLES
                   7930: Display the contents of a certificate:
                   7931: .Pp
                   7932: .Dl $ openssl x509 -in cert.pem -noout -text
                   7933: .Pp
                   7934: Display the certificate serial number:
                   7935: .Pp
                   7936: .Dl $ openssl x509 -in cert.pem -noout -serial
                   7937: .Pp
                   7938: Display the certificate subject name:
                   7939: .Pp
                   7940: .Dl $ openssl x509 -in cert.pem -noout -subject
                   7941: .Pp
                   7942: Display the certificate subject name in RFC 2253 form:
                   7943: .Pp
                   7944: .Dl $ openssl x509 -in cert.pem -noout -subject -nameopt RFC2253
                   7945: .Pp
                   7946: Display the certificate subject name in oneline form on a terminal
                   7947: supporting UTF8:
                   7948: .Bd -literal -offset indent
                   7949: $ openssl x509 -in cert.pem -noout -subject \e
                   7950:        -nameopt oneline,-esc_msb
                   7951: .Ed
                   7952: .Pp
                   7953: Display the certificate MD5 fingerprint:
                   7954: .Pp
                   7955: .Dl $ openssl x509 -in cert.pem -noout -fingerprint
                   7956: .Pp
                   7957: Display the certificate SHA1 fingerprint:
                   7958: .Pp
                   7959: .Dl $ openssl x509 -sha1 -in cert.pem -noout -fingerprint
                   7960: .Pp
                   7961: Convert a certificate from PEM to DER format:
                   7962: .Pp
                   7963: .Dl "$ openssl x509 -in cert.pem -inform PEM -out cert.der -outform DER"
                   7964: .Pp
                   7965: Convert a certificate to a certificate request:
                   7966: .Bd -literal -offset indent
                   7967: $ openssl x509 -x509toreq -in cert.pem -out req.pem \e
                   7968:        -signkey key.pem
                   7969: .Ed
                   7970: .Pp
                   7971: Convert a certificate request into a self-signed certificate using
                   7972: extensions for a CA:
                   7973: .Bd -literal -offset indent
                   7974: $ openssl x509 -req -in careq.pem -extfile openssl.cnf -extensions \e
                   7975:        v3_ca -signkey key.pem -out cacert.pem
                   7976: .Ed
                   7977: .Pp
                   7978: Sign a certificate request using the CA certificate above and add user
                   7979: certificate extensions:
                   7980: .Bd -literal -offset indent
                   7981: $ openssl x509 -req -in req.pem -extfile openssl.cnf -extensions \e
                   7982:        v3_usr -CA cacert.pem -CAkey key.pem -CAcreateserial
                   7983: .Ed
                   7984: .Pp
                   7985: Set a certificate to be trusted for SSL
                   7986: client use and set its alias to
                   7987: .Qq Steve's Class 1 CA :
                   7988: .Bd -literal -offset indent
                   7989: $ openssl x509 -in cert.pem -addtrust clientAuth \e
                   7990:        -setalias "Steve's Class 1 CA" -out trust.pem
                   7991: .Ed
                   7992: .Sh X509 NOTES
                   7993: The PEM format uses the header and footer lines:
                   7994: .Bd -unfilled -offset indent
                   7995: -----BEGIN CERTIFICATE-----
                   7996: -----END CERTIFICATE-----
                   7997: .Ed
                   7998: .Pp
                   7999: It will also handle files containing:
                   8000: .Bd -unfilled -offset indent
                   8001: -----BEGIN X509 CERTIFICATE-----
                   8002: -----END X509 CERTIFICATE-----
                   8003: .Ed
                   8004: .Pp
                   8005: Trusted certificates have the lines:
                   8006: .Bd -unfilled -offset indent
                   8007: -----BEGIN TRUSTED CERTIFICATE-----
                   8008: -----END TRUSTED CERTIFICATE-----
                   8009: .Ed
                   8010: .Pp
                   8011: The conversion to UTF8 format used with the name options assumes that
                   8012: T61Strings use the ISO 8859-1 character set.
                   8013: This is wrong, but Netscape and MSIE do this, as do many certificates.
                   8014: So although this is incorrect
                   8015: it is more likely to display the majority of certificates correctly.
                   8016: .Pp
                   8017: The
                   8018: .Fl fingerprint
                   8019: option takes the digest of the DER-encoded certificate.
                   8020: This is commonly called a
                   8021: .Qq fingerprint .
                   8022: Because of the nature of message digests, the fingerprint of a certificate
                   8023: is unique to that certificate and two certificates with the same fingerprint
                   8024: can be considered to be the same.
                   8025: .Pp
                   8026: The Netscape fingerprint uses MD5, whereas MSIE uses SHA1.
                   8027: .Pp
                   8028: The
                   8029: .Fl email
                   8030: option searches the subject name and the subject alternative
                   8031: name extension.
                   8032: Only unique email addresses will be printed out: it will
                   8033: not print the same address more than once.
                   8034: .Sh X.509 CERTIFICATE EXTENSIONS
                   8035: The
                   8036: .Fl purpose
                   8037: option checks the certificate extensions and determines
                   8038: what the certificate can be used for.
                   8039: The actual checks done are rather
                   8040: complex and include various hacks and workarounds to handle broken
                   8041: certificates and software.
                   8042: .Pp
                   8043: The same code is used when verifying untrusted certificates in chains,
                   8044: so this section is useful if a chain is rejected by the verify code.
                   8045: .Pp
                   8046: The
                   8047: .Em basicConstraints
                   8048: extension CA flag is used to determine whether the
                   8049: certificate can be used as a CA.
                   8050: If the CA flag is true, it is a CA;
                   8051: if the CA flag is false, it is not a CA.
                   8052: .Em All
                   8053: CAs should have the CA flag set to true.
                   8054: .Pp
                   8055: If the
                   8056: .Em basicConstraints
                   8057: extension is absent, then the certificate is
                   8058: considered to be a
                   8059: .Qq possible CA ;
                   8060: other extensions are checked according to the intended use of the certificate.
                   8061: A warning is given in this case because the certificate should really not
                   8062: be regarded as a CA: however,
                   8063: it is allowed to be a CA to work around some broken software.
                   8064: .Pp
                   8065: If the certificate is a V1 certificate
                   8066: .Pq and thus has no extensions
                   8067: and it is self-signed, it is also assumed to be a CA but a warning is again
                   8068: given: this is to work around the problem of Verisign roots which are V1
                   8069: self-signed certificates.
                   8070: .Pp
                   8071: If the
                   8072: .Em keyUsage
                   8073: extension is present, then additional restraints are
                   8074: made on the uses of the certificate.
                   8075: A CA certificate
                   8076: .Em must
                   8077: have the
                   8078: .Em keyCertSign
                   8079: bit set if the
                   8080: .Em keyUsage
                   8081: extension is present.
                   8082: .Pp
                   8083: The extended key usage extension places additional restrictions on the
                   8084: certificate uses.
                   8085: If this extension is present
                   8086: .Pq whether critical or not ,
                   8087: the key can only be used for the purposes specified.
                   8088: .Pp
                   8089: A complete description of each test is given below.
                   8090: The comments about
                   8091: .Em basicConstraints
                   8092: and
                   8093: .Em keyUsage
                   8094: and V1 certificates above apply to
                   8095: .Em all
                   8096: CA certificates.
                   8097: .Bl -tag -width "XXXX"
                   8098: .It Ar SSL Client
                   8099: The extended key usage extension must be absent or include the
                   8100: .Qq web client authentication
                   8101: OID.
                   8102: .Ar keyUsage
                   8103: must be absent or it must have the
                   8104: .Em digitalSignature
                   8105: bit set.
                   8106: Netscape certificate type must be absent or it must have the SSL
                   8107: client bit set.
                   8108: .It Ar SSL Client CA
                   8109: The extended key usage extension must be absent or include the
                   8110: .Qq web client authentication
                   8111: OID.
                   8112: Netscape certificate type must be absent or it must have the SSL CA
                   8113: bit set: this is used as a work around if the
                   8114: .Em basicConstraints
                   8115: extension is absent.
                   8116: .It Ar SSL Server
                   8117: The extended key usage extension must be absent or include the
                   8118: .Qq web server authentication
                   8119: and/or one of the SGC OIDs.
                   8120: .Em keyUsage
                   8121: must be absent or it must have the
                   8122: .Em digitalSignature
                   8123: set, the
                   8124: .Em keyEncipherment
                   8125: set, or both bits set.
                   8126: Netscape certificate type must be absent or have the SSL server bit set.
                   8127: .It Ar SSL Server CA
                   8128: The extended key usage extension must be absent or include the
                   8129: .Qq web server authentication
                   8130: and/or one of the SGC OIDs.
                   8131: Netscape certificate type must be absent or the SSL CA
                   8132: bit must be set: this is used as a work around if the
                   8133: .Em basicConstraints
                   8134: extension is absent.
                   8135: .It Ar Netscape SSL Server
                   8136: For Netscape SSL clients to connect to an SSL server; it must have the
                   8137: .Em keyEncipherment
                   8138: bit set if the
                   8139: .Em keyUsage
                   8140: extension is present.
                   8141: This isn't always valid because some cipher suites use the key for
                   8142: digital signing.
                   8143: Otherwise it is the same as a normal SSL server.
                   8144: .It Ar Common S/MIME Client Tests
                   8145: The extended key usage extension must be absent or include the
                   8146: .Qq email protection
                   8147: OID.
                   8148: Netscape certificate type must be absent or should have the
                   8149: .Em S/MIME
                   8150: bit set.
                   8151: If the
                   8152: .Em S/MIME
                   8153: bit is not set in Netscape certificate type, then the SSL
                   8154: client bit is tolerated as an alternative but a warning is shown:
                   8155: this is because some Verisign certificates don't set the
                   8156: .Em S/MIME
                   8157: bit.
                   8158: .It Ar S/MIME Signing
                   8159: In addition to the common
                   8160: .Em S/MIME
                   8161: client tests, the
                   8162: .Em digitalSignature
                   8163: bit must be set if the
                   8164: .Em keyUsage
                   8165: extension is present.
                   8166: .It Ar S/MIME Encryption
                   8167: In addition to the common
                   8168: .Em S/MIME
                   8169: tests, the
                   8170: .Em keyEncipherment
                   8171: bit must be set if the
                   8172: .Em keyUsage
                   8173: extension is present.
                   8174: .It Ar S/MIME CA
                   8175: The extended key usage extension must be absent or include the
                   8176: .Qq email protection
                   8177: OID.
                   8178: Netscape certificate type must be absent or must have the
                   8179: .Em S/MIME CA
                   8180: bit set: this is used as a work around if the
                   8181: .Em basicConstraints
                   8182: extension is absent.
                   8183: .It Ar CRL Signing
                   8184: The
                   8185: .Em keyUsage
                   8186: extension must be absent or it must have the
                   8187: .Em CRL
                   8188: signing bit set.
                   8189: .It Ar CRL Signing CA
                   8190: The normal CA tests apply.
                   8191: Except in this case the
                   8192: .Em basicConstraints
                   8193: extension must be present.
                   8194: .El
                   8195: .Sh X509 BUGS
                   8196: Extensions in certificates are not transferred to certificate requests and
                   8197: vice versa.
                   8198: .Pp
                   8199: It is possible to produce invalid certificates or requests by specifying the
                   8200: wrong private key or using inconsistent options in some cases: these should
                   8201: be checked.
                   8202: .Pp
                   8203: There should be options to explicitly set such things as start and end dates,
                   8204: rather than an offset from the current time.
                   8205: .Pp
                   8206: The code to implement the verify behaviour described in the
                   8207: .Sx X509 TRUST SETTINGS
                   8208: is currently being developed.
                   8209: It thus describes the intended behaviour rather than the current behaviour.
                   8210: It is hoped that it will represent reality in
                   8211: .Nm OpenSSL
                   8212: 0.9.5 and later.
                   8213: .Sh X509 HISTORY
                   8214: Before
                   8215: .Nm OpenSSL
                   8216: 0.9.8,
                   8217: the default digest for RSA keys was MD5.
                   8218: .Pp
                   8219: The hash algorithm used in the
                   8220: .Fl subject_hash
                   8221: and
                   8222: .Fl issuer_hash
                   8223: options before
                   8224: .Nm OpenSSL
                   8225: 1.0.0 was based on the deprecated MD5 algorithm and the encoding
                   8226: of the distinguished name.
                   8227: In
                   8228: .Nm OpenSSL
                   8229: 1.0.0 and later it is based on a canonical version of the DN using SHA1.
                   8230: This means that any directories using the old form
                   8231: must have their links rebuilt using
                   8232: .Ar c_rehash
                   8233: or similar.
1.38      jmc      8234: .Sh COMMON NOTATION
                   8235: Several commands share a common syntax,
                   8236: as detailed below.
                   8237: .Pp
                   8238: Password arguments, typically specified using
1.33      jmc      8239: .Fl passin
                   8240: and
                   8241: .Fl passout
1.38      jmc      8242: for input and output passwords,
                   8243: allow passwords to be obtained from a variety of sources.
                   8244: Both of these options take a single argument, described below.
1.33      jmc      8245: If no password argument is given and a password is required,
                   8246: then the user is prompted to enter one:
                   8247: this will typically be read from the current terminal with echoing turned off.
1.38      jmc      8248: .Bl -tag -width "pass:password" -offset indent
                   8249: .It Cm pass : Ns Ar password
1.33      jmc      8250: The actual password is
                   8251: .Ar password .
1.38      jmc      8252: Since the password is visible to utilities,
1.33      jmc      8253: this form should only be used where security is not important.
1.38      jmc      8254: .It Cm env : Ns Ar var
1.33      jmc      8255: Obtain the password from the environment variable
                   8256: .Ar var .
1.38      jmc      8257: Since the environment of other processes is visible,
                   8258: this option should be used with caution.
                   8259: .It Cm file : Ns Ar path
1.33      jmc      8260: The first line of
                   8261: .Ar path
                   8262: is the password.
                   8263: If the same
                   8264: .Ar path
                   8265: argument is supplied to
                   8266: .Fl passin
                   8267: and
                   8268: .Fl passout ,
                   8269: then the first line will be used for the input password and the next line
                   8270: for the output password.
                   8271: .Ar path
                   8272: need not refer to a regular file:
                   8273: it could, for example, refer to a device or named pipe.
1.38      jmc      8274: .It Cm fd : Ns Ar number
1.33      jmc      8275: Read the password from the file descriptor
                   8276: .Ar number .
1.38      jmc      8277: This can be used to send the data via a pipe, for example.
                   8278: .It Cm stdin
1.33      jmc      8279: Read the password from standard input.
1.35      jmc      8280: .El
1.38      jmc      8281: .Pp
                   8282: File formats,
                   8283: typically specified using
                   8284: .Fl inform
                   8285: and
                   8286: .Fl outform ,
                   8287: indicate the type of file being read from
                   8288: or the file format to write.
                   8289: The argument is case insensitive.
                   8290: .Pp
                   8291: .Bl -tag -width Ds -offset indent -compact
                   8292: .It Cm der
                   8293: Distinguished Encoding Rules (DER)
                   8294: is a binary format.
                   8295: .It Cm pem
                   8296: Privacy Enhanced Mail (PEM)
                   8297: is base64-encoded.
                   8298: .It Cm txt
                   8299: Plain ASCII text.
                   8300: .El
1.35      jmc      8301: .Sh ENVIRONMENT
                   8302: The following environment variables affect the execution of
                   8303: .Nm openssl :
1.38      jmc      8304: .Bl -tag -width "/etc/ssl/openssl.cnf"
1.35      jmc      8305: .It Ev OPENSSL_CONF
                   8306: The location of the master configuration file.
1.33      jmc      8307: .El
1.1       jsing    8308: .\"
                   8309: .\" FILES
                   8310: .\"
                   8311: .Sh FILES
                   8312: .Bl -tag -width "/etc/ssl/openssl.cnf" -compact
1.17      sobrado  8313: .It Pa /etc/ssl/
1.1       jsing    8314: Default config directory for
                   8315: .Nm openssl .
1.17      sobrado  8316: .It Pa /etc/ssl/lib/
1.1       jsing    8317: Unused.
1.17      sobrado  8318: .It Pa /etc/ssl/private/
1.1       jsing    8319: Default private key directory.
1.17      sobrado  8320: .It Pa /etc/ssl/openssl.cnf
1.1       jsing    8321: Default configuration file for
                   8322: .Nm openssl .
1.17      sobrado  8323: .It Pa /etc/ssl/x509v3.cnf
1.1       jsing    8324: Default configuration file for
                   8325: .Nm x509
                   8326: certificates.
                   8327: .El
                   8328: .\"
                   8329: .\" SEE ALSO
                   8330: .\"
                   8331: .Sh SEE ALSO
1.26      jmc      8332: .Xr nc 1 ,
1.1       jsing    8333: .Xr ssl 8 ,
                   8334: .Xr starttls 8
                   8335: .Sh STANDARDS
                   8336: .Rs
                   8337: .%D February 1995
                   8338: .%Q Netscape Communications Corp.
                   8339: .%T The SSL Protocol
                   8340: .Re
                   8341: .Pp
                   8342: .Rs
                   8343: .%D November 1996
                   8344: .%Q Netscape Communications Corp.
                   8345: .%T The SSL 3.0 Protocol
                   8346: .Re
                   8347: .Pp
                   8348: .Rs
                   8349: .%A T. Dierks
                   8350: .%A C. Allen
                   8351: .%D January 1999
                   8352: .%R RFC 2246
                   8353: .%T The TLS Protocol Version 1.0
                   8354: .Re
                   8355: .Pp
                   8356: .Rs
                   8357: .%A M. Wahl
                   8358: .%A S. Killie
                   8359: .%A T. Howes
                   8360: .%D December 1997
                   8361: .%R RFC 2253
                   8362: .%T Lightweight Directory Access Protocol (v3): UTF-8 String Representation of Distinguished Names
                   8363: .Re
                   8364: .Pp
                   8365: .Rs
                   8366: .%A B. Kaliski
                   8367: .%D March 1998
                   8368: .%R RFC 2315
                   8369: .%T PKCS #7: Cryptographic Message Syntax Version 1.5
                   8370: .Re
                   8371: .Pp
                   8372: .Rs
                   8373: .%A R. Housley
                   8374: .%A W. Ford
                   8375: .%A W. Polk
                   8376: .%A D. Solo
                   8377: .%D January 1999
                   8378: .%R RFC 2459
                   8379: .%T Internet X.509 Public Key Infrastructure Certificate and CRL Profile
                   8380: .Re
                   8381: .Pp
                   8382: .Rs
                   8383: .%A M. Myers
                   8384: .%A R. Ankney
                   8385: .%A A. Malpani
                   8386: .%A S. Galperin
                   8387: .%A C. Adams
                   8388: .%D June 1999
                   8389: .%R RFC 2560
                   8390: .%T X.509 Internet Public Key Infrastructure Online Certificate Status Protocol \(en OCSP
                   8391: .Re
                   8392: .Pp
                   8393: .Rs
                   8394: .%A R. Housley
                   8395: .%D June 1999
                   8396: .%R RFC 2630
                   8397: .%T Cryptographic Message Syntax
                   8398: .Re
                   8399: .Pp
                   8400: .Rs
                   8401: .%A P. Chown
                   8402: .%D June 2002
                   8403: .%R RFC 3268
1.24      jmc      8404: .%T Advanced Encryption Standard (AES) Ciphersuites for Transport Layer Security (TLS)
1.1       jsing    8405: .Re