[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.50

1.50    ! jmc         1: .\" $OpenBSD: openssl.1,v 1.49 2016/08/12 06:17:22 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.50    ! jmc       115: .Dd $Mdocdate: August 12 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,
                   1732: or standard input if none is 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.49      jmc      1803: The output file to read from,
                   1804: or standard output if none is 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: .\"
                   1855: .\" GENDSA
                   1856: .\"
                   1857: .Sh GENDSA
                   1858: .nr nS 1
                   1859: .Nm "openssl gendsa"
                   1860: .Bk -words
                   1861: .Oo
                   1862: .Fl aes128 | aes192 | aes256 |
                   1863: .Fl des | des3
                   1864: .Oc
                   1865: .Op Fl out Ar file
                   1866: .Op Ar paramfile
                   1867: .Ek
                   1868: .nr nS 0
                   1869: .Pp
                   1870: The
                   1871: .Nm gendsa
                   1872: command generates a DSA private key from a DSA parameter file
                   1873: (which will typically be generated by the
                   1874: .Nm openssl dsaparam
                   1875: command).
                   1876: .Pp
                   1877: The options are as follows:
                   1878: .Bl -tag -width Ds
                   1879: .It Xo
                   1880: .Fl aes128 | aes192 | aes256 |
                   1881: .Fl des | des3
                   1882: .Xc
                   1883: These options encrypt the private key with the AES, DES,
                   1884: or the triple DES ciphers, respectively, before outputting it.
                   1885: A pass phrase is prompted for.
                   1886: If none of these options are specified, no encryption is used.
                   1887: .It Fl out Ar file
                   1888: The output
                   1889: .Ar file .
                   1890: If this argument is not specified, standard output is used.
                   1891: .It Ar paramfile
                   1892: This option specifies the DSA parameter file to use.
                   1893: The parameters in this file determine the size of the private key.
                   1894: DSA parameters can be generated and examined using the
                   1895: .Nm openssl dsaparam
                   1896: command.
                   1897: .El
                   1898: .Sh GENDSA NOTES
                   1899: DSA key generation is little more than random number generation so it is
                   1900: much quicker than RSA key generation, for example.
                   1901: .\"
                   1902: .\" GENPKEY
                   1903: .\"
                   1904: .Sh GENPKEY
                   1905: .nr nS 1
                   1906: .Nm "openssl genpkey"
                   1907: .Bk -words
                   1908: .Op Fl algorithm Ar alg
                   1909: .Op Ar cipher
                   1910: .Op Fl genparam
                   1911: .Op Fl out Ar file
                   1912: .Op Fl outform Ar DER | PEM
                   1913: .Op Fl paramfile Ar file
                   1914: .Op Fl pass Ar arg
                   1915: .Op Fl pkeyopt Ar opt : Ns Ar value
                   1916: .Op Fl text
                   1917: .Ek
                   1918: .nr nS 0
                   1919: .Pp
                   1920: The
                   1921: .Nm genpkey
                   1922: command generates private keys.
                   1923: The use of this
                   1924: program is encouraged over the algorithm specific utilities
1.22      bcook    1925: because additional algorithm options can be used.
1.1       jsing    1926: .Pp
                   1927: The options are as follows:
                   1928: .Bl -tag -width Ds
                   1929: .It Fl algorithm Ar alg
                   1930: The public key algorithm to use,
                   1931: such as RSA, DSA, or DH.
                   1932: If used this option must precede any
                   1933: .Fl pkeyopt
                   1934: options.
                   1935: The options
                   1936: .Fl paramfile
                   1937: and
                   1938: .Fl algorithm
                   1939: are mutually exclusive.
                   1940: .It Ar cipher
                   1941: Encrypt the private key with the supplied cipher.
                   1942: Any algorithm name accepted by
                   1943: .Fn EVP_get_cipherbyname
                   1944: is acceptable, such as
                   1945: .Cm des3 .
                   1946: .It Fl genparam
                   1947: Generate a set of parameters instead of a private key.
                   1948: If used this option must precede any
                   1949: .Fl algorithm ,
                   1950: .Fl paramfile ,
                   1951: or
                   1952: .Fl pkeyopt
                   1953: options.
                   1954: .It Fl out Ar file
                   1955: The output filename.
                   1956: If this argument is not specified then standard output is used.
                   1957: .It Fl outform Ar DER | PEM
                   1958: This specifies the output format, DER or PEM.
                   1959: .It Fl paramfile Ar file
                   1960: Some public key algorithms generate a private key based on a set of parameters.
                   1961: They can be supplied using this option.
                   1962: If this option is used the public key
                   1963: algorithm used is determined by the parameters.
                   1964: If used this option must precede any
                   1965: .Fl pkeyopt
                   1966: options.
                   1967: The options
                   1968: .Fl paramfile
                   1969: and
                   1970: .Fl algorithm
                   1971: are mutually exclusive.
                   1972: .It Fl pass Ar arg
                   1973: The output file password source.
                   1974: .It Fl pkeyopt Ar opt : Ns Ar value
                   1975: Set the public key algorithm option
                   1976: .Ar opt
                   1977: to
                   1978: .Ar value .
                   1979: The precise set of options supported
                   1980: depends on the public key algorithm used and its implementation.
                   1981: See
                   1982: .Sx GENPKEY KEY GENERATION OPTIONS
                   1983: below for more details.
                   1984: .It Fl text
                   1985: Print an (unencrypted) text representation of private and public keys and
                   1986: parameters along with the DER or PEM structure.
                   1987: .El
                   1988: .Sh GENPKEY KEY GENERATION OPTIONS
                   1989: The options supported by each algorithm
                   1990: and indeed each implementation of an algorithm can vary.
                   1991: The options for the
                   1992: .Nm OpenSSL
                   1993: implementations are detailed below.
                   1994: .Bl -tag -width Ds -offset indent
                   1995: .It rsa_keygen_bits : Ns Ar numbits
                   1996: (RSA)
                   1997: The number of bits in the generated key.
                   1998: If not specified 2048 is used.
                   1999: .It rsa_keygen_pubexp : Ns Ar value
                   2000: (RSA)
                   2001: The RSA public exponent value.
                   2002: This can be a large decimal or hexadecimal value if preceded by 0x.
                   2003: The default value is 65537.
                   2004: .It dsa_paramgen_bits : Ns Ar numbits
                   2005: (DSA)
                   2006: The number of bits in the generated parameters.
                   2007: If not specified 1024 is used.
                   2008: .It dh_paramgen_prime_len : Ns Ar numbits
                   2009: (DH)
                   2010: The number of bits in the prime parameter
                   2011: .Ar p .
                   2012: .It dh_paramgen_generator : Ns Ar value
                   2013: (DH)
                   2014: The value to use for the generator
                   2015: .Ar g .
                   2016: .It ec_paramgen_curve : Ns Ar curve
                   2017: (EC)
                   2018: The EC curve to use.
                   2019: .El
                   2020: .Sh GENPKEY EXAMPLES
                   2021: Generate an RSA private key using default parameters:
                   2022: .Bd -literal -offset indent
                   2023: $ openssl genpkey -algorithm RSA -out key.pem
                   2024: .Ed
                   2025: .Pp
                   2026: Encrypt and output a private key using 128-bit AES and the passphrase "hello":
                   2027: .Bd -literal -offset indent
                   2028: $ openssl genpkey -algorithm RSA -out key.pem \e
                   2029:        -aes-128-cbc -pass pass:hello
                   2030: .Ed
                   2031: .Pp
                   2032: Generate a 2048-bit RSA key using 3 as the public exponent:
                   2033: .Bd -literal -offset indent
                   2034: $ openssl genpkey -algorithm RSA -out key.pem \e
                   2035:        -pkeyopt rsa_keygen_bits:2048 -pkeyopt rsa_keygen_pubexp:3
                   2036: .Ed
                   2037: .Pp
                   2038: Generate 1024-bit DSA parameters:
                   2039: .Bd -literal -offset indent
                   2040: $ openssl genpkey -genparam -algorithm DSA \e
                   2041:        -out dsap.pem -pkeyopt dsa_paramgen_bits:1024
                   2042: .Ed
                   2043: .Pp
                   2044: Generate a DSA key from parameters:
                   2045: .Bd -literal -offset indent
                   2046: $ openssl genpkey -paramfile dsap.pem -out dsakey.pem
                   2047: .Ed
                   2048: .Pp
                   2049: Generate 1024-bit DH parameters:
                   2050: .Bd -literal -offset indent
                   2051: $ openssl genpkey -genparam -algorithm DH \e
                   2052:        -out dhp.pem -pkeyopt dh_paramgen_prime_len:1024
                   2053: .Ed
                   2054: .Pp
                   2055: Generate a DH key from parameters:
                   2056: .Bd -literal -offset indent
                   2057: $ openssl genpkey -paramfile dhp.pem -out dhkey.pem
                   2058: .Ed
                   2059: .\"
                   2060: .\" GENRSA
                   2061: .\"
                   2062: .Sh GENRSA
                   2063: .nr nS 1
                   2064: .Nm "openssl genrsa"
                   2065: .Bk -words
                   2066: .Op Fl 3 | f4
                   2067: .Oo
                   2068: .Fl aes128 | aes192 | aes256 |
                   2069: .Fl des | des3
                   2070: .Oc
                   2071: .Op Fl out Ar file
                   2072: .Op Fl passout Ar arg
                   2073: .Op Ar numbits
                   2074: .Ek
                   2075: .nr nS 0
                   2076: .Pp
                   2077: The
                   2078: .Nm genrsa
                   2079: command generates an RSA private key.
                   2080: .Pp
                   2081: The options are as follows:
                   2082: .Bl -tag -width Ds
                   2083: .It Fl 3 | f4
                   2084: The public exponent to use, either 3 or 65537.
                   2085: The default is 65537.
                   2086: .It Xo
                   2087: .Fl aes128 | aes192 | aes256 |
                   2088: .Fl des | des3
                   2089: .Xc
                   2090: These options encrypt the private key with the AES, DES,
                   2091: or the triple DES ciphers, respectively, before outputting it.
                   2092: If none of these options are specified, no encryption is used.
                   2093: If encryption is used, a pass phrase is prompted for,
                   2094: if it is not supplied via the
                   2095: .Fl passout
                   2096: option.
                   2097: .It Fl out Ar file
                   2098: The output
                   2099: .Ar file .
                   2100: If this argument is not specified, standard output is used.
                   2101: .It Fl passout Ar arg
                   2102: The output file password source.
                   2103: .It Ar numbits
                   2104: The size of the private key to generate in bits.
                   2105: This must be the last option specified.
                   2106: The default is 2048.
                   2107: .El
                   2108: .Sh GENRSA NOTES
                   2109: RSA private key generation essentially involves the generation of two prime
                   2110: numbers.
                   2111: When generating a private key, various symbols will be output to
                   2112: indicate the progress of the generation.
                   2113: A
                   2114: .Sq \&.
                   2115: represents each number which has passed an initial sieve test;
                   2116: .Sq +
                   2117: means a number has passed a single round of the Miller-Rabin primality test.
                   2118: A newline means that the number has passed all the prime tests
                   2119: .Pq the actual number depends on the key size .
                   2120: .Pp
                   2121: Because key generation is a random process,
                   2122: the time taken to generate a key may vary somewhat.
                   2123: .Sh GENRSA BUGS
                   2124: A quirk of the prime generation algorithm is that it cannot generate small
                   2125: primes.
                   2126: Therefore the number of bits should not be less that 64.
                   2127: For typical private keys this will not matter because for security reasons
                   2128: they will be much larger
                   2129: .Pq typically 2048 bits .
                   2130: .\"
                   2131: .\" NSEQ
                   2132: .\"
                   2133: .Sh NSEQ
                   2134: .Nm openssl nseq
                   2135: .Op Fl in Ar file
                   2136: .Op Fl out Ar file
                   2137: .Op Fl toseq
                   2138: .Pp
                   2139: The
                   2140: .Nm nseq
                   2141: command takes a file containing a Netscape certificate
                   2142: sequence and prints out the certificates contained in it or takes a
                   2143: file of certificates and converts it into a Netscape certificate
                   2144: sequence.
                   2145: .Pp
                   2146: The options are as follows:
                   2147: .Bl -tag -width Ds
                   2148: .It Fl in Ar file
                   2149: This specifies the input
                   2150: .Ar file
                   2151: to read, or standard input if this option is not specified.
                   2152: .It Fl out Ar file
                   2153: Specifies the output
                   2154: .Ar file ,
                   2155: or standard output by default.
                   2156: .It Fl toseq
                   2157: Normally, a Netscape certificate sequence will be input and the output
                   2158: is the certificates contained in it.
                   2159: With the
                   2160: .Fl toseq
                   2161: option the situation is reversed:
                   2162: a Netscape certificate sequence is created from a file of certificates.
                   2163: .El
                   2164: .Sh NSEQ EXAMPLES
                   2165: Output the certificates in a Netscape certificate sequence:
                   2166: .Bd -literal -offset indent
                   2167: $ openssl nseq -in nseq.pem -out certs.pem
                   2168: .Ed
                   2169: .Pp
                   2170: Create a Netscape certificate sequence:
                   2171: .Bd -literal -offset indent
                   2172: $ openssl nseq -in certs.pem -toseq -out nseq.pem
                   2173: .Ed
                   2174: .Sh NSEQ NOTES
                   2175: The PEM-encoded form uses the same headers and footers as a certificate:
                   2176: .Bd -unfilled -offset indent
                   2177: -----BEGIN CERTIFICATE-----
                   2178: -----END CERTIFICATE-----
                   2179: .Ed
                   2180: .Pp
                   2181: A Netscape certificate sequence is a Netscape specific form that can be sent
                   2182: to browsers as an alternative to the standard PKCS#7 format when several
                   2183: certificates are sent to the browser:
                   2184: for example during certificate enrollment.
                   2185: It is used by the Netscape certificate server, for example.
                   2186: .Sh NSEQ BUGS
                   2187: This program needs a few more options,
                   2188: like allowing DER or PEM input and output files
                   2189: and allowing multiple certificate files to be used.
                   2190: .\"
                   2191: .\" OCSP
                   2192: .\"
                   2193: .Sh OCSP
                   2194: .nr nS 1
                   2195: .Nm "openssl ocsp"
                   2196: .Bk -words
                   2197: .Op Fl CA Ar file
                   2198: .Op Fl CAfile Ar file
                   2199: .Op Fl CApath Ar directory
                   2200: .Op Fl cert Ar file
                   2201: .Op Fl dgst Ar alg
                   2202: .Oo
                   2203: .Fl host
                   2204: .Ar hostname : Ns Ar port
                   2205: .Oc
                   2206: .Op Fl index Ar indexfile
                   2207: .Op Fl issuer Ar file
                   2208: .Op Fl ndays Ar days
                   2209: .Op Fl nmin Ar minutes
                   2210: .Op Fl no_cert_checks
                   2211: .Op Fl no_cert_verify
                   2212: .Op Fl no_certs
                   2213: .Op Fl no_chain
                   2214: .Op Fl no_intern
                   2215: .Op Fl no_nonce
                   2216: .Op Fl no_signature_verify
                   2217: .Op Fl nonce
                   2218: .Op Fl noverify
                   2219: .Op Fl nrequest Ar number
                   2220: .Op Fl out Ar file
                   2221: .Op Fl path Ar path
                   2222: .Op Fl port Ar portnum
                   2223: .Op Fl req_text
                   2224: .Op Fl reqin Ar file
                   2225: .Op Fl reqout Ar file
                   2226: .Op Fl resp_key_id
                   2227: .Op Fl resp_no_certs
                   2228: .Op Fl resp_text
                   2229: .Op Fl respin Ar file
                   2230: .Op Fl respout Ar file
                   2231: .Op Fl rkey Ar file
                   2232: .Op Fl rother Ar file
                   2233: .Op Fl rsigner Ar file
                   2234: .Op Fl serial Ar number
                   2235: .Op Fl sign_other Ar file
                   2236: .Op Fl signer Ar file
                   2237: .Op Fl signkey Ar file
                   2238: .Op Fl status_age Ar age
                   2239: .Op Fl text
                   2240: .Op Fl trust_other
                   2241: .Op Fl url Ar responder_url
                   2242: .Op Fl VAfile Ar file
                   2243: .Op Fl validity_period Ar nsec
                   2244: .Op Fl verify_other Ar file
                   2245: .Ek
                   2246: .nr nS 0
                   2247: .Pp
                   2248: The Online Certificate Status Protocol
                   2249: .Pq OCSP
                   2250: enables applications to determine the
                   2251: .Pq revocation
                   2252: state of an identified certificate
                   2253: .Pq RFC 2560 .
                   2254: .Pp
                   2255: The
                   2256: .Nm ocsp
                   2257: command performs many common OCSP tasks.
                   2258: It can be used to print out requests and responses,
                   2259: create requests and send queries to an OCSP responder,
                   2260: and behave like a mini OCSP server itself.
                   2261: .Pp
                   2262: The options are as follows:
                   2263: .Bl -tag -width Ds
                   2264: .It Fl CAfile Ar file , Fl CApath Ar directory
                   2265: .Ar file
                   2266: or
                   2267: .Ar path
                   2268: containing trusted CA certificates.
                   2269: These are used to verify the signature on the OCSP response.
                   2270: .It Fl cert Ar file
                   2271: Add the certificate
                   2272: .Ar file
                   2273: to the request.
                   2274: The issuer certificate is taken from the previous
                   2275: .Fl issuer
                   2276: option, or an error occurs if no issuer certificate is specified.
                   2277: .It Fl dgst Ar alg
                   2278: Sets the digest algorithm to use for certificate identification
                   2279: in the OCSP request.
                   2280: By default SHA-1 is used.
                   2281: .It Xo
                   2282: .Fl host Ar hostname : Ns Ar port ,
                   2283: .Fl path Ar path
                   2284: .Xc
                   2285: If the
                   2286: .Fl host
                   2287: option is present, then the OCSP request is sent to the host
                   2288: .Ar hostname
                   2289: on port
                   2290: .Ar port .
                   2291: .Fl path
                   2292: specifies the HTTP path name to use, or
                   2293: .Sq /
                   2294: by default.
                   2295: .It Fl issuer Ar file
                   2296: This specifies the current issuer certificate.
                   2297: This option can be used multiple times.
                   2298: The certificate specified in
                   2299: .Ar file
                   2300: must be in PEM format.
                   2301: This option
                   2302: .Em must
                   2303: come before any
                   2304: .Fl cert
                   2305: options.
                   2306: .It Fl no_cert_checks
                   2307: Don't perform any additional checks on the OCSP response signer's certificate.
                   2308: That is, do not make any checks to see if the signer's certificate is
                   2309: authorised to provide the necessary status information:
                   2310: as a result this option should only be used for testing purposes.
                   2311: .It Fl no_cert_verify
                   2312: Don't verify the OCSP response signer's certificate at all.
                   2313: Since this option allows the OCSP response to be signed by any certificate,
                   2314: it should only be used for testing purposes.
                   2315: .It Fl no_certs
                   2316: Don't include any certificates in signed request.
                   2317: .It Fl no_chain
                   2318: Do not use certificates in the response as additional untrusted CA
                   2319: certificates.
                   2320: .It Fl no_intern
                   2321: Ignore certificates contained in the OCSP response
                   2322: when searching for the signer's certificate.
                   2323: With this option, the signer's certificate must be specified with either the
                   2324: .Fl verify_other
                   2325: or
                   2326: .Fl VAfile
                   2327: options.
                   2328: .It Fl no_signature_verify
                   2329: Don't check the signature on the OCSP response.
                   2330: Since this option tolerates invalid signatures on OCSP responses,
                   2331: it will normally only be used for testing purposes.
                   2332: .It Fl nonce , no_nonce
                   2333: Add an OCSP
                   2334: .Em nonce
                   2335: extension to a request or disable an OCSP
                   2336: .Em nonce
                   2337: addition.
                   2338: Normally, if an OCSP request is input using the
                   2339: .Fl respin
                   2340: option no
                   2341: .Em nonce
                   2342: is added:
                   2343: using the
                   2344: .Fl nonce
                   2345: option will force addition of a
                   2346: .Em nonce .
                   2347: If an OCSP request is being created (using the
                   2348: .Fl cert
                   2349: and
                   2350: .Fl serial
                   2351: options)
                   2352: a
                   2353: .Em nonce
                   2354: is automatically added; specifying
                   2355: .Fl no_nonce
                   2356: overrides this.
                   2357: .It Fl noverify
                   2358: Don't attempt to verify the OCSP response signature or the
                   2359: .Em nonce
                   2360: values.
                   2361: This option will normally only be used for debugging
                   2362: since it disables all verification of the responder's certificate.
                   2363: .It Fl out Ar file
                   2364: Specify output
                   2365: .Ar file ;
                   2366: default is standard output.
                   2367: .It Fl req_text , resp_text , text
                   2368: Print out the text form of the OCSP request, response, or both, respectively.
                   2369: .It Fl reqin Ar file , Fl respin Ar file
                   2370: Read an OCSP request or response file from
                   2371: .Ar file .
                   2372: These options are ignored
                   2373: if an OCSP request or response creation is implied by other options
                   2374: (for example with the
                   2375: .Fl serial , cert ,
                   2376: and
                   2377: .Fl host
                   2378: options).
                   2379: .It Fl reqout Ar file , Fl respout Ar file
                   2380: Write out the DER-encoded certificate request or response to
                   2381: .Ar file .
                   2382: .It Fl serial Ar num
                   2383: Same as the
                   2384: .Fl cert
                   2385: option except the certificate with serial number
                   2386: .Ar num
                   2387: is added to the request.
                   2388: The serial number is interpreted as a decimal integer unless preceded by
                   2389: .Sq 0x .
                   2390: Negative integers can also be specified by preceding the value with a
                   2391: .Sq -
                   2392: sign.
                   2393: .It Fl sign_other Ar file
                   2394: Additional certificates to include in the signed request.
                   2395: .It Fl signer Ar file , Fl signkey Ar file
                   2396: Sign the OCSP request using the certificate specified in the
                   2397: .Fl signer
                   2398: option and the private key specified by the
                   2399: .Fl signkey
                   2400: option.
                   2401: If the
                   2402: .Fl signkey
                   2403: option is not present, then the private key is read from the same file
                   2404: as the certificate.
                   2405: If neither option is specified, the OCSP request is not signed.
                   2406: .It Fl trust_other
                   2407: The certificates specified by the
                   2408: .Fl verify_other
                   2409: option should be explicitly trusted and no additional checks will be
                   2410: performed on them.
                   2411: This is useful when the complete responder certificate chain is not available
                   2412: or trusting a root CA is not appropriate.
                   2413: .It Fl url Ar responder_url
                   2414: Specify the responder URL.
                   2415: Both HTTP and HTTPS
                   2416: .Pq SSL/TLS
                   2417: URLs can be specified.
                   2418: .It Fl VAfile Ar file
                   2419: .Ar file
                   2420: containing explicitly trusted responder certificates.
                   2421: Equivalent to the
                   2422: .Fl verify_other
                   2423: and
                   2424: .Fl trust_other
                   2425: options.
                   2426: .It Fl validity_period Ar nsec , Fl status_age Ar age
                   2427: These options specify the range of times, in seconds, which will be tolerated
                   2428: in an OCSP response.
                   2429: Each certificate status response includes a
                   2430: .Em notBefore
                   2431: time and an optional
                   2432: .Em notAfter
                   2433: time.
                   2434: The current time should fall between these two values,
                   2435: but the interval between the two times may be only a few seconds.
                   2436: In practice the OCSP responder and clients' clocks may not be precisely
                   2437: synchronised and so such a check may fail.
                   2438: To avoid this the
                   2439: .Fl validity_period
                   2440: option can be used to specify an acceptable error range in seconds,
                   2441: the default value is 5 minutes.
                   2442: .Pp
                   2443: If the
                   2444: .Em notAfter
                   2445: time is omitted from a response, then this means that new status
                   2446: information is immediately available.
                   2447: In this case the age of the
                   2448: .Em notBefore
                   2449: field is checked to see it is not older than
                   2450: .Ar age
                   2451: seconds old.
                   2452: By default, this additional check is not performed.
                   2453: .It Fl verify_other Ar file
                   2454: .Ar file
                   2455: containing additional certificates to search when attempting to locate
                   2456: the OCSP response signing certificate.
                   2457: Some responders omit the actual signer's certificate from the response;
                   2458: this option can be used to supply the necessary certificate in such cases.
                   2459: .El
                   2460: .Sh OCSP SERVER OPTIONS
                   2461: .Bl -tag -width "XXXX"
                   2462: .It Fl CA Ar file
                   2463: CA certificate corresponding to the revocation information in
                   2464: .Ar indexfile .
                   2465: .It Fl index Ar indexfile
                   2466: .Ar indexfile
                   2467: is a text index file in
                   2468: .Nm ca
                   2469: format containing certificate revocation information.
                   2470: .Pp
                   2471: If the
                   2472: .Fl index
                   2473: option is specified, the
                   2474: .Nm ocsp
                   2475: utility is in
                   2476: .Em responder
                   2477: mode, otherwise it is in
                   2478: .Em client
                   2479: mode.
                   2480: The request(s) the responder processes can be either specified on
                   2481: the command line (using the
                   2482: .Fl issuer
                   2483: and
                   2484: .Fl serial
                   2485: options), supplied in a file (using the
                   2486: .Fl respin
                   2487: option) or via external OCSP clients (if
                   2488: .Ar port
                   2489: or
                   2490: .Ar url
                   2491: is specified).
                   2492: .Pp
                   2493: If the
                   2494: .Fl index
                   2495: option is present, then the
                   2496: .Fl CA
                   2497: and
                   2498: .Fl rsigner
                   2499: options must also be present.
                   2500: .It Fl nmin Ar minutes , Fl ndays Ar days
                   2501: Number of
                   2502: .Ar minutes
                   2503: or
                   2504: .Ar days
                   2505: when fresh revocation information is available: used in the
                   2506: .Ar nextUpdate
                   2507: field.
                   2508: If neither option is present, the
                   2509: .Em nextUpdate
                   2510: field is omitted, meaning fresh revocation information is immediately available.
                   2511: .It Fl nrequest Ar number
                   2512: The OCSP server will exit after receiving
                   2513: .Ar number
                   2514: requests, default unlimited.
                   2515: .It Fl port Ar portnum
                   2516: Port to listen for OCSP requests on.
                   2517: The port may also be specified using the
                   2518: .Fl url
                   2519: option.
                   2520: .It Fl resp_key_id
                   2521: Identify the signer certificate using the key ID;
                   2522: default is to use the subject name.
                   2523: .It Fl resp_no_certs
                   2524: Don't include any certificates in the OCSP response.
                   2525: .It Fl rkey Ar file
                   2526: The private key to sign OCSP responses with;
                   2527: if not present, the file specified in the
                   2528: .Fl rsigner
                   2529: option is used.
                   2530: .It Fl rother Ar file
                   2531: Additional certificates to include in the OCSP response.
                   2532: .It Fl rsigner Ar file
                   2533: The certificate to sign OCSP responses with.
                   2534: .El
                   2535: .Sh OCSP RESPONSE VERIFICATION
                   2536: OCSP Response follows the rules specified in RFC 2560.
                   2537: .Pp
                   2538: Initially the OCSP responder certificate is located and the signature on
                   2539: the OCSP request checked using the responder certificate's public key.
                   2540: .Pp
                   2541: Then a normal certificate verify is performed on the OCSP responder certificate
                   2542: building up a certificate chain in the process.
                   2543: The locations of the trusted certificates used to build the chain can be
                   2544: specified by the
                   2545: .Fl CAfile
                   2546: and
                   2547: .Fl CApath
                   2548: options or they will be looked for in the standard
                   2549: .Nm OpenSSL
                   2550: certificates
                   2551: directory.
                   2552: .Pp
                   2553: If the initial verify fails, the OCSP verify process halts with an
                   2554: error.
                   2555: .Pp
                   2556: Otherwise the issuing CA certificate in the request is compared to the OCSP
                   2557: responder certificate: if there is a match then the OCSP verify succeeds.
                   2558: .Pp
                   2559: Otherwise the OCSP responder certificate's CA is checked against the issuing
                   2560: CA certificate in the request.
                   2561: If there is a match and the OCSPSigning extended key usage is present
                   2562: in the OCSP responder certificate, then the OCSP verify succeeds.
                   2563: .Pp
                   2564: Otherwise the root CA of the OCSP responder's CA is checked to see if it
                   2565: is trusted for OCSP signing.
                   2566: If it is, the OCSP verify succeeds.
                   2567: .Pp
                   2568: If none of these checks is successful, the OCSP verify fails.
                   2569: .Pp
                   2570: What this effectively means is that if the OCSP responder certificate is
                   2571: authorised directly by the CA it is issuing revocation information about
                   2572: .Pq and it is correctly configured ,
                   2573: then verification will succeed.
                   2574: .Pp
                   2575: If the OCSP responder is a
                   2576: .Em global responder
                   2577: which can give details about multiple CAs and has its own separate
                   2578: certificate chain, then its root CA can be trusted for OCSP signing.
                   2579: For example:
                   2580: .Bd -literal -offset indent
                   2581: $ openssl x509 -in ocspCA.pem -addtrust OCSPSigning \e
                   2582:        -out trustedCA.pem
                   2583: .Ed
                   2584: .Pp
                   2585: Alternatively, the responder certificate itself can be explicitly trusted
                   2586: with the
                   2587: .Fl VAfile
                   2588: option.
                   2589: .Sh OCSP NOTES
                   2590: As noted, most of the verify options are for testing or debugging purposes.
                   2591: Normally, only the
                   2592: .Fl CApath , CAfile
                   2593: and
                   2594: .Pq if the responder is a `global VA'
                   2595: .Fl VAfile
                   2596: options need to be used.
                   2597: .Pp
                   2598: The OCSP server is only useful for test and demonstration purposes:
                   2599: it is not really usable as a full OCSP responder.
                   2600: It contains only a very simple HTTP request handling and can only handle
                   2601: the POST form of OCSP queries.
                   2602: It also handles requests serially, meaning it cannot respond to
                   2603: new requests until it has processed the current one.
                   2604: The text index file format of revocation is also inefficient for large
                   2605: quantities of revocation data.
                   2606: .Pp
                   2607: It is possible to run the
                   2608: .Nm ocsp
                   2609: application in
                   2610: .Em responder
                   2611: mode via a CGI script using the
                   2612: .Fl respin
                   2613: and
                   2614: .Fl respout
                   2615: options.
                   2616: .Sh OCSP EXAMPLES
                   2617: Create an OCSP request and write it to a file:
                   2618: .Bd -literal -offset indent
                   2619: $ openssl ocsp -issuer issuer.pem -cert c1.pem -cert c2.pem \e
                   2620:        -reqout req.der
                   2621: .Ed
                   2622: .Pp
                   2623: Send a query to an OCSP responder with URL
                   2624: .Pa http://ocsp.myhost.com/ ,
                   2625: save the response to a file and print it out in text form:
                   2626: .Bd -literal -offset indent
                   2627: $ openssl ocsp -issuer issuer.pem -cert c1.pem -cert c2.pem \e
                   2628:        -url http://ocsp.myhost.com/ -resp_text -respout resp.der
                   2629: .Ed
                   2630: .Pp
                   2631: Read in an OCSP response and print out in text form:
                   2632: .Pp
                   2633: .Dl $ openssl ocsp -respin resp.der -text
                   2634: .Pp
                   2635: OCSP server on port 8888 using a standard
                   2636: .Nm ca
                   2637: configuration, and a separate responder certificate.
                   2638: All requests and responses are printed to a file:
                   2639: .Bd -literal -offset indent
                   2640: $ openssl ocsp -index demoCA/index.txt -port 8888 -rsigner \e
                   2641:        rcert.pem -CA demoCA/cacert.pem -text -out log.txt
                   2642: .Ed
                   2643: .Pp
                   2644: As above, but exit after processing one request:
                   2645: .Bd -literal -offset indent
                   2646: $ openssl ocsp -index demoCA/index.txt -port 8888 -rsigner \e
                   2647:        rcert.pem -CA demoCA/cacert.pem -nrequest 1
                   2648: .Ed
                   2649: .Pp
                   2650: Query status information using internally generated request:
                   2651: .Bd -literal -offset indent
                   2652: $ openssl ocsp -index demoCA/index.txt -rsigner rcert.pem -CA \e
                   2653:        demoCA/cacert.pem -issuer demoCA/cacert.pem -serial 1
                   2654: .Ed
                   2655: .Pp
                   2656: Query status information using request read from a file and write
                   2657: the response to a second file:
                   2658: .Bd -literal -offset indent
                   2659: $ openssl ocsp -index demoCA/index.txt -rsigner rcert.pem -CA \e
                   2660:        demoCA/cacert.pem -reqin req.der -respout resp.der
                   2661: .Ed
                   2662: .\"
                   2663: .\" PASSWD
                   2664: .\"
                   2665: .Sh PASSWD
                   2666: .nr nS 1
                   2667: .Nm "openssl passwd"
                   2668: .Op Fl 1 | apr1 | crypt
                   2669: .Op Fl in Ar file
                   2670: .Op Fl noverify
                   2671: .Op Fl quiet
                   2672: .Op Fl reverse
                   2673: .Op Fl salt Ar string
                   2674: .Op Fl stdin
                   2675: .Op Fl table
                   2676: .Op Ar password
                   2677: .nr nS 0
                   2678: .Pp
                   2679: The
                   2680: .Nm passwd
                   2681: command computes the hash of a password typed at run-time
                   2682: or the hash of each password in a list.
                   2683: The password list is taken from the named
                   2684: .Ar file
                   2685: for option
                   2686: .Fl in ,
                   2687: from stdin for option
                   2688: .Fl stdin ,
                   2689: or from the command line, or from the terminal otherwise.
                   2690: The
                   2691: .Ux
                   2692: standard algorithm
                   2693: .Em crypt
                   2694: and the MD5-based
                   2695: .Bx
                   2696: password algorithm
                   2697: .Em 1
                   2698: and its Apache variant
                   2699: .Em apr1
                   2700: are available.
                   2701: .Pp
                   2702: The options are as follows:
                   2703: .Bl -tag -width Ds
                   2704: .It Fl 1
                   2705: Use the MD5 based
                   2706: .Bx
                   2707: password algorithm
                   2708: .Em 1 .
                   2709: .It Fl apr1
                   2710: Use the
                   2711: .Em apr1
                   2712: algorithm
                   2713: .Pq Apache variant of the
                   2714: .Bx
                   2715: algorithm.
                   2716: .It Fl crypt
                   2717: Use the
                   2718: .Em crypt
                   2719: algorithm
                   2720: .Pq default .
                   2721: .It Fl in Ar file
                   2722: Read passwords from
                   2723: .Ar file .
                   2724: .It Fl noverify
                   2725: Don't verify when reading a password from the terminal.
                   2726: .It Fl quiet
                   2727: Don't output warnings when passwords given on the command line are truncated.
                   2728: .It Fl reverse
                   2729: Switch table columns.
                   2730: This only makes sense in conjunction with the
                   2731: .Fl table
                   2732: option.
                   2733: .It Fl salt Ar string
                   2734: Use the specified
                   2735: .Ar salt .
                   2736: When reading a password from the terminal, this implies
                   2737: .Fl noverify .
                   2738: .It Fl stdin
                   2739: Read passwords from
                   2740: .Em stdin .
                   2741: .It Fl table
                   2742: In the output list, prepend the cleartext password and a TAB character
                   2743: to each password hash.
                   2744: .El
                   2745: .Sh PASSWD EXAMPLES
                   2746: .Dl $ openssl passwd -crypt -salt xx password
                   2747: prints
                   2748: .Qq xxj31ZMTZzkVA .
                   2749: .Pp
                   2750: .Dl $ openssl passwd -1 -salt xxxxxxxx password
                   2751: prints
                   2752: .Qq $1$xxxxxxxx$UYCIxa628.9qXjpQCjM4a. .
                   2753: .Pp
                   2754: .Dl $ openssl passwd -apr1 -salt xxxxxxxx password
                   2755: prints
                   2756: .Qq $apr1$xxxxxxxx$dxHfLAsjHkDRmG83UXe8K0 .
                   2757: .\"
                   2758: .\" PKCS7
                   2759: .\"
                   2760: .Sh PKCS7
                   2761: .nr nS 1
                   2762: .Nm "openssl pkcs7"
                   2763: .Bk -words
                   2764: .Op Fl in Ar file
                   2765: .Op Fl inform Ar DER | PEM
                   2766: .Op Fl noout
                   2767: .Op Fl out Ar file
                   2768: .Op Fl outform Ar DER | PEM
                   2769: .Op Fl print_certs
                   2770: .Op Fl text
                   2771: .Ek
                   2772: .nr nS 0
                   2773: .Pp
                   2774: The
                   2775: .Nm pkcs7
                   2776: command processes PKCS#7 files in DER or PEM format.
                   2777: .Pp
                   2778: The options are as follows:
                   2779: .Bl -tag -width Ds
                   2780: .It Fl in Ar file
                   2781: This specifies the input
                   2782: .Ar file
                   2783: to read from, or standard input if this option is not specified.
                   2784: .It Fl inform Ar DER | PEM
                   2785: This specifies the input format.
                   2786: .Ar DER
                   2787: format is a DER-encoded PKCS#7 v1.5 structure.
                   2788: .Ar PEM
                   2789: .Pq the default
                   2790: is a base64-encoded version of the DER form with header and footer lines.
                   2791: .It Fl noout
                   2792: Don't output the encoded version of the PKCS#7 structure
                   2793: (or certificates if
                   2794: .Fl print_certs
                   2795: is set).
                   2796: .It Fl out Ar file
                   2797: Specifies the output
                   2798: .Ar file
                   2799: to write to, or standard output by default.
                   2800: .It Fl outform Ar DER | PEM
                   2801: This specifies the output format; the options have the same meaning as the
                   2802: .Fl inform
                   2803: option.
                   2804: .It Fl print_certs
                   2805: Prints out any certificates or CRLs contained in the file.
                   2806: They are preceded by their subject and issuer names in a one-line format.
                   2807: .It Fl text
                   2808: Prints out certificate details in full rather than just subject and
                   2809: issuer names.
                   2810: .El
                   2811: .Sh PKCS7 EXAMPLES
                   2812: Convert a PKCS#7 file from PEM to DER:
                   2813: .Pp
                   2814: .Dl $ openssl pkcs7 -in file.pem -outform DER -out file.der
                   2815: .Pp
                   2816: Output all certificates in a file:
                   2817: .Pp
                   2818: .Dl $ openssl pkcs7 -in file.pem -print_certs -out certs.pem
                   2819: .Sh PKCS7 NOTES
                   2820: The PEM PKCS#7 format uses the header and footer lines:
                   2821: .Bd -unfilled -offset indent
                   2822: -----BEGIN PKCS7-----
                   2823: -----END PKCS7-----
                   2824: .Ed
                   2825: .Pp
                   2826: For compatibility with some CAs it will also accept:
                   2827: .Bd -unfilled -offset indent
                   2828: -----BEGIN CERTIFICATE-----
                   2829: -----END CERTIFICATE-----
                   2830: .Ed
                   2831: .Sh PKCS7 RESTRICTIONS
                   2832: There is no option to print out all the fields of a PKCS#7 file.
                   2833: .Pp
                   2834: The PKCS#7 routines only understand PKCS#7 v 1.5 as specified in RFC 2315.
                   2835: They cannot currently parse, for example, the new CMS as described in RFC 2630.
                   2836: .\"
                   2837: .\" PKCS8
                   2838: .\"
                   2839: .Sh PKCS8
                   2840: .nr nS 1
                   2841: .Nm "openssl pkcs8"
                   2842: .Bk -words
                   2843: .Op Fl embed
                   2844: .Op Fl in Ar file
                   2845: .Op Fl inform Ar DER | PEM
                   2846: .Op Fl nocrypt
                   2847: .Op Fl noiter
                   2848: .Op Fl nooct
                   2849: .Op Fl nsdb
                   2850: .Op Fl out Ar file
                   2851: .Op Fl outform Ar DER | PEM
                   2852: .Op Fl passin Ar arg
                   2853: .Op Fl passout Ar arg
                   2854: .Op Fl topk8
                   2855: .Op Fl v1 Ar alg
                   2856: .Op Fl v2 Ar alg
                   2857: .Ek
                   2858: .nr nS 0
                   2859: .Pp
                   2860: The
                   2861: .Nm pkcs8
                   2862: command processes private keys in PKCS#8 format.
                   2863: It can handle both unencrypted PKCS#8 PrivateKeyInfo format
                   2864: and EncryptedPrivateKeyInfo format with a variety of PKCS#5
                   2865: .Pq v1.5 and v2.0
                   2866: and PKCS#12 algorithms.
                   2867: .Pp
                   2868: The options are as follows:
                   2869: .Bl -tag -width Ds
                   2870: .It Fl embed
                   2871: This option generates DSA keys in a broken format.
                   2872: The DSA parameters are embedded inside the
                   2873: .Em PrivateKey
                   2874: structure.
                   2875: In this form the OCTET STRING contains an ASN1 SEQUENCE consisting of
                   2876: two structures:
                   2877: a SEQUENCE containing the parameters and an ASN1 INTEGER containing
                   2878: the private key.
                   2879: .It Fl in Ar file
                   2880: This specifies the input
                   2881: .Ar file
                   2882: to read a key from, or standard input if this option is not specified.
                   2883: If the key is encrypted, a pass phrase will be prompted for.
                   2884: .It Fl inform Ar DER | PEM
                   2885: This specifies the input format.
                   2886: If a PKCS#8 format key is expected on input,
                   2887: then either a
                   2888: DER- or PEM-encoded version of a PKCS#8 key will be expected.
                   2889: Otherwise the DER or PEM format of the traditional format private key is used.
                   2890: .It Fl nocrypt
                   2891: PKCS#8 keys generated or input are normally PKCS#8
                   2892: .Em EncryptedPrivateKeyInfo
                   2893: structures using an appropriate password-based encryption algorithm.
                   2894: With this option, an unencrypted
                   2895: .Em PrivateKeyInfo
                   2896: structure is expected or output.
                   2897: This option does not encrypt private keys at all and should only be used
                   2898: when absolutely necessary.
                   2899: Certain software such as some versions of Java code signing software use
                   2900: unencrypted private keys.
                   2901: .It Fl noiter
                   2902: Use an iteration count of 1.
                   2903: See the
                   2904: .Sx PKCS12
                   2905: section below for a detailed explanation of this option.
                   2906: .It Fl nooct
                   2907: This option generates RSA private keys in a broken format that some software
                   2908: uses.
                   2909: Specifically the private key should be enclosed in an OCTET STRING,
                   2910: but some software just includes the structure itself without the
                   2911: surrounding OCTET STRING.
                   2912: .It Fl nsdb
                   2913: This option generates DSA keys in a broken format compatible with Netscape
                   2914: private key databases.
                   2915: The
                   2916: .Em PrivateKey
                   2917: contains a SEQUENCE consisting of the public and private keys, respectively.
                   2918: .It Fl out Ar file
                   2919: This specifies the output
                   2920: .Ar file
                   2921: to write a key to, or standard output by default.
                   2922: If any encryption options are set, a pass phrase will be prompted for.
                   2923: The output filename should
                   2924: .Em not
                   2925: be the same as the input filename.
                   2926: .It Fl outform Ar DER | PEM
                   2927: This specifies the output format; the options have the same meaning as the
                   2928: .Fl inform
                   2929: option.
                   2930: .It Fl passin Ar arg
                   2931: The key password source.
                   2932: .It Fl passout Ar arg
                   2933: The output file password source.
                   2934: .It Fl topk8
                   2935: Normally, a PKCS#8 private key is expected on input and a traditional format
                   2936: private key will be written.
                   2937: With the
                   2938: .Fl topk8
                   2939: option the situation is reversed:
                   2940: it reads a traditional format private key and writes a PKCS#8 format key.
                   2941: .It Fl v1 Ar alg
                   2942: This option specifies a PKCS#5 v1.5 or PKCS#12 algorithm to use.
                   2943: A complete list of possible algorithms is included below.
                   2944: .It Fl v2 Ar alg
                   2945: This option enables the use of PKCS#5 v2.0 algorithms.
                   2946: Normally, PKCS#8 private keys are encrypted with the password-based
                   2947: encryption algorithm called
                   2948: .Em pbeWithMD5AndDES-CBC ;
                   2949: this uses 56-bit DES encryption but it was the strongest encryption
                   2950: algorithm supported in PKCS#5 v1.5.
                   2951: Using the
                   2952: .Fl v2
                   2953: option PKCS#5 v2.0 algorithms are used which can use any
                   2954: encryption algorithm such as 168-bit triple DES or 128-bit RC2, however
                   2955: not many implementations support PKCS#5 v2.0 yet.
                   2956: If using private keys with
                   2957: .Nm OpenSSL
                   2958: then this doesn't matter.
                   2959: .Pp
                   2960: The
                   2961: .Ar alg
                   2962: argument is the encryption algorithm to use; valid values include
                   2963: .Ar des , des3 ,
                   2964: and
                   2965: .Ar rc2 .
                   2966: It is recommended that
                   2967: .Ar des3
                   2968: is used.
                   2969: .El
                   2970: .Sh PKCS8 NOTES
                   2971: The encrypted form of a PEM-encoded PKCS#8 file uses the following
                   2972: headers and footers:
                   2973: .Bd -unfilled -offset indent
                   2974: -----BEGIN ENCRYPTED PRIVATE KEY-----
                   2975: -----END ENCRYPTED PRIVATE KEY-----
                   2976: .Ed
                   2977: .Pp
                   2978: The unencrypted form uses:
                   2979: .Bd -unfilled -offset indent
                   2980: -----BEGIN PRIVATE KEY-----
                   2981: -----END PRIVATE KEY-----
                   2982: .Ed
                   2983: .Pp
                   2984: Private keys encrypted using PKCS#5 v2.0 algorithms and high iteration
                   2985: counts are more secure than those encrypted using the traditional
                   2986: .Nm SSLeay
                   2987: compatible formats.
                   2988: So if additional security is considered important, the keys should be converted.
                   2989: .Pp
                   2990: The default encryption is only 56 bits because this is the encryption
                   2991: that most current implementations of PKCS#8 support.
                   2992: .Pp
                   2993: Some software may use PKCS#12 password-based encryption algorithms
                   2994: with PKCS#8 format private keys: these are handled automatically
                   2995: but there is no option to produce them.
                   2996: .Pp
                   2997: It is possible to write out
                   2998: DER-encoded encrypted private keys in PKCS#8 format because the encryption
                   2999: details are included at an ASN1
                   3000: level whereas the traditional format includes them at a PEM level.
                   3001: .Sh PKCS#5 V1.5 AND PKCS#12 ALGORITHMS
                   3002: Various algorithms can be used with the
                   3003: .Fl v1
                   3004: command line option, including PKCS#5 v1.5 and PKCS#12.
                   3005: These are described in more detail below.
                   3006: .Pp
                   3007: .Bl -tag -width "XXXX" -compact
1.29      bcook    3008: .It Ar PBE-MD5-DES
1.1       jsing    3009: These algorithms were included in the original PKCS#5 v1.5 specification.
                   3010: They only offer 56 bits of protection since they both use DES.
                   3011: .Pp
1.29      bcook    3012: .It Ar PBE-SHA1-RC2-64 | PBE-MD5-RC2-64 | PBE-SHA1-DES
1.1       jsing    3013: These algorithms are not mentioned in the original PKCS#5 v1.5 specification
                   3014: but they use the same key derivation algorithm and are supported by some
                   3015: software.
                   3016: They are mentioned in PKCS#5 v2.0.
                   3017: They use either 64-bit RC2 or 56-bit DES.
                   3018: .Pp
                   3019: .It Ar PBE-SHA1-RC4-128 | PBE-SHA1-RC4-40 | PBE-SHA1-3DES | PBE-SHA1-2DES
                   3020: .It Ar PBE-SHA1-RC2-128 | PBE-SHA1-RC2-40
                   3021: These algorithms use the PKCS#12 password-based encryption algorithm and
                   3022: allow strong encryption algorithms like triple DES or 128-bit RC2 to be used.
                   3023: .El
                   3024: .Sh PKCS8 EXAMPLES
                   3025: Convert a private key from traditional to PKCS#5 v2.0 format using triple DES:
                   3026: .Pp
                   3027: .Dl "$ openssl pkcs8 -in key.pem -topk8 -v2 des3 -out enckey.pem"
                   3028: .Pp
                   3029: Convert a private key to PKCS#8 using a PKCS#5 1.5 compatible algorithm
                   3030: .Pq DES :
                   3031: .Pp
                   3032: .Dl $ openssl pkcs8 -in key.pem -topk8 -out enckey.pem
                   3033: .Pp
                   3034: Convert a private key to PKCS#8 using a PKCS#12 compatible algorithm
                   3035: .Pq 3DES :
                   3036: .Bd -literal -offset indent
                   3037: $ openssl pkcs8 -in key.pem -topk8 -out enckey.pem \e
                   3038:        -v1 PBE-SHA1-3DES
                   3039: .Ed
                   3040: .Pp
                   3041: Read a DER-unencrypted PKCS#8 format private key:
                   3042: .Pp
                   3043: .Dl "$ openssl pkcs8 -inform DER -nocrypt -in key.der -out key.pem"
                   3044: .Pp
                   3045: Convert a private key from any PKCS#8 format to traditional format:
                   3046: .Pp
                   3047: .Dl $ openssl pkcs8 -in pk8.pem -out key.pem
                   3048: .Sh PKCS8 STANDARDS
                   3049: Test vectors from this PKCS#5 v2.0 implementation were posted to the
                   3050: pkcs-tng mailing list using triple DES, DES and RC2 with high iteration counts;
                   3051: several people confirmed that they could decrypt the private
                   3052: keys produced and therefore it can be assumed that the PKCS#5 v2.0
                   3053: implementation is reasonably accurate at least as far as these
                   3054: algorithms are concerned.
                   3055: .Pp
                   3056: The format of PKCS#8 DSA
                   3057: .Pq and other
                   3058: private keys is not well documented:
                   3059: it is hidden away in PKCS#11 v2.01, section 11.9;
                   3060: .Nm OpenSSL Ns Li 's
                   3061: default DSA PKCS#8 private key format complies with this standard.
                   3062: .Sh PKCS8 BUGS
                   3063: There should be an option that prints out the encryption algorithm
                   3064: in use and other details such as the iteration count.
                   3065: .Pp
                   3066: PKCS#8 using triple DES and PKCS#5 v2.0 should be the default private
                   3067: key format; for
                   3068: .Nm OpenSSL
                   3069: compatibility, several of the utilities use the old format at present.
                   3070: .\"
                   3071: .\" PKCS12
                   3072: .\"
                   3073: .Sh PKCS12
                   3074: .nr nS 1
                   3075: .Nm "openssl pkcs12"
                   3076: .Bk -words
                   3077: .Oo
                   3078: .Fl aes128 | aes192 | aes256 |
                   3079: .Fl des | des3
                   3080: .Oc
                   3081: .Op Fl cacerts
                   3082: .Op Fl CAfile Ar file
                   3083: .Op Fl caname Ar name
                   3084: .Op Fl CApath Ar directory
                   3085: .Op Fl certfile Ar file
                   3086: .Op Fl certpbe Ar alg
                   3087: .Op Fl chain
                   3088: .Op Fl clcerts
                   3089: .Op Fl CSP Ar name
                   3090: .Op Fl descert
                   3091: .Op Fl export
                   3092: .Op Fl in Ar file
                   3093: .Op Fl info
                   3094: .Op Fl inkey Ar file
                   3095: .Op Fl keyex
                   3096: .Op Fl keypbe Ar alg
                   3097: .Op Fl keysig
                   3098: .Op Fl macalg Ar alg
                   3099: .Op Fl maciter
                   3100: .Op Fl name Ar name
                   3101: .Op Fl nocerts
                   3102: .Op Fl nodes
                   3103: .Op Fl noiter
                   3104: .Op Fl nokeys
                   3105: .Op Fl nomac
                   3106: .Op Fl nomaciter
                   3107: .Op Fl nomacver
                   3108: .Op Fl noout
                   3109: .Op Fl out Ar file
                   3110: .Op Fl passin Ar arg
                   3111: .Op Fl passout Ar arg
                   3112: .Op Fl twopass
                   3113: .Ek
                   3114: .nr nS 0
                   3115: .Pp
                   3116: The
                   3117: .Nm pkcs12
                   3118: command allows PKCS#12 files
                   3119: .Pq sometimes referred to as PFX files
                   3120: to be created and parsed.
                   3121: PKCS#12 files are used by several programs including Netscape, MSIE
                   3122: and MS Outlook.
                   3123: .Pp
                   3124: There are a lot of options; the meaning of some depends on whether a
                   3125: PKCS#12 file is being created or parsed.
                   3126: By default, a PKCS#12 file is parsed;
                   3127: a PKCS#12 file can be created by using the
                   3128: .Fl export
                   3129: option
                   3130: .Pq see below .
                   3131: .Sh PKCS12 PARSING OPTIONS
                   3132: .Bl -tag -width "XXXX"
                   3133: .It Xo
                   3134: .Fl aes128 | aes192 | aes256 |
                   3135: .Fl des | des3
                   3136: .Xc
                   3137: Use AES, DES, or triple DES, respectively,
                   3138: to encrypt private keys before outputting.
                   3139: The default is triple DES.
                   3140: .It Fl cacerts
                   3141: Only output CA certificates
                   3142: .Pq not client certificates .
                   3143: .It Fl clcerts
                   3144: Only output client certificates
                   3145: .Pq not CA certificates .
                   3146: .It Fl in Ar file
                   3147: This specifies the
                   3148: .Ar file
                   3149: of the PKCS#12 file to be parsed.
                   3150: Standard input is used by default.
                   3151: .It Fl info
                   3152: Output additional information about the PKCS#12 file structure,
                   3153: algorithms used, and iteration counts.
                   3154: .It Fl nocerts
                   3155: No certificates at all will be output.
                   3156: .It Fl nodes
                   3157: Don't encrypt the private keys at all.
                   3158: .It Fl nokeys
                   3159: No private keys will be output.
                   3160: .It Fl nomacver
                   3161: Don't attempt to verify the integrity MAC before reading the file.
                   3162: .It Fl noout
                   3163: This option inhibits output of the keys and certificates to the output file
                   3164: version of the PKCS#12 file.
                   3165: .It Fl out Ar file
                   3166: The
                   3167: .Ar file
                   3168: to write certificates and private keys to, standard output by default.
                   3169: They are all written in PEM format.
                   3170: .It Fl passin Ar arg
                   3171: The key password source.
                   3172: .It Fl passout Ar arg
                   3173: The output file password source.
                   3174: .It Fl twopass
                   3175: Prompt for separate integrity and encryption passwords: most software
                   3176: always assumes these are the same so this option will render such
                   3177: PKCS#12 files unreadable.
                   3178: .El
                   3179: .Sh PKCS12 FILE CREATION OPTIONS
                   3180: .Bl -tag -width "XXXX"
                   3181: .It Fl CAfile Ar file
                   3182: CA storage as a file.
                   3183: .It Fl CApath Ar directory
                   3184: CA storage as a directory.
                   3185: This directory must be a standard certificate directory:
                   3186: that is, a hash of each subject name (using
                   3187: .Cm x509 -hash )
                   3188: should be linked to each certificate.
                   3189: .It Fl caname Ar name
                   3190: This specifies the
                   3191: .Qq friendly name
                   3192: for other certificates.
                   3193: This option may be used multiple times to specify names for all certificates
                   3194: in the order they appear.
                   3195: Netscape ignores friendly names on other certificates,
                   3196: whereas MSIE displays them.
                   3197: .It Fl certfile Ar file
                   3198: A file to read additional certificates from.
                   3199: .It Fl certpbe Ar alg , Fl keypbe Ar alg
                   3200: These options allow the algorithm used to encrypt the private key and
                   3201: certificates to be selected.
                   3202: Any PKCS#5 v1.5 or PKCS#12 PBE algorithm name can be used (see the
                   3203: .Sx PKCS12 NOTES
                   3204: section for more information).
                   3205: If a cipher name
                   3206: (as output by the
                   3207: .Cm list-cipher-algorithms
                   3208: command) is specified then it
                   3209: is used with PKCS#5 v2.0.
                   3210: For interoperability reasons it is advisable to only use PKCS#12 algorithms.
                   3211: .It Fl chain
                   3212: If this option is present, an attempt is made to include the entire
                   3213: certificate chain of the user certificate.
                   3214: The standard CA store is used for this search.
                   3215: If the search fails, it is considered a fatal error.
                   3216: .It Fl CSP Ar name
                   3217: Write
                   3218: .Ar name
                   3219: as a Microsoft CSP name.
                   3220: .It Fl descert
                   3221: Encrypt the certificate using triple DES; this may render the PKCS#12
                   3222: file unreadable by some
                   3223: .Qq export grade
                   3224: software.
                   3225: By default, the private key is encrypted using triple DES and the
                   3226: certificate using 40-bit RC2.
                   3227: .It Fl export
                   3228: This option specifies that a PKCS#12 file will be created rather than
                   3229: parsed.
                   3230: .It Fl in Ar file
                   3231: The
                   3232: .Ar file
                   3233: to read certificates and private keys from, standard input by default.
                   3234: They must all be in PEM format.
                   3235: The order doesn't matter but one private key and its corresponding
                   3236: certificate should be present.
                   3237: If additional certificates are present, they will also be included
                   3238: in the PKCS#12 file.
                   3239: .It Fl inkey Ar file
                   3240: File to read private key from.
                   3241: If not present, a private key must be present in the input file.
                   3242: .It Fl keyex | keysig
                   3243: Specifies that the private key is to be used for key exchange or just signing.
                   3244: This option is only interpreted by MSIE and similar MS software.
                   3245: Normally,
                   3246: .Qq export grade
                   3247: software will only allow 512-bit RSA keys to be
                   3248: used for encryption purposes, but arbitrary length keys for signing.
                   3249: The
                   3250: .Fl keysig
                   3251: option marks the key for signing only.
                   3252: Signing only keys can be used for S/MIME signing, authenticode
                   3253: .Pq ActiveX control signing
                   3254: and SSL client authentication;
                   3255: however, due to a bug only MSIE 5.0 and later support
                   3256: the use of signing only keys for SSL client authentication.
                   3257: .It Fl macalg Ar alg
                   3258: Specify the MAC digest algorithm.
                   3259: If not included then SHA1 is used.
                   3260: .It Fl maciter
                   3261: This option is included for compatibility with previous versions; it used
                   3262: to be needed to use MAC iterations counts but they are now used by default.
                   3263: .It Fl name Ar name
                   3264: This specifies the
                   3265: .Qq friendly name
                   3266: for the certificate and private key.
                   3267: This name is typically displayed in list boxes by software importing the file.
                   3268: .It Fl nomac
                   3269: Don't attempt to provide the MAC integrity.
                   3270: .It Fl nomaciter , noiter
                   3271: These options affect the iteration counts on the MAC and key algorithms.
                   3272: Unless you wish to produce files compatible with MSIE 4.0, you should leave
                   3273: these options alone.
                   3274: .Pp
                   3275: To discourage attacks by using large dictionaries of common passwords,
                   3276: the algorithm that derives keys from passwords can have an iteration count
                   3277: applied to it: this causes a certain part of the algorithm to be repeated
                   3278: and slows it down.
                   3279: The MAC is used to check the file integrity but since it will normally
                   3280: have the same password as the keys and certificates it could also be attacked.
                   3281: By default, both MAC and encryption iteration counts are set to 2048;
                   3282: using these options the MAC and encryption iteration counts can be set to 1.
                   3283: Since this reduces the file security you should not use these options
                   3284: unless you really have to.
                   3285: Most software supports both MAC and key iteration counts.
                   3286: MSIE 4.0 doesn't support MAC iteration counts, so it needs the
                   3287: .Fl nomaciter
                   3288: option.
                   3289: .It Fl out Ar file
                   3290: This specifies
                   3291: .Ar file
                   3292: to write the PKCS#12 file to.
                   3293: Standard output is used by default.
                   3294: .It Fl passin Ar arg
                   3295: The key password source.
                   3296: .It Fl passout Ar arg
                   3297: The output file password source.
                   3298: .El
                   3299: .Sh PKCS12 NOTES
                   3300: Although there are a large number of options,
                   3301: most of them are very rarely used.
                   3302: For PKCS#12 file parsing, only
                   3303: .Fl in
                   3304: and
                   3305: .Fl out
                   3306: need to be used for PKCS#12 file creation.
                   3307: .Fl export
                   3308: and
                   3309: .Fl name
                   3310: are also used.
                   3311: .Pp
                   3312: If none of the
                   3313: .Fl clcerts , cacerts ,
                   3314: or
                   3315: .Fl nocerts
                   3316: options are present, then all certificates will be output in the order
                   3317: they appear in the input PKCS#12 files.
                   3318: There is no guarantee that the first certificate present is
                   3319: the one corresponding to the private key.
                   3320: Certain software which requires a private key and certificate and assumes
                   3321: the first certificate in the file is the one corresponding to the private key:
                   3322: this may not always be the case.
                   3323: Using the
                   3324: .Fl clcerts
                   3325: option will solve this problem by only outputting the certificate
                   3326: corresponding to the private key.
                   3327: If the CA certificates are required, they can be output to a separate
                   3328: file using the
                   3329: .Fl nokeys
                   3330: and
                   3331: .Fl cacerts
                   3332: options to just output CA certificates.
                   3333: .Pp
                   3334: The
                   3335: .Fl keypbe
                   3336: and
                   3337: .Fl certpbe
                   3338: algorithms allow the precise encryption algorithms for private keys
                   3339: and certificates to be specified.
                   3340: Normally, the defaults are fine but occasionally software can't handle
                   3341: triple DES encrypted private keys;
                   3342: then the option
                   3343: .Fl keypbe Ar PBE-SHA1-RC2-40
                   3344: can be used to reduce the private key encryption to 40-bit RC2.
                   3345: A complete description of all algorithms is contained in the
                   3346: .Sx PKCS8
                   3347: section above.
                   3348: .Sh PKCS12 EXAMPLES
                   3349: Parse a PKCS#12 file and output it to a file:
                   3350: .Pp
                   3351: .Dl $ openssl pkcs12 -in file.p12 -out file.pem
                   3352: .Pp
                   3353: Output only client certificates to a file:
                   3354: .Pp
                   3355: .Dl $ openssl pkcs12 -in file.p12 -clcerts -out file.pem
                   3356: .Pp
                   3357: Don't encrypt the private key:
                   3358: .Pp
                   3359: .Dl $ openssl pkcs12 -in file.p12 -out file.pem -nodes
                   3360: .Pp
                   3361: Print some info about a PKCS#12 file:
                   3362: .Pp
                   3363: .Dl $ openssl pkcs12 -in file.p12 -info -noout
                   3364: .Pp
                   3365: Create a PKCS#12 file:
                   3366: .Bd -literal -offset indent
                   3367: $ openssl pkcs12 -export -in file.pem -out file.p12 \e
                   3368:        -name "My Certificate"
                   3369: .Ed
                   3370: .Pp
                   3371: Include some extra certificates:
                   3372: .Bd -literal -offset indent
                   3373: $ openssl pkcs12 -export -in file.pem -out file.p12 \e
                   3374:        -name "My Certificate" -certfile othercerts.pem
                   3375: .Ed
                   3376: .Sh PKCS12 BUGS
                   3377: Some would argue that the PKCS#12 standard is one big bug :\-)
                   3378: .Pp
                   3379: Versions of
                   3380: .Nm OpenSSL
                   3381: before 0.9.6a had a bug in the PKCS#12 key generation routines.
                   3382: Under rare circumstances this could produce a PKCS#12 file encrypted
                   3383: with an invalid key.
                   3384: As a result some PKCS#12 files which triggered this bug
                   3385: from other implementations
                   3386: .Pq MSIE or Netscape
                   3387: could not be decrypted by
                   3388: .Nm OpenSSL
                   3389: and similarly
                   3390: .Nm OpenSSL
                   3391: could produce PKCS#12 files which could not be decrypted by other
                   3392: implementations.
                   3393: The chances of producing such a file are relatively small: less than 1 in 256.
                   3394: .Pp
                   3395: A side effect of fixing this bug is that any old invalidly encrypted PKCS#12
                   3396: files can no longer be parsed by the fixed version.
                   3397: Under such circumstances the
                   3398: .Nm pkcs12
                   3399: utility will report that the MAC is OK but fail with a decryption
                   3400: error when extracting private keys.
                   3401: .Pp
                   3402: This problem can be resolved by extracting the private keys and certificates
                   3403: from the PKCS#12 file using an older version of
                   3404: .Nm OpenSSL
                   3405: and recreating
                   3406: the PKCS#12 file from the keys and certificates using a newer version of
                   3407: .Nm OpenSSL .
                   3408: For example:
                   3409: .Bd -literal -offset indent
                   3410: $ old-openssl -in bad.p12 -out keycerts.pem
                   3411: $ openssl -in keycerts.pem -export -name "My PKCS#12 file" \e
                   3412:        -out fixed.p12
                   3413: .Ed
                   3414: .\"
                   3415: .\" PKEY
                   3416: .\"
                   3417: .Sh PKEY
                   3418: .nr nS 1
                   3419: .Nm "openssl pkey"
                   3420: .Bk -words
                   3421: .Op Ar cipher
                   3422: .Op Fl in Ar file
                   3423: .Op Fl inform Ar DER | PEM
                   3424: .Op Fl noout
                   3425: .Op Fl out Ar file
                   3426: .Op Fl outform Ar DER | PEM
                   3427: .Op Fl passin Ar arg
                   3428: .Op Fl passout Ar arg
                   3429: .Op Fl pubin
                   3430: .Op Fl pubout
                   3431: .Op Fl text
                   3432: .Op Fl text_pub
                   3433: .Ek
                   3434: .nr nS 0
                   3435: .Pp
                   3436: The
                   3437: .Nm pkey
                   3438: command processes public or private keys.
                   3439: They can be converted between various forms
                   3440: and their components printed out.
                   3441: .Pp
                   3442: The options are as follows:
                   3443: .Bl -tag -width Ds
                   3444: .It Ar cipher
                   3445: These options encrypt the private key with the supplied cipher.
                   3446: Any algorithm name accepted by
                   3447: .Fn EVP_get_cipherbyname
                   3448: is acceptable, such as
                   3449: .Cm des3 .
                   3450: .It Fl in Ar file
                   3451: This specifies the input filename to read a key from,
                   3452: or standard input if this option is not specified.
                   3453: If the key is encrypted a pass phrase will be prompted for.
                   3454: .It Fl inform Ar DER | PEM
                   3455: This specifies the input format, DER or PEM.
                   3456: .It Fl noout
                   3457: Do not output the encoded version of the key.
                   3458: .It Fl out Ar file
                   3459: This specifies the output filename to write a key to,
                   3460: or standard output if this option is not specified.
                   3461: If any encryption options are set then a pass phrase
                   3462: will be prompted for.
                   3463: The output filename should
                   3464: .Em not
                   3465: be the same as the input filename.
                   3466: .It Fl outform Ar DER | PEM
                   3467: This specifies the output format;
                   3468: the options have the same meaning as the
                   3469: .Fl inform
                   3470: option.
                   3471: .It Fl passin Ar arg
                   3472: The key password source.
                   3473: .It Fl passout Ar arg
                   3474: The output file password source.
                   3475: .It Fl pubin
                   3476: By default a private key is read from the input file:
                   3477: with this option a public key is read instead.
                   3478: .It Fl pubout
                   3479: By default a private key is output:
                   3480: with this option a public key will be output instead.
                   3481: This option is automatically set if
                   3482: the input is a public key.
                   3483: .It Fl text
                   3484: Print out the various public or private key components in
                   3485: plain text in addition to the encoded version.
                   3486: .It Fl text_pub
                   3487: Print out only public key components
                   3488: even if a private key is being processed.
                   3489: .El
                   3490: .Sh PKEY EXAMPLES
                   3491: To remove the pass phrase on an RSA private key:
                   3492: .Bd -literal -offset indent
                   3493: $ openssl pkey -in key.pem -out keyout.pem
                   3494: .Ed
                   3495: .Pp
                   3496: To encrypt a private key using triple DES:
                   3497: .Bd -literal -offset indent
                   3498: $ openssl pkey -in key.pem -des3 -out keyout.pem
                   3499: .Ed
                   3500: .Pp
                   3501: To convert a private key from PEM to DER format:
                   3502: .Bd -literal -offset indent
                   3503: $ openssl pkey -in key.pem -outform DER -out keyout.der
                   3504: .Ed
                   3505: .Pp
                   3506: To print the components of a private key to standard output:
                   3507: .Bd -literal -offset indent
                   3508: $ openssl pkey -in key.pem -text -noout
                   3509: .Ed
                   3510: .Pp
                   3511: To print the public components of a private key to standard output:
                   3512: .Bd -literal -offset indent
                   3513: $ openssl pkey -in key.pem -text_pub -noout
                   3514: .Ed
                   3515: .Pp
                   3516: To just output the public part of a private key:
                   3517: .Bd -literal -offset indent
                   3518: $ openssl pkey -in key.pem -pubout -out pubkey.pem
                   3519: .Ed
                   3520: .\"
                   3521: .\" PKEYPARAM
                   3522: .\"
                   3523: .Sh PKEYPARAM
                   3524: .Cm openssl pkeyparam
                   3525: .Op Fl in Ar file
                   3526: .Op Fl noout
                   3527: .Op Fl out Ar file
                   3528: .Op Fl text
                   3529: .Pp
                   3530: The
                   3531: .Nm pkey
                   3532: command processes public or private keys.
                   3533: They can be converted between various forms and their components printed out.
                   3534: .Pp
                   3535: The options are as follows:
                   3536: .Bl -tag -width Ds
                   3537: .It Fl in Ar file
                   3538: This specifies the input filename to read parameters from,
                   3539: or standard input if this option is not specified.
                   3540: .It Fl noout
                   3541: Do not output the encoded version of the parameters.
                   3542: .It Fl out Ar file
                   3543: This specifies the output filename to write parameters to,
                   3544: or standard output if this option is not specified.
                   3545: .It Fl text
                   3546: Prints out the parameters in plain text in addition to the encoded version.
                   3547: .El
                   3548: .Sh PKEYPARAM EXAMPLES
                   3549: Print out text version of parameters:
                   3550: .Bd -literal -offset indent
                   3551: $ openssl pkeyparam -in param.pem -text
                   3552: .Ed
                   3553: .Sh PKEYPARAM NOTES
                   3554: There are no
                   3555: .Fl inform
                   3556: or
                   3557: .Fl outform
                   3558: options for this command because only PEM format is supported
                   3559: because the key type is determined by the PEM headers.
                   3560: .\"
                   3561: .\" PKEYUTL
                   3562: .\"
                   3563: .Sh PKEYUTL
                   3564: .nr nS 1
                   3565: .Nm "openssl pkeyutl"
                   3566: .Bk -words
                   3567: .Op Fl asn1parse
                   3568: .Op Fl certin
                   3569: .Op Fl decrypt
                   3570: .Op Fl derive
                   3571: .Op Fl encrypt
                   3572: .Op Fl hexdump
                   3573: .Op Fl in Ar file
                   3574: .Op Fl inkey Ar file
1.22      bcook    3575: .Op Fl keyform Ar DER | PEM
1.1       jsing    3576: .Op Fl out Ar file
                   3577: .Op Fl passin Ar arg
1.22      bcook    3578: .Op Fl peerform Ar DER | PEM
1.1       jsing    3579: .Op Fl peerkey Ar file
                   3580: .Op Fl pkeyopt Ar opt : Ns Ar value
                   3581: .Op Fl pubin
                   3582: .Op Fl rev
                   3583: .Op Fl sigfile Ar file
                   3584: .Op Fl sign
                   3585: .Op Fl verify
                   3586: .Op Fl verifyrecover
                   3587: .Ek
                   3588: .nr nS 0
                   3589: .Pp
                   3590: The
                   3591: .Nm pkeyutl
                   3592: command can be used to perform public key operations using
                   3593: any supported algorithm.
                   3594: .Pp
                   3595: The options are as follows:
                   3596: .Bl -tag -width Ds
                   3597: .It Fl asn1parse
                   3598: ASN1parse the output data.
                   3599: This is useful when combined with the
                   3600: .Fl verifyrecover
                   3601: option when an ASN1 structure is signed.
                   3602: .It Fl certin
                   3603: The input is a certificate containing a public key.
                   3604: .It Fl decrypt
                   3605: Decrypt the input data using a private key.
                   3606: .It Fl derive
                   3607: Derive a shared secret using the peer key.
                   3608: .It Fl encrypt
                   3609: Encrypt the input data using a public key.
                   3610: .It Fl hexdump
                   3611: Hex dump the output data.
                   3612: .It Fl in Ar file
                   3613: Specify the input filename to read data from,
                   3614: or standard input if this option is not specified.
                   3615: .It Fl inkey Ar file
                   3616: The input key file.
                   3617: By default it should be a private key.
1.22      bcook    3618: .It Fl keyform Ar DER | PEM
                   3619: The key format DER or PEM.
1.1       jsing    3620: .It Fl out Ar file
                   3621: Specify the output filename to write to,
                   3622: or standard output by default.
                   3623: .It Fl passin Ar arg
                   3624: The key password source.
1.22      bcook    3625: .It Fl peerform Ar DER | PEM
                   3626: The peer key format DER or PEM.
1.1       jsing    3627: .It Fl peerkey Ar file
                   3628: The peer key file, used by key derivation (agreement) operations.
                   3629: .It Fl pkeyopt Ar opt : Ns Ar value
                   3630: Public key options.
                   3631: .It Fl pubin
                   3632: The input file is a public key.
                   3633: .It Fl rev
                   3634: Reverse the order of the input buffer.
                   3635: This is useful for some libraries (such as CryptoAPI)
                   3636: which represent the buffer in little endian format.
                   3637: .It Fl sigfile Ar file
                   3638: Signature file (verify operation only).
                   3639: .It Fl sign
                   3640: Sign the input data and output the signed result.
                   3641: This requires a private key.
                   3642: .It Fl verify
                   3643: Verify the input data against the signature file and indicate if the
                   3644: verification succeeded or failed.
                   3645: .It Fl verifyrecover
                   3646: Verify the input data and output the recovered data.
                   3647: .El
                   3648: .Sh PKEYUTL NOTES
                   3649: The operations and options supported vary according to the key algorithm
                   3650: and its implementation.
                   3651: The
                   3652: .Nm OpenSSL
                   3653: operations and options are indicated below.
                   3654: .Pp
                   3655: Unless otherwise mentioned all algorithms support the
                   3656: .Ar digest : Ns Ar alg
                   3657: option which specifies the digest in use
                   3658: for sign, verify, and verifyrecover operations.
                   3659: The value
                   3660: .Ar alg
                   3661: should represent a digest name as used in the
                   3662: .Fn EVP_get_digestbyname
                   3663: function, for example
                   3664: .Cm sha1 .
                   3665: .Ss RSA algorithm
                   3666: The RSA algorithm supports the
                   3667: encrypt, decrypt, sign, verify, and verifyrecover operations in general.
                   3668: Some padding modes only support some of these
                   3669: operations however.
                   3670: .Bl -tag -width Ds
                   3671: .It rsa_padding_mode : Ns Ar mode
                   3672: This sets the RSA padding mode.
                   3673: Acceptable values for
                   3674: .Ar mode
                   3675: are
                   3676: .Cm pkcs1
                   3677: for PKCS#1 padding;
                   3678: .Cm none
                   3679: for no padding;
                   3680: .Cm oaep
                   3681: for OAEP mode;
                   3682: .Cm x931
                   3683: for X9.31 mode;
                   3684: and
                   3685: .Cm pss
                   3686: for PSS.
                   3687: .Pp
                   3688: In PKCS#1 padding if the message digest is not set then the supplied data is
                   3689: signed or verified directly instead of using a DigestInfo structure.
                   3690: If a digest is set then a DigestInfo
                   3691: structure is used and its length
                   3692: must correspond to the digest type.
                   3693: .Pp
                   3694: For oeap mode only encryption and decryption is supported.
                   3695: .Pp
                   3696: For x931 if the digest type is set it is used to format the block data;
                   3697: otherwise the first byte is used to specify the X9.31 digest ID.
                   3698: Sign, verify, and verifyrecover can be performed in this mode.
                   3699: .Pp
                   3700: For pss mode only sign and verify are supported and the digest type must be
                   3701: specified.
                   3702: .It rsa_pss_saltlen : Ns Ar len
                   3703: For pss
                   3704: mode only this option specifies the salt length.
                   3705: Two special values are supported:
                   3706: -1 sets the salt length to the digest length.
                   3707: When signing -2 sets the salt length to the maximum permissible value.
                   3708: When verifying -2 causes the salt length to be automatically determined
                   3709: based on the PSS block structure.
                   3710: .El
                   3711: .Ss DSA algorithm
                   3712: The DSA algorithm supports the sign and verify operations.
                   3713: Currently there are no additional options other than
                   3714: .Ar digest .
                   3715: Only the SHA1 digest can be used and this digest is assumed by default.
                   3716: .Ss DH algorithm
                   3717: The DH algorithm supports the derive operation
                   3718: and no additional options.
                   3719: .Ss EC algorithm
                   3720: The EC algorithm supports the sign, verify, and derive operations.
                   3721: The sign and verify operations use ECDSA and derive uses ECDH.
                   3722: Currently there are no additional options other than
                   3723: .Ar digest .
                   3724: Only the SHA1 digest can be used and this digest is assumed by default.
                   3725: .Sh PKEYUTL EXAMPLES
                   3726: Sign some data using a private key:
                   3727: .Bd -literal -offset indent
                   3728: $ openssl pkeyutl -sign -in file -inkey key.pem -out sig
                   3729: .Ed
                   3730: .Pp
                   3731: Recover the signed data (e.g. if an RSA key is used):
                   3732: .Bd -literal -offset indent
                   3733: $ openssl pkeyutl -verifyrecover -in sig -inkey key.pem
                   3734: .Ed
                   3735: .Pp
                   3736: Verify the signature (e.g. a DSA key):
                   3737: .Bd -literal -offset indent
                   3738: $ openssl pkeyutl -verify -in file -sigfile sig \e
                   3739:        -inkey key.pem
                   3740: .Ed
                   3741: .Pp
                   3742: Sign data using a message digest value (this is currently only valid for RSA):
                   3743: .Bd -literal -offset indent
                   3744: $ openssl pkeyutl -sign -in file -inkey key.pem \e
                   3745:        -out sig -pkeyopt digest:sha256
                   3746: .Ed
                   3747: .Pp
                   3748: Derive a shared secret value:
                   3749: .Bd -literal -offset indent
                   3750: $ openssl pkeyutl -derive -inkey key.pem \e
                   3751:        -peerkey pubkey.pem -out secret
                   3752: .Ed
                   3753: .\"
                   3754: .\" PRIME
                   3755: .\"
                   3756: .Sh PRIME
                   3757: .Cm openssl prime
                   3758: .Op Fl bits Ar n
                   3759: .Op Fl checks Ar n
                   3760: .Op Fl generate
                   3761: .Op Fl hex
                   3762: .Op Fl safe
                   3763: .Ar p
                   3764: .Pp
                   3765: The
                   3766: .Nm prime
                   3767: command is used to generate prime numbers,
                   3768: or to check numbers for primality.
                   3769: Results are probabilistic:
                   3770: they have an exceedingly high likelihood of being correct,
                   3771: but are not guaranteed.
                   3772: .Pp
                   3773: The options are as follows:
                   3774: .Bl -tag -width Ds
                   3775: .It Fl bits Ar n
                   3776: Specify the number of bits in the generated prime number.
                   3777: Must be used in conjunction with
                   3778: .Fl generate .
                   3779: .It Fl checks Ar n
                   3780: Perform a Miller-Rabin probabilistic primality test with
                   3781: .Ar n
                   3782: iterations.
                   3783: The default is 20.
                   3784: .It Fl generate
                   3785: Generate a pseudo-random prime number.
                   3786: Must be used in conjunction with
                   3787: .Fl bits .
                   3788: .It Fl hex
                   3789: Output in hex format.
                   3790: .It Fl safe
                   3791: Generate only
                   3792: .Qq safe
                   3793: prime numbers
                   3794: (i.e. a prime p so that (p-1)/2 is also prime).
                   3795: .It Ar p
                   3796: Test if number
                   3797: .Ar p
                   3798: is prime.
                   3799: .El
                   3800: .\"
                   3801: .\" RAND
                   3802: .\"
                   3803: .Sh RAND
                   3804: .nr nS 1
                   3805: .Nm "openssl rand"
                   3806: .Op Fl base64
                   3807: .Op Fl hex
                   3808: .Op Fl out Ar file
                   3809: .Ar num
                   3810: .nr nS 0
                   3811: .Pp
                   3812: The
                   3813: .Nm rand
                   3814: command outputs
                   3815: .Ar num
                   3816: pseudo-random bytes.
                   3817: .Pp
                   3818: The options are as follows:
                   3819: .Bl -tag -width Ds
                   3820: .It Fl base64
                   3821: Perform
                   3822: .Em base64
                   3823: encoding on the output.
                   3824: .It Fl hex
                   3825: Specify hexadecimal output.
                   3826: .It Fl out Ar file
                   3827: Write to
                   3828: .Ar file
                   3829: instead of standard output.
                   3830: .El
                   3831: .\"
                   3832: .\" REQ
                   3833: .\"
                   3834: .Sh REQ
                   3835: .nr nS 1
                   3836: .Nm "openssl req"
                   3837: .Bk -words
                   3838: .Op Fl asn1-kludge
                   3839: .Op Fl batch
                   3840: .Op Fl config Ar file
                   3841: .Op Fl days Ar n
                   3842: .Op Fl extensions Ar section
                   3843: .Op Fl in Ar file
                   3844: .Op Fl inform Ar DER | PEM
                   3845: .Op Fl key Ar keyfile
                   3846: .Op Fl keyform Ar DER | PEM
                   3847: .Op Fl keyout Ar file
1.28      doug     3848: .Op Fl md4 | md5 | sha1
1.1       jsing    3849: .Op Fl modulus
                   3850: .Op Fl nameopt Ar option
                   3851: .Op Fl new
                   3852: .Op Fl newhdr
                   3853: .Op Fl newkey Ar arg
                   3854: .Op Fl no-asn1-kludge
                   3855: .Op Fl nodes
                   3856: .Op Fl noout
                   3857: .Op Fl out Ar file
                   3858: .Op Fl outform Ar DER | PEM
                   3859: .Op Fl passin Ar arg
                   3860: .Op Fl passout Ar arg
                   3861: .Op Fl pubkey
                   3862: .Op Fl reqexts Ar section
                   3863: .Op Fl reqopt Ar option
                   3864: .Op Fl set_serial Ar n
                   3865: .Op Fl subj Ar arg
                   3866: .Op Fl subject
                   3867: .Op Fl text
                   3868: .Op Fl utf8
                   3869: .Op Fl verbose
                   3870: .Op Fl verify
                   3871: .Op Fl x509
                   3872: .Ek
                   3873: .nr nS 0
                   3874: .Pp
                   3875: The
                   3876: .Nm req
                   3877: command primarily creates and processes certificate requests
                   3878: in PKCS#10 format.
                   3879: It can additionally create self-signed certificates,
                   3880: for use as root CAs, for example.
                   3881: .Pp
                   3882: The options are as follows:
                   3883: .Bl -tag -width Ds
                   3884: .It Fl asn1-kludge
                   3885: By default, the
                   3886: .Nm req
                   3887: command outputs certificate requests containing
                   3888: no attributes in the correct PKCS#10 format.
                   3889: However certain CAs will only
                   3890: accept requests containing no attributes in an invalid form: this
                   3891: option produces this invalid format.
                   3892: .Pp
                   3893: More precisely, the
                   3894: .Em Attributes
                   3895: in a PKCS#10 certificate request are defined as a SET OF Attribute.
                   3896: They are
                   3897: .Em not
                   3898: optional, so if no attributes are present then they should be encoded as an
                   3899: empty SET OF.
                   3900: The invalid form does not include the empty
                   3901: SET OF, whereas the correct form does.
                   3902: .Pp
                   3903: It should be noted that very few CAs still require the use of this option.
                   3904: .It Fl batch
                   3905: Non-interactive mode.
                   3906: .It Fl config Ar file
                   3907: This allows an alternative configuration file to be specified;
                   3908: this overrides the compile time filename or any specified in
                   3909: the
                   3910: .Ev OPENSSL_CONF
                   3911: environment variable.
                   3912: .It Fl days Ar n
                   3913: When the
                   3914: .Fl x509
                   3915: option is being used, this specifies the number of
                   3916: days to certify the certificate for.
                   3917: The default is 30 days.
                   3918: .It Fl extensions Ar section , Fl reqexts Ar section
                   3919: These options specify alternative sections to include certificate
                   3920: extensions (if the
                   3921: .Fl x509
                   3922: option is present) or certificate request extensions.
                   3923: This allows several different sections to
                   3924: be used in the same configuration file to specify requests for
                   3925: a variety of purposes.
                   3926: .It Fl in Ar file
                   3927: This specifies the input
                   3928: .Ar file
                   3929: to read a request from, or standard input
                   3930: if this option is not specified.
                   3931: A request is only read if the creation options
                   3932: .Fl new
                   3933: and
                   3934: .Fl newkey
                   3935: are not specified.
                   3936: .It Fl inform Ar DER | PEM
                   3937: This specifies the input format.
                   3938: The
                   3939: .Ar DER
                   3940: argument uses an ASN1 DER-encoded form compatible with the PKCS#10.
                   3941: The
                   3942: .Ar PEM
                   3943: form is the default format:
                   3944: it consists of the DER format base64-encoded with additional header and
                   3945: footer lines.
                   3946: .It Fl key Ar keyfile
                   3947: This specifies the file to read the private key from.
                   3948: It also accepts PKCS#8 format private keys for PEM format files.
                   3949: .It Fl keyform Ar DER | PEM
                   3950: The format of the private key file specified in the
                   3951: .Fl key
                   3952: argument.
                   3953: .Ar PEM
                   3954: is the default.
                   3955: .It Fl keyout Ar file
                   3956: This gives the
                   3957: .Ar file
                   3958: to write the newly created private key to.
                   3959: If this option is not specified, the filename present in the
                   3960: configuration file is used.
1.4       sthen    3961: .It Fl md5 | sha1 | sha256
1.1       jsing    3962: This specifies the message digest to sign the request with.
                   3963: This overrides the digest algorithm specified in the configuration file.
                   3964: .Pp
                   3965: Some public key algorithms may override this choice.
                   3966: For instance, DSA signatures always use SHA1.
                   3967: .It Fl modulus
                   3968: This option prints out the value of the modulus of the public key
                   3969: contained in the request.
                   3970: .It Fl nameopt Ar option , Fl reqopt Ar option
                   3971: These options determine how the subject or issuer names are displayed.
                   3972: The
                   3973: .Ar option
                   3974: argument can be a single option or multiple options separated by commas.
                   3975: Alternatively, these options may be used more than once to set multiple options.
                   3976: See the
                   3977: .Sx X509
                   3978: section below for details.
                   3979: .It Fl new
                   3980: This option generates a new certificate request.
                   3981: It will prompt the user for the relevant field values.
                   3982: The actual fields prompted for and their maximum and minimum sizes
                   3983: are specified in the configuration file and any requested extensions.
                   3984: .Pp
                   3985: If the
                   3986: .Fl key
                   3987: option is not used, it will generate a new RSA private
                   3988: key using information specified in the configuration file.
                   3989: .It Fl newhdr
                   3990: Adds the word NEW to the PEM file header and footer lines
                   3991: on the outputed request.
                   3992: Some software
                   3993: .Pq Netscape certificate server
                   3994: and some CAs need this.
                   3995: .It Fl newkey Ar arg
                   3996: This option creates a new certificate request and a new private key.
                   3997: The argument takes one of several forms.
                   3998: .Ar rsa : Ns Ar nbits ,
                   3999: where
                   4000: .Ar nbits
                   4001: is the number of bits, generates an RSA key
                   4002: .Ar nbits
                   4003: in size.
                   4004: If
                   4005: .Ar nbits
                   4006: is omitted, i.e.\&
                   4007: .Cm -newkey rsa
                   4008: specified,
                   4009: the default key size, specified in the configuration file, is used.
                   4010: .Pp
                   4011: All other algorithms support the
                   4012: .Ar alg : Ns Ar file
                   4013: form,
                   4014: where file may be an algorithm parameter file,
                   4015: created by the
                   4016: .Cm genpkey -genparam
1.14      jmc      4017: command or an X.509 certificate for a key with appropriate algorithm.
1.1       jsing    4018: .Pp
                   4019: .Ar param : Ns Ar file
                   4020: generates a key using the parameter file or certificate
                   4021: .Ar file ;
                   4022: the algorithm is determined by the parameters.
                   4023: .Ar algname : Ns Ar file
                   4024: use algorithm
                   4025: .Ar algname
                   4026: and parameter file
                   4027: .Ar file :
                   4028: the two algorithms must match or an error occurs.
                   4029: .Ar algname
                   4030: just uses algorithm
                   4031: .Ar algname ,
                   4032: and parameters, if necessary,
                   4033: should be specified via the
                   4034: .Fl pkeyopt
                   4035: option.
                   4036: .Pp
                   4037: .Ar dsa : Ns Ar file
                   4038: generates a DSA key using the parameters in the file
                   4039: .Ar file .
                   4040: .It Fl no-asn1-kludge
                   4041: Reverses the effect of
                   4042: .Fl asn1-kludge .
                   4043: .It Fl nodes
                   4044: If this option is specified and a private key is created, it
                   4045: will not be encrypted.
                   4046: .It Fl noout
                   4047: This option prevents output of the encoded version of the request.
                   4048: .It Fl out Ar file
                   4049: This specifies the output
                   4050: .Ar file
                   4051: to write to, or standard output by default.
                   4052: .It Fl outform Ar DER | PEM
                   4053: This specifies the output format; the options have the same meaning as the
                   4054: .Fl inform
                   4055: option.
                   4056: .It Fl passin Ar arg
                   4057: The key password source.
                   4058: .It Fl passout Ar arg
                   4059: The output file password source.
                   4060: .It Fl pubkey
                   4061: Outputs the public key.
                   4062: .It Fl reqopt Ar option
                   4063: Customise the output format used with
                   4064: .Fl text .
                   4065: The
                   4066: .Ar option
                   4067: argument can be a single option or multiple options separated by commas.
                   4068: .Pp
                   4069: See the discussion of the
                   4070: .Fl certopt
                   4071: option in the
                   4072: .Nm x509
                   4073: command.
                   4074: .It Fl set_serial Ar n
                   4075: Serial number to use when outputting a self-signed certificate.
                   4076: This may be specified as a decimal value or a hex value if preceded by
                   4077: .Sq 0x .
                   4078: It is possible to use negative serial numbers but this is not recommended.
                   4079: .It Fl subj Ar arg
                   4080: Replaces subject field of input request with specified data and outputs
                   4081: modified request.
                   4082: The arg must be formatted as
                   4083: .Em /type0=value0/type1=value1/type2=... ;
                   4084: characters may be escaped by
                   4085: .Sq \e
                   4086: .Pq backslash ;
                   4087: no spaces are skipped.
                   4088: .It Fl subject
                   4089: Prints out the request subject (or certificate subject if
                   4090: .Fl x509
                   4091: is specified.
                   4092: .It Fl text
                   4093: Prints out the certificate request in text form.
                   4094: .It Fl utf8
                   4095: This option causes field values to be interpreted as UTF8 strings;
                   4096: by default they are interpreted as ASCII.
                   4097: This means that the field values, whether prompted from a terminal or
                   4098: obtained from a configuration file, must be valid UTF8 strings.
                   4099: .It Fl verbose
                   4100: Print extra details about the operations being performed.
                   4101: .It Fl verify
                   4102: Verifies the signature on the request.
                   4103: .It Fl x509
                   4104: This option outputs a self-signed certificate instead of a certificate
                   4105: request.
                   4106: This is typically used to generate a test certificate or
                   4107: a self-signed root CA.
                   4108: The extensions added to the certificate
                   4109: .Pq if any
                   4110: are specified in the configuration file.
                   4111: Unless specified using the
                   4112: .Fl set_serial
                   4113: option, 0 will be used for the serial number.
                   4114: .El
                   4115: .Sh REQ CONFIGURATION FILE FORMAT
                   4116: The configuration options are specified in the
                   4117: .Em req
                   4118: section of the configuration file.
                   4119: As with all configuration files, if no value is specified in the specific
                   4120: section (i.e.\&
                   4121: .Em req )
                   4122: then the initial unnamed or
                   4123: .Em default
                   4124: section is searched too.
                   4125: .Pp
                   4126: The options available are described in detail below.
                   4127: .Bl -tag -width "XXXX"
                   4128: .It Ar attributes
                   4129: This specifies the section containing any request attributes: its format
                   4130: is the same as
                   4131: .Ar distinguished_name .
                   4132: Typically these may contain the
                   4133: .Em challengePassword
                   4134: or
                   4135: .Em unstructuredName
                   4136: types.
                   4137: They are currently ignored by
                   4138: .Nm OpenSSL Ns Li 's
                   4139: request signing utilities, but some CAs might want them.
                   4140: .It Ar default_bits
                   4141: This specifies the default key size in bits.
1.4       sthen    4142: If not specified, 2048 is used.
1.1       jsing    4143: It is used if the
                   4144: .Fl new
                   4145: option is used.
                   4146: It can be overridden by using the
                   4147: .Fl newkey
                   4148: option.
                   4149: .It Ar default_keyfile
                   4150: This is the default file to write a private key to.
                   4151: If not specified, the key is written to standard output.
                   4152: This can be overridden by the
                   4153: .Fl keyout
                   4154: option.
                   4155: .It Ar default_md
                   4156: This option specifies the digest algorithm to use.
                   4157: Possible values include
1.4       sthen    4158: .Ar md5 ,
                   4159: .Ar sha1
1.1       jsing    4160: and
1.4       sthen    4161: .Ar sha256 .
                   4162: If not present, SHA256 is used.
1.1       jsing    4163: This option can be overridden on the command line.
                   4164: .It Ar distinguished_name
                   4165: This specifies the section containing the distinguished name fields to
                   4166: prompt for when generating a certificate or certificate request.
                   4167: The format is described in the next section.
                   4168: .It Ar encrypt_key
                   4169: If this is set to
                   4170: .Em no
                   4171: and a private key is generated, it is
                   4172: .Em not
                   4173: encrypted.
                   4174: This is equivalent to the
                   4175: .Fl nodes
                   4176: command line option.
                   4177: For compatibility,
                   4178: .Ar encrypt_rsa_key
                   4179: is an equivalent option.
                   4180: .It Ar input_password | output_password
                   4181: The passwords for the input private key file
                   4182: .Pq if present
                   4183: and the output private key file
                   4184: .Pq if one will be created .
                   4185: The command line options
                   4186: .Fl passin
                   4187: and
                   4188: .Fl passout
                   4189: override the configuration file values.
                   4190: .It Ar oid_file
                   4191: This specifies a file containing additional OBJECT IDENTIFIERS.
                   4192: Each line of the file should consist of the numerical form of the
                   4193: object identifier, followed by whitespace, then the short name followed
                   4194: by whitespace and finally the long name.
                   4195: .It Ar oid_section
                   4196: This specifies a section in the configuration file containing extra
                   4197: object identifiers.
                   4198: Each line should consist of the short name of the
                   4199: object identifier followed by
                   4200: .Sq =
                   4201: and the numerical form.
                   4202: The short and long names are the same when this option is used.
                   4203: .It Ar prompt
                   4204: If set to the value
                   4205: .Em no ,
                   4206: this disables prompting of certificate fields
                   4207: and just takes values from the config file directly.
                   4208: It also changes the expected format of the
                   4209: .Em distinguished_name
                   4210: and
                   4211: .Em attributes
                   4212: sections.
                   4213: .It Ar req_extensions
                   4214: This specifies the configuration file section containing a list of
                   4215: extensions to add to the certificate request.
                   4216: It can be overridden by the
                   4217: .Fl reqexts
                   4218: command line switch.
                   4219: .It Ar string_mask
                   4220: This option limits the string types for encoding certain
                   4221: fields.
                   4222: The following values may be used, limiting strings to the indicated types:
                   4223: .Bl -tag -width "MASK:number"
                   4224: .It Ar utf8only
                   4225: .Em UTF8String.
                   4226: This is the default, as recommended by PKIX in RFC 2459.
                   4227: .It Ar default
                   4228: .Em PrintableString , IA5String , T61String , BMPString , UTF8String .
                   4229: .It Ar pkix
                   4230: .Em PrintableString , IA5String , BMPString , UTF8String .
                   4231: This was inspired by the PKIX recommendation in RFC 2459 for certificates
                   4232: generated before 2004, but differs by also permitting
                   4233: .Em IA5String .
                   4234: .It Ar nombstr
                   4235: .Em PrintableString , IA5String , T61String , UniversalString .
                   4236: This was a workaround for some ancient software that had problems
                   4237: with the variable-sized
                   4238: .Em BMPString
                   4239: and
                   4240: .Em UTF8String
                   4241: types.
                   4242: .It Cm MASK : Ns Ar number
                   4243: This is an explicit bitmask of permitted types, where
                   4244: .Ar number
                   4245: is a C-style hex, decimal, or octal number that's a bit-wise OR of
                   4246: .Dv B_ASN1_*
                   4247: values from
                   4248: .In openssl/asn1.h .
                   4249: .El
                   4250: .It Ar utf8
                   4251: If set to the value
                   4252: .Em yes ,
                   4253: then field values are interpreted as UTF8 strings;
                   4254: by default they are interpreted as ASCII.
                   4255: This means that the field values, whether prompted from a terminal or
                   4256: obtained from a configuration file, must be valid UTF8 strings.
                   4257: .It Ar x509_extensions
                   4258: This specifies the configuration file section containing a list of
                   4259: extensions to add to a certificate generated when the
                   4260: .Fl x509
                   4261: switch is used.
                   4262: It can be overridden by the
                   4263: .Fl extensions
                   4264: command line switch.
                   4265: .El
                   4266: .Sh REQ DISTINGUISHED NAME AND ATTRIBUTE SECTION FORMAT
                   4267: There are two separate formats for the distinguished name and attribute
                   4268: sections.
                   4269: If the
                   4270: .Fl prompt
                   4271: option is set to
                   4272: .Em no ,
                   4273: then these sections just consist of field names and values: for example,
                   4274: .Bd -unfilled -offset indent
                   4275: CN=My Name
                   4276: OU=My Organization
                   4277: emailAddress=someone@somewhere.org
                   4278: .Ed
                   4279: .Pp
                   4280: This allows external programs
                   4281: .Pq e.g. GUI based
                   4282: to generate a template file with all the field names and values
                   4283: and just pass it to
                   4284: .Nm req .
                   4285: An example of this kind of configuration file is contained in the
                   4286: .Sx REQ EXAMPLES
                   4287: section.
                   4288: .Pp
                   4289: Alternatively if the
                   4290: .Fl prompt
                   4291: option is absent or not set to
                   4292: .Em no ,
                   4293: then the file contains field prompting information.
                   4294: It consists of lines of the form:
                   4295: .Bd -unfilled -offset indent
                   4296: fieldName="prompt"
                   4297: fieldName_default="default field value"
                   4298: fieldName_min= 2
                   4299: fieldName_max= 4
                   4300: .Ed
                   4301: .Pp
                   4302: .Qq fieldName
                   4303: is the field name being used, for example
                   4304: .Em commonName
                   4305: .Pq or CN .
                   4306: The
                   4307: .Qq prompt
                   4308: string is used to ask the user to enter the relevant details.
                   4309: If the user enters nothing, the default value is used;
                   4310: if no default value is present, the field is omitted.
                   4311: A field can still be omitted if a default value is present,
                   4312: if the user just enters the
                   4313: .Sq \&.
                   4314: character.
                   4315: .Pp
                   4316: The number of characters entered must be between the
                   4317: .Em fieldName_min
                   4318: and
                   4319: .Em fieldName_max
                   4320: limits:
                   4321: there may be additional restrictions based on the field being used
                   4322: (for example
                   4323: .Em countryName
                   4324: can only ever be two characters long and must fit in a
                   4325: .Em PrintableString ) .
                   4326: .Pp
                   4327: Some fields (such as
                   4328: .Em organizationName )
                   4329: can be used more than once in a DN.
                   4330: This presents a problem because configuration files will
                   4331: not recognize the same name occurring twice.
                   4332: To avoid this problem, if the
                   4333: .Em fieldName
                   4334: contains some characters followed by a full stop, they will be ignored.
                   4335: So, for example, a second
                   4336: .Em organizationName
                   4337: can be input by calling it
                   4338: .Qq 1.organizationName .
                   4339: .Pp
                   4340: The actual permitted field names are any object identifier short or
                   4341: long names.
                   4342: These are compiled into
                   4343: .Nm OpenSSL
                   4344: and include the usual values such as
                   4345: .Em commonName , countryName , localityName , organizationName ,
                   4346: .Em organizationUnitName , stateOrProvinceName .
                   4347: Additionally,
                   4348: .Em emailAddress
                   4349: is included as well as
                   4350: .Em name , surname , givenName initials
                   4351: and
                   4352: .Em dnQualifier .
                   4353: .Pp
                   4354: Additional object identifiers can be defined with the
                   4355: .Ar oid_file
                   4356: or
                   4357: .Ar oid_section
                   4358: options in the configuration file.
                   4359: Any additional fields will be treated as though they were a
                   4360: .Em DirectoryString .
                   4361: .Sh REQ EXAMPLES
                   4362: Examine and verify a certificate request:
                   4363: .Pp
                   4364: .Dl $ openssl req -in req.pem -text -verify -noout
                   4365: .Pp
                   4366: Create a private key and then generate a certificate request from it:
                   4367: .Bd -literal -offset indent
                   4368: $ openssl genrsa -out key.pem 2048
                   4369: $ openssl req -new -key key.pem -out req.pem
                   4370: .Ed
                   4371: .Pp
                   4372: The same but just using req:
                   4373: .Pp
                   4374: .Dl $ openssl req -newkey rsa:2048 -keyout key.pem -out req.pem
                   4375: .Pp
                   4376: Generate a self-signed root certificate:
                   4377: .Pp
                   4378: .Dl "$ openssl req -x509 -newkey rsa:2048 -keyout key.pem -out req.pem"
                   4379: .Pp
                   4380: Example of a file pointed to by the
                   4381: .Ar oid_file
                   4382: option:
                   4383: .Bd -unfilled -offset indent
                   4384: 1.2.3.4        shortName       A longer Name
                   4385: 1.2.3.6        otherName       Other longer Name
                   4386: .Ed
                   4387: .Pp
                   4388: Example of a section pointed to by
                   4389: .Ar oid_section
                   4390: making use of variable expansion:
                   4391: .Bd -unfilled -offset indent
                   4392: testoid1=1.2.3.5
                   4393: testoid2=${testoid1}.6
                   4394: .Ed
                   4395: .Pp
                   4396: Sample configuration file prompting for field values:
                   4397: .Bd -literal
                   4398: \& [ req ]
                   4399: \& default_bits           = 1024
                   4400: \& default_keyfile        = privkey.pem
                   4401: \& distinguished_name     = req_distinguished_name
                   4402: \& attributes             = req_attributes
                   4403: \& x509_extensions        = v3_ca
                   4404:
                   4405: \& dirstring_type = nobmp
                   4406:
                   4407: \& [ req_distinguished_name ]
                   4408: \& countryName                    = Country Name (2 letter code)
                   4409: \& countryName_default            = AU
                   4410: \& countryName_min                = 2
                   4411: \& countryName_max                = 2
                   4412:
                   4413: \& localityName                   = Locality Name (eg, city)
                   4414:
                   4415: \& organizationalUnitName         = Organizational Unit Name (eg, section)
                   4416:
                   4417: \& commonName                     = Common Name (eg, YOUR name)
                   4418: \& commonName_max                 = 64
                   4419:
                   4420: \& emailAddress                   = Email Address
                   4421: \& emailAddress_max               = 40
                   4422:
                   4423: \& [ req_attributes ]
                   4424: \& challengePassword              = A challenge password
                   4425: \& challengePassword_min          = 4
                   4426: \& challengePassword_max          = 20
                   4427:
                   4428: \& [ v3_ca ]
                   4429:
                   4430: \& subjectKeyIdentifier=hash
                   4431: \& authorityKeyIdentifier=keyid:always,issuer:always
                   4432: \& basicConstraints = CA:true
                   4433: .Ed
                   4434: .Pp
                   4435: Sample configuration containing all field values:
                   4436: .Bd -literal
                   4437:
                   4438: \& [ req ]
                   4439: \& default_bits           = 1024
                   4440: \& default_keyfile        = keyfile.pem
                   4441: \& distinguished_name     = req_distinguished_name
                   4442: \& attributes             = req_attributes
                   4443: \& prompt                 = no
                   4444: \& output_password        = mypass
                   4445:
                   4446: \& [ req_distinguished_name ]
                   4447: \& C                      = GB
                   4448: \& ST                     = Test State or Province
                   4449: \& L                      = Test Locality
                   4450: \& O                      = Organization Name
                   4451: \& OU                     = Organizational Unit Name
                   4452: \& CN                     = Common Name
                   4453: \& emailAddress           = test@email.address
                   4454:
                   4455: \& [ req_attributes ]
                   4456: \& challengePassword              = A challenge password
                   4457: .Ed
                   4458: .Sh REQ NOTES
                   4459: The header and footer lines in the PEM format are normally:
                   4460: .Bd -unfilled -offset indent
                   4461: -----BEGIN CERTIFICATE REQUEST-----
                   4462: -----END CERTIFICATE REQUEST-----
                   4463: .Ed
                   4464: .Pp
                   4465: Some software
                   4466: .Pq some versions of Netscape certificate server
                   4467: instead needs:
                   4468: .Bd -unfilled -offset indent
                   4469: -----BEGIN NEW CERTIFICATE REQUEST-----
                   4470: -----END NEW CERTIFICATE REQUEST-----
                   4471: .Ed
                   4472: .Pp
                   4473: which is produced with the
                   4474: .Fl newhdr
                   4475: option but is otherwise compatible.
                   4476: Either form is accepted transparently on input.
                   4477: .Pp
                   4478: The certificate requests generated by Xenroll with MSIE have extensions added.
                   4479: It includes the
                   4480: .Em keyUsage
                   4481: extension which determines the type of key
                   4482: .Pq signature only or general purpose
                   4483: and any additional OIDs entered by the script in an
                   4484: .Em extendedKeyUsage
                   4485: extension.
                   4486: .Sh REQ DIAGNOSTICS
                   4487: The following messages are frequently asked about:
                   4488: .Bd -unfilled -offset indent
                   4489: Using configuration from /some/path/openssl.cnf
                   4490: Unable to load config info
                   4491: .Ed
                   4492: .Pp
                   4493: This is followed some time later by...
                   4494: .Bd -unfilled -offset indent
                   4495: unable to find 'distinguished_name' in config
                   4496: problems making Certificate Request
                   4497: .Ed
                   4498: .Pp
                   4499: The first error message is the clue: it can't find the configuration
                   4500: file!
                   4501: Certain operations
                   4502: .Pq like examining a certificate request
                   4503: don't need a configuration file so its use isn't enforced.
                   4504: Generation of certificates or requests, however, do need a configuration file.
                   4505: This could be regarded as a bug.
                   4506: .Pp
                   4507: Another puzzling message is this:
                   4508: .Bd -unfilled -offset indent
                   4509: Attributes:
                   4510:     a0:00
                   4511: .Ed
                   4512: .Pp
                   4513: This is displayed when no attributes are present and the request includes
                   4514: the correct empty SET OF structure
                   4515: .Pq the DER encoding of which is 0xa0 0x00 .
                   4516: If you just see:
                   4517: .Pp
                   4518: .D1 Attributes:
                   4519: .Pp
                   4520: then the SET OF is missing and the encoding is technically invalid
                   4521: .Pq but it is tolerated .
                   4522: See the description of the command line option
                   4523: .Fl asn1-kludge
                   4524: for more information.
                   4525: .Sh REQ ENVIRONMENT VARIABLES
                   4526: The variable
                   4527: .Ev OPENSSL_CONF ,
                   4528: if defined, allows an alternative configuration
                   4529: file location to be specified; it will be overridden by the
                   4530: .Fl config
                   4531: command line switch if it is present.
                   4532: .Sh REQ BUGS
                   4533: .Nm OpenSSL Ns Li 's
                   4534: handling of T61Strings
                   4535: .Pq aka TeletexStrings
                   4536: is broken: it effectively treats them as ISO 8859-1
                   4537: .Pq Latin 1 ;
                   4538: Netscape and MSIE have similar behaviour.
                   4539: This can cause problems if you need characters that aren't available in
                   4540: .Em PrintableStrings
                   4541: and you don't want to or can't use
                   4542: .Em BMPStrings .
                   4543: .Pp
                   4544: As a consequence of the T61String handling, the only correct way to represent
                   4545: accented characters in
                   4546: .Nm OpenSSL
                   4547: is to use a
                   4548: .Em BMPString :
                   4549: unfortunately Netscape currently chokes on these.
                   4550: If you have to use accented characters with Netscape
                   4551: and MSIE then you currently need to use the invalid T61String form.
                   4552: .Pp
                   4553: The current prompting is not very friendly.
                   4554: It doesn't allow you to confirm what you've just entered.
                   4555: Other things, like extensions in certificate requests, are
                   4556: statically defined in the configuration file.
                   4557: Some of these, like an email address in
                   4558: .Em subjectAltName ,
                   4559: should be input by the user.
                   4560: .\"
                   4561: .\" RSA
                   4562: .\"
                   4563: .Sh RSA
                   4564: .nr nS 1
                   4565: .Nm "openssl rsa"
                   4566: .Bk -words
                   4567: .Oo
                   4568: .Fl aes128 | aes192 | aes256 |
                   4569: .Fl des | des3
                   4570: .Oc
                   4571: .Op Fl check
                   4572: .Op Fl in Ar file
                   4573: .Op Fl inform Ar DER | NET | PEM
                   4574: .Op Fl modulus
                   4575: .Op Fl noout
                   4576: .Op Fl out Ar file
                   4577: .Op Fl outform Ar DER | NET | PEM
                   4578: .Op Fl passin Ar arg
                   4579: .Op Fl passout Ar arg
                   4580: .Op Fl pubin
                   4581: .Op Fl pubout
                   4582: .Op Fl sgckey
                   4583: .Op Fl text
                   4584: .nr nS 0
                   4585: .Ek
                   4586: .Pp
                   4587: The
                   4588: .Nm rsa
                   4589: command processes RSA keys.
                   4590: They can be converted between various forms and their components printed out.
                   4591: .Pp
                   4592: .Sy Note :
                   4593: this command uses the traditional
                   4594: .Nm SSLeay
                   4595: compatible format for private key encryption:
                   4596: newer applications should use the more secure PKCS#8 format using the
                   4597: .Nm pkcs8
                   4598: utility.
                   4599: .Pp
                   4600: The options are as follows:
                   4601: .Bl -tag -width Ds
                   4602: .It Xo
                   4603: .Fl aes128 | aes192 | aes256 |
                   4604: .Fl des | des3
                   4605: .Xc
                   4606: These options encrypt the private key with the AES, DES,
                   4607: or the triple DES ciphers, respectively, before outputting it.
                   4608: A pass phrase is prompted for.
                   4609: If none of these options are specified, the key is written in plain text.
                   4610: This means that using the
                   4611: .Nm rsa
                   4612: utility to read in an encrypted key with no encryption option can be used
                   4613: to remove the pass phrase from a key, or by setting the encryption options
                   4614: it can be used to add or change the pass phrase.
                   4615: These options can only be used with PEM format output files.
                   4616: .It Fl check
                   4617: This option checks the consistency of an RSA private key.
                   4618: .It Fl in Ar file
                   4619: This specifies the input
                   4620: .Ar file
                   4621: to read a key from, or standard input if this
                   4622: option is not specified.
                   4623: If the key is encrypted, a pass phrase will be prompted for.
                   4624: .It Fl inform Ar DER | NET | PEM
                   4625: This specifies the input format.
                   4626: The
                   4627: .Ar DER
                   4628: argument
                   4629: uses an ASN1 DER-encoded form compatible with the PKCS#1
                   4630: RSAPrivateKey or SubjectPublicKeyInfo format.
                   4631: The
                   4632: .Ar PEM
                   4633: form is the default format: it consists of the DER format base64-encoded with
                   4634: additional header and footer lines.
                   4635: On input PKCS#8 format private keys are also accepted.
                   4636: The
                   4637: .Ar NET
                   4638: form is a format described in the
                   4639: .Sx RSA NOTES
                   4640: section.
                   4641: .It Fl noout
                   4642: This option prevents output of the encoded version of the key.
                   4643: .It Fl modulus
                   4644: This option prints out the value of the modulus of the key.
                   4645: .It Fl out Ar file
                   4646: This specifies the output
                   4647: .Ar file
                   4648: to write a key to, or standard output if this option is not specified.
                   4649: If any encryption options are set, a pass phrase will be prompted for.
                   4650: The output filename should
                   4651: .Em not
                   4652: be the same as the input filename.
                   4653: .It Fl outform Ar DER | NET | PEM
                   4654: This specifies the output format; the options have the same meaning as the
                   4655: .Fl inform
                   4656: option.
                   4657: .It Fl passin Ar arg
                   4658: The key password source.
                   4659: .It Fl passout Ar arg
                   4660: The output file password source.
                   4661: .It Fl pubin
                   4662: By default, a private key is read from the input file; with this
                   4663: option a public key is read instead.
                   4664: .It Fl pubout
                   4665: By default, a private key is output;
                   4666: with this option a public key will be output instead.
                   4667: This option is automatically set if the input is a public key.
                   4668: .It Fl sgckey
                   4669: Use the modified
                   4670: .Em NET
                   4671: algorithm used with some versions of Microsoft IIS and SGC keys.
                   4672: .It Fl text
                   4673: Prints out the various public or private key components in
                   4674: plain text, in addition to the encoded version.
                   4675: .El
                   4676: .Sh RSA NOTES
                   4677: The PEM private key format uses the header and footer lines:
                   4678: .Bd -unfilled -offset indent
                   4679: -----BEGIN RSA PRIVATE KEY-----
                   4680: -----END RSA PRIVATE KEY-----
                   4681: .Ed
                   4682: .Pp
                   4683: The PEM public key format uses the header and footer lines:
                   4684: .Bd -unfilled -offset indent
                   4685: -----BEGIN PUBLIC KEY-----
                   4686: -----END PUBLIC KEY-----
                   4687: .Ed
                   4688: .Pp
                   4689: The
                   4690: .Em NET
                   4691: form is a format compatible with older Netscape servers
                   4692: and Microsoft IIS .key files; this uses unsalted RC4 for its encryption.
                   4693: It is not very secure and so should only be used when necessary.
                   4694: .Pp
                   4695: Some newer version of IIS have additional data in the exported .key files.
                   4696: To use these with the
                   4697: .Nm rsa
                   4698: utility, view the file with a binary editor
                   4699: and look for the string
                   4700: .Qq private-key ,
                   4701: then trace back to the byte sequence 0x30, 0x82
                   4702: .Pq this is an ASN1 SEQUENCE .
                   4703: Copy all the data from this point onwards to another file and use that as
                   4704: the input to the
                   4705: .Nm rsa
                   4706: utility with the
                   4707: .Fl inform Ar NET
                   4708: option.
                   4709: If there is an error after entering the password, try the
                   4710: .Fl sgckey
                   4711: option.
                   4712: .Sh RSA EXAMPLES
                   4713: To remove the pass phrase on an RSA private key:
                   4714: .Pp
                   4715: .Dl $ openssl rsa -in key.pem -out keyout.pem
                   4716: .Pp
                   4717: To encrypt a private key using triple DES:
                   4718: .Pp
                   4719: .Dl $ openssl rsa -in key.pem -des3 -out keyout.pem
                   4720: .Pp
                   4721: To convert a private key from PEM to DER format:
                   4722: .Pp
                   4723: .Dl $ openssl rsa -in key.pem -outform DER -out keyout.der
                   4724: .Pp
                   4725: To print out the components of a private key to standard output:
                   4726: .Pp
                   4727: .Dl $ openssl rsa -in key.pem -text -noout
                   4728: .Pp
                   4729: To just output the public part of a private key:
                   4730: .Pp
                   4731: .Dl $ openssl rsa -in key.pem -pubout -out pubkey.pem
                   4732: .Sh RSA BUGS
                   4733: The command line password arguments don't currently work with
                   4734: .Em NET
                   4735: format.
                   4736: .Pp
                   4737: There should be an option that automatically handles .key files,
                   4738: without having to manually edit them.
                   4739: .\"
                   4740: .\" RSAUTL
                   4741: .\"
                   4742: .Sh RSAUTL
                   4743: .nr nS 1
                   4744: .Nm "openssl rsautl"
                   4745: .Bk -words
                   4746: .Op Fl asn1parse
                   4747: .Op Fl certin
                   4748: .Op Fl decrypt
                   4749: .Op Fl encrypt
                   4750: .Op Fl hexdump
                   4751: .Op Fl in Ar file
                   4752: .Op Fl inkey Ar file
                   4753: .Op Fl keyform Ar DER | PEM
                   4754: .Op Fl oaep | pkcs | raw | ssl
                   4755: .Op Fl out Ar file
                   4756: .Op Fl pubin
                   4757: .Op Fl sign
                   4758: .Op Fl verify
                   4759: .Ek
                   4760: .nr nS 0
                   4761: .Pp
                   4762: The
                   4763: .Nm rsautl
                   4764: command can be used to sign, verify, encrypt and decrypt
                   4765: data using the RSA algorithm.
                   4766: .Pp
                   4767: The options are as follows:
                   4768: .Bl -tag -width Ds
                   4769: .It Fl asn1parse
                   4770: Asn1parse the output data; this is useful when combined with the
                   4771: .Fl verify
                   4772: option.
                   4773: .It Fl certin
                   4774: The input is a certificate containing an RSA public key.
                   4775: .It Fl decrypt
                   4776: Decrypt the input data using an RSA private key.
                   4777: .It Fl encrypt
                   4778: Encrypt the input data using an RSA public key.
                   4779: .It Fl hexdump
                   4780: Hex dump the output data.
                   4781: .It Fl in Ar file
                   4782: This specifies the input
                   4783: .Ar file
                   4784: to read data from, or standard input
                   4785: if this option is not specified.
                   4786: .It Fl inkey Ar file
                   4787: The input key file, by default it should be an RSA private key.
                   4788: .It Fl keyform Ar DER | PEM
                   4789: Private ket format.
                   4790: Default is
                   4791: .Ar PEM .
                   4792: .It Fl oaep | pkcs | raw | ssl
                   4793: The padding to use:
                   4794: PKCS#1 OAEP, PKCS#1 v1.5
                   4795: .Pq the default ,
                   4796: or no padding, respectively.
                   4797: For signatures, only
                   4798: .Fl pkcs
                   4799: and
                   4800: .Fl raw
                   4801: can be used.
                   4802: .It Fl out Ar file
                   4803: Specifies the output
                   4804: .Ar file
                   4805: to write to, or standard output by
                   4806: default.
                   4807: .It Fl pubin
                   4808: The input file is an RSA public key.
                   4809: .It Fl sign
                   4810: Sign the input data and output the signed result.
                   4811: This requires an RSA private key.
                   4812: .It Fl verify
                   4813: Verify the input data and output the recovered data.
                   4814: .El
                   4815: .Sh RSAUTL NOTES
                   4816: .Nm rsautl ,
                   4817: because it uses the RSA algorithm directly, can only be
                   4818: used to sign or verify small pieces of data.
                   4819: .Sh RSAUTL EXAMPLES
                   4820: Sign some data using a private key:
                   4821: .Pp
                   4822: .Dl "$ openssl rsautl -sign -in file -inkey key.pem -out sig"
                   4823: .Pp
                   4824: Recover the signed data:
                   4825: .Pp
                   4826: .Dl $ openssl rsautl -verify -in sig -inkey key.pem
                   4827: .Pp
                   4828: Examine the raw signed data:
                   4829: .Pp
                   4830: .Li "\ \&$ openssl rsautl -verify -in file -inkey key.pem -raw -hexdump"
                   4831: .Bd -unfilled
                   4832: \& 0000 - 00 01 ff ff ff ff ff ff-ff ff ff ff ff ff ff ff   ................
                   4833: \& 0010 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff   ................
                   4834: \& 0020 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff   ................
                   4835: \& 0030 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff   ................
                   4836: \& 0040 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff   ................
                   4837: \& 0050 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff   ................
                   4838: \& 0060 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff   ................
                   4839: \& 0070 - ff ff ff ff 00 68 65 6c-6c 6f 20 77 6f 72 6c 64   .....hello world
                   4840: .Ed
                   4841: .Pp
                   4842: The PKCS#1 block formatting is evident from this.
                   4843: If this was done using encrypt and decrypt, the block would have been of type 2
                   4844: .Pq the second byte
                   4845: and random padding data visible instead of the 0xff bytes.
                   4846: .Pp
                   4847: It is possible to analyse the signature of certificates using this
                   4848: utility in conjunction with
                   4849: .Nm asn1parse .
                   4850: Consider the self-signed example in
                   4851: .Pa certs/pca-cert.pem :
                   4852: running
                   4853: .Nm asn1parse
                   4854: as follows yields:
                   4855: .Pp
                   4856: .Li "\ \&$ openssl asn1parse -in pca-cert.pem"
                   4857: .Bd -unfilled
                   4858: \&    0:d=0  hl=4 l= 742 cons: SEQUENCE
                   4859: \&    4:d=1  hl=4 l= 591 cons:  SEQUENCE
                   4860: \&    8:d=2  hl=2 l=   3 cons:   cont [ 0 ]
                   4861: \&   10:d=3  hl=2 l=   1 prim:    INTEGER           :02
                   4862: \&   13:d=2  hl=2 l=   1 prim:   INTEGER           :00
                   4863: \&   16:d=2  hl=2 l=  13 cons:   SEQUENCE
                   4864: \&   18:d=3  hl=2 l=   9 prim:    OBJECT            :md5WithRSAEncryption
                   4865: \&   29:d=3  hl=2 l=   0 prim:    NULL
                   4866: \&   31:d=2  hl=2 l=  92 cons:   SEQUENCE
                   4867: \&   33:d=3  hl=2 l=  11 cons:    SET
                   4868: \&   35:d=4  hl=2 l=   9 cons:     SEQUENCE
                   4869: \&   37:d=5  hl=2 l=   3 prim:      OBJECT            :countryName
                   4870: \&   42:d=5  hl=2 l=   2 prim:      PRINTABLESTRING   :AU
                   4871: \&  ....
                   4872: \&  599:d=1  hl=2 l=  13 cons:  SEQUENCE
                   4873: \&  601:d=2  hl=2 l=   9 prim:   OBJECT            :md5WithRSAEncryption
                   4874: \&  612:d=2  hl=2 l=   0 prim:   NULL
                   4875: \&  614:d=1  hl=3 l= 129 prim:  BIT STRING
                   4876: .Ed
                   4877: .Pp
                   4878: The final BIT STRING contains the actual signature.
                   4879: It can be extracted with:
                   4880: .Pp
                   4881: .Dl "$ openssl asn1parse -in pca-cert.pem -out sig -noout -strparse 614"
                   4882: .Pp
                   4883: The certificate public key can be extracted with:
                   4884: .Pp
                   4885: .Dl $ openssl x509 -in test/testx509.pem -pubkey -noout \*(Gtpubkey.pem
                   4886: .Pp
                   4887: The signature can be analysed with:
                   4888: .Pp
                   4889: .Li "\ \&$ openssl rsautl -in sig -verify -asn1parse -inkey pubkey.pem -pubin"
                   4890: .Bd -unfilled
                   4891: \&    0:d=0  hl=2 l=  32 cons: SEQUENCE
                   4892: \&    2:d=1  hl=2 l=  12 cons:  SEQUENCE
                   4893: \&    4:d=2  hl=2 l=   8 prim:   OBJECT            :md5
                   4894: \&   14:d=2  hl=2 l=   0 prim:   NULL
                   4895: \&   16:d=1  hl=2 l=  16 prim:  OCTET STRING
                   4896: \&   0000 - f3 46 9e aa 1a 4a 73 c9-37 ea 93 00 48 25 08 b5  .F...Js.7...H%..
                   4897: .Ed
                   4898: .Pp
                   4899: This is the parsed version of an ASN1
                   4900: .Em DigestInfo
                   4901: structure.
                   4902: It can be seen that the digest used was MD5.
                   4903: The actual part of the certificate that was signed can be extracted with:
                   4904: .Pp
                   4905: .Dl "$ openssl asn1parse -in pca-cert.pem -out tbs -noout -strparse 4"
                   4906: .Pp
                   4907: and its digest computed with:
                   4908: .Pp
                   4909: .Dl $ openssl md5 -c tbs
                   4910: .D1 MD5(tbs)= f3:46:9e:aa:1a:4a:73:c9:37:ea:93:00:48:25:08:b5
                   4911: .Pp
                   4912: which it can be seen agrees with the recovered value above.
                   4913: .\"
                   4914: .\" S_CLIENT
                   4915: .\"
                   4916: .Sh S_CLIENT
                   4917: .nr nS 1
                   4918: .Nm "openssl s_client"
                   4919: .Bk -words
                   4920: .Op Fl 4 | 6
                   4921: .Op Fl bugs
                   4922: .Op Fl CAfile Ar file
                   4923: .Op Fl CApath Ar directory
                   4924: .Op Fl cert Ar file
                   4925: .Op Fl check_ss_sig
                   4926: .Op Fl cipher Ar cipherlist
                   4927: .Oo
                   4928: .Fl connect Ar host : Ns Ar port |
                   4929: .Ar host Ns / Ns Ar port
                   4930: .Oc
                   4931: .Op Fl crl_check
                   4932: .Op Fl crl_check_all
                   4933: .Op Fl crlf
                   4934: .Op Fl debug
                   4935: .Op Fl extended_crl
                   4936: .Op Fl ign_eof
                   4937: .Op Fl ignore_critical
                   4938: .Op Fl issuer_checks
                   4939: .Op Fl key Ar keyfile
                   4940: .Op Fl msg
                   4941: .Op Fl nbio
                   4942: .Op Fl nbio_test
                   4943: .Op Fl no_ticket
                   4944: .Op Fl no_tls1
1.6       guenther 4945: .Op Fl no_tls1_1
                   4946: .Op Fl no_tls1_2
1.1       jsing    4947: .Op Fl pause
                   4948: .Op Fl policy_check
                   4949: .Op Fl prexit
1.11      bluhm    4950: .Op Fl proxy Ar host : Ns Ar port
1.1       jsing    4951: .Op Fl psk Ar key
                   4952: .Op Fl psk_identity Ar identity
                   4953: .Op Fl quiet
                   4954: .Op Fl reconnect
1.5       jsing    4955: .Op Fl servername Ar name
1.1       jsing    4956: .Op Fl showcerts
                   4957: .Op Fl starttls Ar protocol
                   4958: .Op Fl state
                   4959: .Op Fl tls1
1.31      jmc      4960: .Op Fl tls1_1
                   4961: .Op Fl tls1_2
1.1       jsing    4962: .Op Fl tlsextdebug
                   4963: .Op Fl verify Ar depth
                   4964: .Op Fl x509_strict
1.19      landry   4965: .Op Fl xmpphost Ar host
1.1       jsing    4966: .Ek
                   4967: .nr nS 0
                   4968: .Pp
                   4969: The
                   4970: .Nm s_client
                   4971: command implements a generic SSL/TLS client which connects
                   4972: to a remote host using SSL/TLS.
                   4973: It is a
                   4974: .Em very
                   4975: useful diagnostic tool for SSL servers.
                   4976: .Pp
                   4977: The options are as follows:
                   4978: .Bl -tag -width Ds
                   4979: .It Fl 4
                   4980: Specify that
                   4981: .Nm s_client
                   4982: should attempt connections using IPv4 only.
                   4983: .It Fl 6
                   4984: Specify that
                   4985: .Nm s_client
                   4986: should attempt connections using IPv6 only.
                   4987: .It Fl bugs
                   4988: There are several known bugs in SSL and TLS implementations.
                   4989: Adding this option enables various workarounds.
                   4990: .It Fl CAfile Ar file
                   4991: A
                   4992: .Ar file
                   4993: containing trusted certificates to use during server authentication
                   4994: and to use when attempting to build the client certificate chain.
                   4995: .It Fl CApath Ar directory
                   4996: The
                   4997: .Ar directory
                   4998: to use for server certificate verification.
                   4999: This directory must be in
                   5000: .Qq hash format ;
                   5001: see
                   5002: .Fl verify
                   5003: for more information.
                   5004: These are also used when building the client certificate chain.
                   5005: .It Fl cert Ar file
                   5006: The certificate to use, if one is requested by the server.
                   5007: The default is not to use a certificate.
                   5008: .It Xo
                   5009: .Fl check_ss_sig ,
                   5010: .Fl crl_check ,
                   5011: .Fl crl_check_all ,
                   5012: .Fl extended_crl ,
                   5013: .Fl ignore_critical ,
                   5014: .Fl issuer_checks ,
                   5015: .Fl policy_check ,
                   5016: .Fl x509_strict
                   5017: .Xc
                   5018: Set various certificate chain validation options.
                   5019: See the
                   5020: .Nm VERIFY
                   5021: command for details.
                   5022: .It Fl cipher Ar cipherlist
                   5023: This allows the cipher list sent by the client to be modified.
                   5024: Although the server determines which cipher suite is used, it should take
                   5025: the first supported cipher in the list sent by the client.
                   5026: See the
                   5027: .Sx CIPHERS
                   5028: section above for more information.
                   5029: .It Xo
                   5030: .Fl connect Ar host : Ns Ar port |
                   5031: .Ar host Ns / Ns Ar port
                   5032: .Xc
                   5033: This specifies the
                   5034: .Ar host
                   5035: and optional
                   5036: .Ar port
                   5037: to connect to.
                   5038: If not specified, an attempt is made to connect to the local host
                   5039: on port 4433.
                   5040: Alternatively, the host and port pair may be separated using a forward-slash
                   5041: character.
                   5042: This form is useful for numeric IPv6 addresses.
                   5043: .It Fl crlf
                   5044: This option translates a line feed from the terminal into CR+LF as required
                   5045: by some servers.
                   5046: .It Fl debug
                   5047: Print extensive debugging information including a hex dump of all traffic.
                   5048: .It Fl ign_eof
                   5049: Inhibit shutting down the connection when end of file is reached in the
                   5050: input.
                   5051: .It Fl key Ar keyfile
                   5052: The private key to use.
                   5053: If not specified, the certificate file will be used.
                   5054: .It Fl msg
                   5055: Show all protocol messages with hex dump.
                   5056: .It Fl nbio
                   5057: Turns on non-blocking I/O.
                   5058: .It Fl nbio_test
                   5059: Tests non-blocking I/O.
1.31      jmc      5060: .It Fl no_tls1 | no_tls1_1 | no_tls1_2
1.1       jsing    5061: By default, the initial handshake uses a method which should be compatible
1.31      jmc      5062: with servers supporting any version of TLS.
                   5063: These options disable the use of TLS1.0, 1.1, and 1.2, respectively.
1.1       jsing    5064: .Pp
                   5065: Unfortunately there are a lot of ancient and broken servers in use which
                   5066: cannot handle this technique and will fail to connect.
                   5067: .It Fl no_ticket
                   5068: Disable RFC 4507 session ticket support.
                   5069: .It Fl pause
                   5070: Pauses 1 second between each read and write call.
                   5071: .It Fl prexit
                   5072: Print session information when the program exits.
                   5073: This will always attempt
                   5074: to print out information even if the connection fails.
                   5075: Normally, information will only be printed out once if the connection succeeds.
                   5076: This option is useful because the cipher in use may be renegotiated
                   5077: or the connection may fail because a client certificate is required or is
                   5078: requested only after an attempt is made to access a certain URL.
                   5079: .Sy Note :
                   5080: the output produced by this option is not always accurate because a
                   5081: connection might never have been established.
1.11      bluhm    5082: .It Fl proxy Ar host : Ns Ar port
                   5083: Use the HTTP proxy at
                   5084: .Ar host
                   5085: and
                   5086: .Ar port .
                   5087: The connection to the proxy is done in cleartext and the
                   5088: .Fl connect
                   5089: argument is given to the proxy.
                   5090: If not specified, localhost is used as final destination.
                   5091: After that, switch the connection through the proxy to the destination
                   5092: to TLS.
1.1       jsing    5093: .It Fl psk Ar key
                   5094: Use the PSK key
                   5095: .Ar key
                   5096: when using a PSK cipher suite.
                   5097: The key is given as a hexadecimal number without the leading 0x,
                   5098: for example -psk 1a2b3c4d.
                   5099: .It Fl psk_identity Ar identity
                   5100: Use the PSK identity
                   5101: .Ar identity
                   5102: when using a PSK cipher suite.
                   5103: .It Fl quiet
                   5104: Inhibit printing of session and certificate information.
                   5105: This implicitly turns on
                   5106: .Fl ign_eof
                   5107: as well.
                   5108: .It Fl reconnect
                   5109: Reconnects to the same server 5 times using the same session ID; this can
                   5110: be used as a test that session caching is working.
1.5       jsing    5111: .It Fl servername Ar name
                   5112: Include the TLS Server Name Indication (SNI) extension in the ClientHello
                   5113: message, using the specified server
                   5114: .Ar name .
1.1       jsing    5115: .It Fl showcerts
                   5116: Display the whole server certificate chain: normally only the server
                   5117: certificate itself is displayed.
                   5118: .It Fl starttls Ar protocol
                   5119: Send the protocol-specific message(s) to switch to TLS for communication.
                   5120: .Ar protocol
                   5121: is a keyword for the intended protocol.
                   5122: Currently, the supported keywords are
                   5123: .Qq ftp ,
                   5124: .Qq imap ,
                   5125: .Qq smtp ,
                   5126: .Qq pop3 ,
                   5127: and
                   5128: .Qq xmpp .
                   5129: .It Fl state
                   5130: Prints out the SSL session states.
1.31      jmc      5131: .It Fl tls1 | tls1_1 | tls1_2
                   5132: Permit only TLS1.0, 1.1, or 1.2, respectively.
1.1       jsing    5133: .It Fl tlsextdebug
                   5134: Print out a hex dump of any TLS extensions received from the server.
                   5135: .It Fl verify Ar depth
                   5136: The verify
                   5137: .Ar depth
                   5138: to use.
                   5139: This specifies the maximum length of the
                   5140: server certificate chain and turns on server certificate verification.
                   5141: Currently the verify operation continues after errors so all the problems
                   5142: with a certificate chain can be seen.
                   5143: As a side effect the connection will never fail due to a server
                   5144: certificate verify failure.
1.19      landry   5145: .It Fl xmpphost Ar hostname
                   5146: This option, when used with
                   5147: .Fl starttls Ar xmpp ,
                   5148: specifies the host for the "to" attribute of the stream element.
                   5149: If this option is not specified then the host specified with
                   5150: .Fl connect
                   5151: will be used.
1.1       jsing    5152: .El
                   5153: .Sh S_CLIENT CONNECTED COMMANDS
                   5154: If a connection is established with an SSL server, any data received
                   5155: from the server is displayed and any key presses will be sent to the
                   5156: server.
                   5157: When used interactively (which means neither
                   5158: .Fl quiet
                   5159: nor
                   5160: .Fl ign_eof
                   5161: have been given), the session will be renegotiated if the line begins with an
                   5162: .Em R ;
                   5163: if the line begins with a
                   5164: .Em Q
                   5165: or if end of file is reached, the connection will be closed down.
                   5166: .Sh S_CLIENT NOTES
                   5167: .Nm s_client
                   5168: can be used to debug SSL servers.
                   5169: To connect to an SSL HTTP server the command:
                   5170: .Pp
                   5171: .Dl $ openssl s_client -connect servername:443
                   5172: .Pp
                   5173: would typically be used
                   5174: .Pq HTTPS uses port 443 .
                   5175: If the connection succeeds, an HTTP command can be given such as
                   5176: .Qq GET
                   5177: to retrieve a web page.
                   5178: .Pp
                   5179: If the handshake fails, there are several possible causes; if it is
                   5180: nothing obvious like no client certificate, then the
1.31      jmc      5181: .Fl bugs , tls1 , tls1_1, tls1_2 , no_tls1 , no_tls1_1 ,
1.1       jsing    5182: and
1.6       guenther 5183: .Fl no_tls1_2
1.1       jsing    5184: options can be tried in case it is a buggy server.
                   5185: .Pp
                   5186: A frequent problem when attempting to get client certificates working
                   5187: is that a web client complains it has no certificates or gives an empty
                   5188: list to choose from.
                   5189: This is normally because the server is not sending the client's certificate
                   5190: authority in its
                   5191: .Qq acceptable CA list
                   5192: when it requests a certificate.
                   5193: By using
                   5194: .Nm s_client
                   5195: the CA list can be viewed and checked.
                   5196: However some servers only request client authentication
                   5197: after a specific URL is requested.
                   5198: To obtain the list in this case it is necessary to use the
                   5199: .Fl prexit
                   5200: option and send an HTTP request for an appropriate page.
                   5201: .Pp
                   5202: If a certificate is specified on the command line using the
                   5203: .Fl cert
                   5204: option, it will not be used unless the server specifically requests
                   5205: a client certificate.
                   5206: Therefore merely including a client certificate
                   5207: on the command line is no guarantee that the certificate works.
                   5208: .Pp
                   5209: If there are problems verifying a server certificate, the
                   5210: .Fl showcerts
                   5211: option can be used to show the whole chain.
                   5212: .Pp
                   5213: Compression methods are only supported for
                   5214: .Fl tls1 .
                   5215: .Sh S_CLIENT BUGS
                   5216: Because this program has a lot of options and also because some of
                   5217: the techniques used are rather old, the C source of
                   5218: .Nm s_client
                   5219: is rather hard to read and not a model of how things should be done.
                   5220: A typical SSL client program would be much simpler.
                   5221: .Pp
                   5222: The
                   5223: .Fl verify
                   5224: option should really exit if the server verification fails.
                   5225: .Pp
                   5226: The
                   5227: .Fl prexit
                   5228: option is a bit of a hack.
                   5229: We should really report information whenever a session is renegotiated.
                   5230: .\"
                   5231: .\" S_SERVER
                   5232: .\"
                   5233: .Sh S_SERVER
                   5234: .nr nS 1
                   5235: .Nm "openssl s_server"
                   5236: .Bk -words
                   5237: .Op Fl accept Ar port
                   5238: .Op Fl bugs
                   5239: .Op Fl CAfile Ar file
                   5240: .Op Fl CApath Ar directory
                   5241: .Op Fl cert Ar file
                   5242: .Op Fl cipher Ar cipherlist
                   5243: .Op Fl context Ar id
                   5244: .Op Fl crl_check
                   5245: .Op Fl crl_check_all
                   5246: .Op Fl crlf
                   5247: .Op Fl dcert Ar file
                   5248: .Op Fl debug
                   5249: .Op Fl dhparam Ar file
                   5250: .Op Fl dkey Ar file
                   5251: .Op Fl hack
                   5252: .Op Fl HTTP
                   5253: .Op Fl id_prefix Ar arg
                   5254: .Op Fl key Ar keyfile
                   5255: .Op Fl msg
                   5256: .Op Fl nbio
                   5257: .Op Fl nbio_test
                   5258: .Op Fl no_dhe
                   5259: .Op Fl no_tls1
1.6       guenther 5260: .Op Fl no_tls1_1
                   5261: .Op Fl no_tls1_2
1.1       jsing    5262: .Op Fl no_tmp_rsa
                   5263: .Op Fl nocert
                   5264: .Op Fl psk Ar key
                   5265: .Op Fl psk_hint Ar hint
                   5266: .Op Fl quiet
                   5267: .Op Fl serverpref
                   5268: .Op Fl state
                   5269: .Op Fl tls1
1.31      jmc      5270: .Op Fl tls1_1
                   5271: .Op Fl tls1_2
1.1       jsing    5272: .Op Fl Verify Ar depth
                   5273: .Op Fl verify Ar depth
                   5274: .Op Fl WWW
                   5275: .Op Fl www
                   5276: .Ek
                   5277: .nr nS 0
                   5278: .Pp
                   5279: The
                   5280: .Nm s_server
                   5281: command implements a generic SSL/TLS server which listens
                   5282: for connections on a given port using SSL/TLS.
                   5283: .Pp
                   5284: The options are as follows:
                   5285: .Bl -tag -width Ds
                   5286: .It Fl accept Ar port
                   5287: The TCP
                   5288: .Ar port
                   5289: to listen on for connections.
                   5290: If not specified, 4433 is used.
                   5291: .It Fl bugs
                   5292: There are several known bugs in SSL and TLS implementations.
                   5293: Adding this option enables various workarounds.
                   5294: .It Fl CAfile Ar file
                   5295: A file containing trusted certificates to use during client authentication
                   5296: and to use when attempting to build the server certificate chain.
                   5297: The list is also used in the list of acceptable client CAs passed to the
                   5298: client when a certificate is requested.
                   5299: .It Fl CApath Ar directory
                   5300: The
                   5301: .Ar directory
                   5302: to use for client certificate verification.
                   5303: This directory must be in
                   5304: .Qq hash format ;
                   5305: see
                   5306: .Fl verify
                   5307: for more information.
                   5308: These are also used when building the server certificate chain.
                   5309: .It Fl cert Ar file
                   5310: The certificate to use; most server's cipher suites require the use of a
                   5311: certificate and some require a certificate with a certain public key type:
                   5312: for example the DSS cipher suites require a certificate containing a DSS
                   5313: .Pq DSA
                   5314: key.
                   5315: If not specified, the file
                   5316: .Pa server.pem
                   5317: will be used.
                   5318: .It Fl cipher Ar cipherlist
                   5319: This allows the cipher list used by the server to be modified.
                   5320: When the client sends a list of supported ciphers, the first client cipher
                   5321: also included in the server list is used.
                   5322: Because the client specifies the preference order, the order of the server
                   5323: cipherlist is irrelevant.
                   5324: See the
                   5325: .Sx CIPHERS
                   5326: section for more information.
                   5327: .It Fl context Ar id
                   5328: Sets the SSL context ID.
                   5329: It can be given any string value.
                   5330: If this option is not present, a default value will be used.
                   5331: .It Fl crl_check , crl_check_all
                   5332: Check the peer certificate has not been revoked by its CA.
                   5333: The CRLs are appended to the certificate file.
                   5334: With the
                   5335: .Fl crl_check_all
                   5336: option, all CRLs of all CAs in the chain are checked.
                   5337: .It Fl crlf
                   5338: This option translates a line feed from the terminal into CR+LF.
                   5339: .It Fl dcert Ar file , Fl dkey Ar file
                   5340: Specify an additional certificate and private key; these behave in the
                   5341: same manner as the
                   5342: .Fl cert
                   5343: and
                   5344: .Fl key
                   5345: options except there is no default if they are not specified
                   5346: .Pq no additional certificate or key is used .
                   5347: As noted above some cipher suites require a certificate containing a key of
                   5348: a certain type.
                   5349: Some cipher suites need a certificate carrying an RSA key
                   5350: and some a DSS
                   5351: .Pq DSA
                   5352: key.
                   5353: By using RSA and DSS certificates and keys,
                   5354: a server can support clients which only support RSA or DSS cipher suites
                   5355: by using an appropriate certificate.
                   5356: .It Fl debug
                   5357: Print extensive debugging information including a hex dump of all traffic.
                   5358: .It Fl dhparam Ar file
                   5359: The DH parameter file to use.
                   5360: The ephemeral DH cipher suites generate keys
                   5361: using a set of DH parameters.
                   5362: If not specified, an attempt is made to
                   5363: load the parameters from the server certificate file.
                   5364: If this fails, a static set of parameters hard coded into the
                   5365: .Nm s_server
                   5366: program will be used.
                   5367: .It Fl hack
                   5368: This option enables a further workaround for some early Netscape
                   5369: SSL code
                   5370: .Pq \&? .
                   5371: .It Fl HTTP
                   5372: Emulates a simple web server.
                   5373: Pages will be resolved relative to the current directory;
                   5374: for example if the URL
                   5375: .Pa https://myhost/page.html
                   5376: is requested, the file
                   5377: .Pa ./page.html
                   5378: will be loaded.
                   5379: The files loaded are assumed to contain a complete and correct HTTP
                   5380: response (lines that are part of the HTTP response line and headers
                   5381: must end with CRLF).
                   5382: .It Fl id_prefix Ar arg
                   5383: Generate SSL/TLS session IDs prefixed by
                   5384: .Ar arg .
                   5385: This is mostly useful for testing any SSL/TLS code
                   5386: .Pq e.g. proxies
                   5387: that wish to deal with multiple servers, when each of which might be
                   5388: generating a unique range of session IDs
                   5389: .Pq e.g. with a certain prefix .
                   5390: .It Fl key Ar keyfile
                   5391: The private key to use.
                   5392: If not specified, the certificate file will be used.
                   5393: .It Fl msg
                   5394: Show all protocol messages with hex dump.
                   5395: .It Fl nbio
                   5396: Turns on non-blocking I/O.
                   5397: .It Fl nbio_test
                   5398: Tests non-blocking I/O.
                   5399: .It Fl no_dhe
                   5400: If this option is set, no DH parameters will be loaded, effectively
                   5401: disabling the ephemeral DH cipher suites.
1.31      jmc      5402: .It Fl no_tls1 | no_tls1_1 | no_tls1_2
1.1       jsing    5403: By default, the initial handshake uses a method which should be compatible
1.32      jmc      5404: with clients supporting any version of TLS.
1.31      jmc      5405: These options disable the use of TLS1.0, 1.1, and 1.2, respectively.
1.1       jsing    5406: .It Fl no_tmp_rsa
                   5407: Certain export cipher suites sometimes use a temporary RSA key; this option
                   5408: disables temporary RSA key generation.
                   5409: .It Fl nocert
                   5410: If this option is set, no certificate is used.
                   5411: This restricts the cipher suites available to the anonymous ones
                   5412: .Pq currently just anonymous DH .
                   5413: .It Fl psk Ar key
                   5414: Use the PSK key
                   5415: .Ar key
                   5416: when using a PSK cipher suite.
                   5417: The key is given as a hexadecimal number without the leading 0x,
                   5418: for example -psk 1a2b3c4d.
                   5419: .It Fl psk_hint Ar hint
                   5420: Use the PSK identity hint
                   5421: .Ar hint
                   5422: when using a PSK cipher suite.
                   5423: .It Fl quiet
                   5424: Inhibit printing of session and certificate information.
                   5425: .It Fl serverpref
                   5426: Use server's cipher preferences.
                   5427: .It Fl state
                   5428: Prints out the SSL session states.
1.31      jmc      5429: .It Fl tls1 | tls1_1 | tls1_2
                   5430: Permit only TLS1.0, 1.1, or 1.2, respectively.
1.1       jsing    5431: .It Fl WWW
                   5432: Emulates a simple web server.
                   5433: Pages will be resolved relative to the current directory;
                   5434: for example if the URL
                   5435: .Pa https://myhost/page.html
                   5436: is requested, the file
                   5437: .Pa ./page.html
                   5438: will be loaded.
                   5439: .It Fl www
                   5440: Sends a status message back to the client when it connects.
                   5441: This includes lots of information about the ciphers used and various
                   5442: session parameters.
                   5443: The output is in HTML format so this option will normally be used with a
                   5444: web browser.
                   5445: .It Fl Verify Ar depth , Fl verify Ar depth
                   5446: The verify
                   5447: .Ar depth
                   5448: to use.
                   5449: This specifies the maximum length of the client certificate chain
                   5450: and makes the server request a certificate from the client.
                   5451: With the
                   5452: .Fl Verify
                   5453: option, the client must supply a certificate or an error occurs.
                   5454: With the
                   5455: .Fl verify
                   5456: option, a certificate is requested but the client does not have to send one.
                   5457: .El
                   5458: .Sh S_SERVER CONNECTED COMMANDS
                   5459: If a connection request is established with an SSL client and neither the
                   5460: .Fl www
                   5461: nor the
                   5462: .Fl WWW
                   5463: option has been used, then normally any data received
                   5464: from the client is displayed and any key presses will be sent to the client.
                   5465: .Pp
                   5466: Certain single letter commands are also recognized which perform special
                   5467: operations: these are listed below.
                   5468: .Bl -tag -width "XXXX"
                   5469: .It Ar P
                   5470: Send some plain text down the underlying TCP connection: this should
                   5471: cause the client to disconnect due to a protocol violation.
                   5472: .It Ar Q
                   5473: End the current SSL connection and exit.
                   5474: .It Ar q
                   5475: End the current SSL connection, but still accept new connections.
                   5476: .It Ar R
                   5477: Renegotiate the SSL session and request a client certificate.
                   5478: .It Ar r
                   5479: Renegotiate the SSL session.
                   5480: .It Ar S
                   5481: Print out some session cache status information.
                   5482: .El
                   5483: .Sh S_SERVER NOTES
                   5484: .Nm s_server
                   5485: can be used to debug SSL clients.
                   5486: To accept connections from a web browser the command:
                   5487: .Pp
                   5488: .Dl $ openssl s_server -accept 443 -www
                   5489: .Pp
                   5490: can be used, for example.
                   5491: .Pp
                   5492: Most web browsers
                   5493: .Pq in particular Netscape and MSIE
                   5494: only support RSA cipher suites, so they cannot connect to servers
                   5495: which don't use a certificate carrying an RSA key or a version of
                   5496: .Nm OpenSSL
                   5497: with RSA disabled.
                   5498: .Pp
                   5499: Although specifying an empty list of CAs when requesting a client certificate
                   5500: is strictly speaking a protocol violation, some SSL
                   5501: clients interpret this to mean any CA is acceptable.
                   5502: This is useful for debugging purposes.
                   5503: .Pp
                   5504: The session parameters can printed out using the
                   5505: .Nm sess_id
                   5506: program.
                   5507: .Sh S_SERVER BUGS
                   5508: Because this program has a lot of options and also because some of
                   5509: the techniques used are rather old, the C source of
                   5510: .Nm s_server
                   5511: is rather hard to read and not a model of how things should be done.
                   5512: A typical SSL server program would be much simpler.
                   5513: .Pp
                   5514: The output of common ciphers is wrong: it just gives the list of ciphers that
                   5515: .Nm OpenSSL
                   5516: recognizes and the client supports.
                   5517: .Pp
                   5518: There should be a way for the
                   5519: .Nm s_server
                   5520: program to print out details of any
                   5521: unknown cipher suites a client says it supports.
                   5522: .\"
                   5523: .\" S_TIME
                   5524: .\"
                   5525: .Sh S_TIME
                   5526: .nr nS 1
                   5527: .Nm "openssl s_time"
                   5528: .Bk -words
                   5529: .Op Fl bugs
                   5530: .Op Fl CAfile Ar file
                   5531: .Op Fl CApath Ar directory
                   5532: .Op Fl cert Ar file
                   5533: .Op Fl cipher Ar cipherlist
                   5534: .Op Fl connect Ar host : Ns Ar port
                   5535: .Op Fl key Ar keyfile
                   5536: .Op Fl nbio
                   5537: .Op Fl new
1.20      lteo     5538: .Op Fl no_shutdown
1.1       jsing    5539: .Op Fl reuse
                   5540: .Op Fl time Ar seconds
                   5541: .Op Fl verify Ar depth
                   5542: .Op Fl www Ar page
                   5543: .Ek
                   5544: .nr nS 0
                   5545: .Pp
                   5546: The
                   5547: .Nm s_client
                   5548: command implements a generic SSL/TLS client which connects to a
                   5549: remote host using SSL/TLS.
                   5550: It can request a page from the server and includes
                   5551: the time to transfer the payload data in its timing measurements.
                   5552: It measures the number of connections within a given timeframe,
                   5553: the amount of data transferred
                   5554: .Pq if any ,
                   5555: and calculates the average time spent for one connection.
                   5556: .Pp
                   5557: The options are as follows:
                   5558: .Bl -tag -width Ds
                   5559: .It Fl bugs
                   5560: There are several known bugs in SSL and TLS implementations.
                   5561: Adding this option enables various workarounds.
                   5562: .It Fl CAfile Ar file
                   5563: A file containing trusted certificates to use during server authentication
                   5564: and to use when attempting to build the client certificate chain.
                   5565: .It Fl CApath Ar directory
                   5566: The directory to use for server certificate verification.
                   5567: This directory must be in
                   5568: .Qq hash format ;
                   5569: see
                   5570: .Nm verify
                   5571: for more information.
                   5572: These are also used when building the client certificate chain.
                   5573: .It Fl cert Ar file
                   5574: The certificate to use, if one is requested by the server.
                   5575: The default is not to use a certificate.
                   5576: The file is in PEM format.
                   5577: .It Fl cipher Ar cipherlist
                   5578: This allows the cipher list sent by the client to be modified.
                   5579: Although the server determines which cipher suite is used,
                   5580: it should take the first supported cipher in the list sent by the client.
                   5581: See the
                   5582: .Nm ciphers
                   5583: command for more information.
                   5584: .It Fl connect Ar host : Ns Ar port
                   5585: This specifies the host and optional port to connect to.
                   5586: .It Fl key Ar keyfile
                   5587: The private key to use.
                   5588: If not specified, the certificate file will be used.
                   5589: The file is in PEM format.
                   5590: .It Fl nbio
                   5591: Turns on non-blocking I/O.
                   5592: .It Fl new
                   5593: Performs the timing test using a new session ID for each connection.
                   5594: If neither
                   5595: .Fl new
                   5596: nor
                   5597: .Fl reuse
                   5598: are specified,
                   5599: they are both on by default and executed in sequence.
1.20      lteo     5600: .It Fl no_shutdown
1.21      jmc      5601: Shut down the connection without sending a
1.20      lteo     5602: .Dq close notify
                   5603: shutdown alert to the server.
1.1       jsing    5604: .It Fl reuse
                   5605: Performs the timing test using the same session ID;
                   5606: this can be used as a test that session caching is working.
                   5607: If neither
                   5608: .Fl new
                   5609: nor
                   5610: .Fl reuse
                   5611: are specified,
                   5612: they are both on by default and executed in sequence.
                   5613: .It Fl time Ar seconds
                   5614: Specifies how long
                   5615: .Pq in seconds
                   5616: .Nm s_time
                   5617: should establish connections and
                   5618: optionally transfer payload data from a server.
                   5619: The default is 30 seconds.
                   5620: Server and client performance and the link speed
                   5621: determine how many connections
                   5622: .Nm s_time
                   5623: can establish.
                   5624: .It Fl verify Ar depth
                   5625: The verify depth to use.
                   5626: This specifies the maximum length of the server certificate chain
                   5627: and turns on server certificate verification.
                   5628: Currently the verify operation continues after errors, so all the problems
                   5629: with a certificate chain can be seen.
                   5630: As a side effect,
                   5631: the connection will never fail due to a server certificate verify failure.
                   5632: .It Fl www Ar page
                   5633: This specifies the page to GET from the server.
                   5634: A value of
                   5635: .Sq /
                   5636: gets the index.htm[l] page.
                   5637: If this parameter is not specified,
                   5638: .Nm s_time
                   5639: will only perform the handshake to establish SSL connections
                   5640: but not transfer any payload data.
                   5641: .El
                   5642: .Sh S_TIME NOTES
                   5643: .Nm s_client
                   5644: can be used to measure the performance of an SSL connection.
                   5645: To connect to an SSL HTTP server and get the default page the command
                   5646: .Bd -literal -offset indent
                   5647: $ openssl s_time -connect servername:443 -www / -CApath yourdir \e
1.18      jmc      5648:        -CAfile yourfile.pem -cipher commoncipher
1.1       jsing    5649: .Ed
                   5650: .Pp
                   5651: would typically be used
                   5652: .Pq HTTPS uses port 443 .
                   5653: .Dq commoncipher
                   5654: is a cipher to which both client and server can agree;
                   5655: see the
                   5656: .Nm ciphers
                   5657: command for details.
                   5658: .Pp
                   5659: If the handshake fails, there are several possible causes:
                   5660: if it is nothing obvious like no client certificate, the
                   5661: .Fl bugs
1.18      jmc      5662: option can be tried in case it is a buggy server.
1.1       jsing    5663: .Pp
                   5664: A frequent problem when attempting to get client certificates working
                   5665: is that a web client complains it has no certificates or gives an empty
                   5666: list to choose from.
                   5667: This is normally because the server is not sending
                   5668: the clients certificate authority in its
                   5669: .Qq acceptable CA list
                   5670: when it requests a certificate.
                   5671: By using
                   5672: .Nm s_client ,
                   5673: the CA list can be viewed and checked.
                   5674: However some servers only request client authentication
                   5675: after a specific URL is requested.
                   5676: To obtain the list in this case, it is necessary to use the
                   5677: .Fl prexit
                   5678: option of
                   5679: .Nm s_client
                   5680: and send an HTTP request for an appropriate page.
                   5681: .Pp
                   5682: If a certificate is specified on the command line using the
                   5683: .Fl cert
                   5684: option,
                   5685: it will not be used unless the server specifically requests
                   5686: a client certificate.
                   5687: Therefore merely including a client certificate
                   5688: on the command line is no guarantee that the certificate works.
                   5689: .Sh S_TIME BUGS
                   5690: Because this program does not have all the options of the
                   5691: .Nm s_client
                   5692: program to turn protocols on and off,
                   5693: you may not be able to measure the performance
                   5694: of all protocols with all servers.
                   5695: .Pp
                   5696: The
                   5697: .Fl verify
                   5698: option should really exit if the server verification fails.
                   5699: .\"
                   5700: .\" SESS_ID
                   5701: .\"
                   5702: .Sh SESS_ID
                   5703: .nr nS 1
                   5704: .Nm "openssl sess_id"
                   5705: .Bk -words
                   5706: .Op Fl cert
                   5707: .Op Fl context Ar ID
                   5708: .Op Fl in Ar file
                   5709: .Op Fl inform Ar DER | PEM
                   5710: .Op Fl noout
                   5711: .Op Fl out Ar file
                   5712: .Op Fl outform Ar DER | PEM
                   5713: .Op Fl text
                   5714: .Ek
                   5715: .nr nS 0
                   5716: .Pp
                   5717: The
                   5718: .Nm sess_id
                   5719: program processes the encoded version of the SSL session structure and
                   5720: optionally prints out SSL session details
                   5721: .Pq for example the SSL session master key
                   5722: in human readable format.
                   5723: Since this is a diagnostic tool that needs some knowledge of the SSL
                   5724: protocol to use properly, most users will not need to use it.
                   5725: .Pp
                   5726: The options are as follows:
                   5727: .Bl -tag -width Ds
                   5728: .It Fl cert
                   5729: If a certificate is present in the session,
                   5730: it will be output using this option;
                   5731: if the
                   5732: .Fl text
                   5733: option is also present, then it will be printed out in text form.
                   5734: .It Fl context Ar ID
                   5735: This option can set the session ID so the output session information uses the
                   5736: supplied
                   5737: .Ar ID .
                   5738: The
                   5739: .Ar ID
                   5740: can be any string of characters.
                   5741: This option won't normally be used.
                   5742: .It Fl in Ar file
                   5743: This specifies the input
                   5744: .Ar file
                   5745: to read session information from, or standard input by default.
                   5746: .It Fl inform Ar DER | PEM
                   5747: This specifies the input format.
                   5748: The
                   5749: .Ar DER
                   5750: argument uses an ASN1 DER-encoded
                   5751: format containing session details.
                   5752: The precise format can vary from one version to the next.
                   5753: The
                   5754: .Ar PEM
                   5755: form is the default format: it consists of the DER
                   5756: format base64-encoded with additional header and footer lines.
                   5757: .It Fl noout
                   5758: This option prevents output of the encoded version of the session.
                   5759: .It Fl out Ar file
                   5760: This specifies the output
                   5761: .Ar file
                   5762: to write session information to, or standard
                   5763: output if this option is not specified.
                   5764: .It Fl outform Ar DER | PEM
                   5765: This specifies the output format; the options have the same meaning as the
                   5766: .Fl inform
                   5767: option.
                   5768: .It Fl text
                   5769: Prints out the various public or private key components in
                   5770: plain text in addition to the encoded version.
                   5771: .El
                   5772: .Sh SESS_ID OUTPUT
                   5773: Typical output:
                   5774: .Bd -literal
                   5775: SSL-Session:
                   5776:     Protocol  : TLSv1
                   5777:     Cipher    : 0016
                   5778:     Session-ID: 871E62626C554CE95488823752CBD5F3673A3EF3DCE9C67BD916C809914B40ED
                   5779:     Session-ID-ctx: 01000000
                   5780:     Master-Key: A7CEFC571974BE02CAC305269DC59F76EA9F0B180CB6642697A68251F2D2BB57E51DBBB4C7885573192AE9AEE220FACD
                   5781:     Key-Arg   : None
                   5782:     Start Time: 948459261
                   5783:     Timeout   : 300 (sec)
                   5784:     Verify return code 0 (ok)
                   5785: .Ed
                   5786: .Pp
                   5787: These are described below in more detail.
                   5788: .Pp
                   5789: .Bl -tag -width "Verify return code " -compact
                   5790: .It Ar Protocol
1.18      jmc      5791: This is the protocol in use.
1.1       jsing    5792: .It Ar Cipher
                   5793: The cipher used is the actual raw SSL or TLS cipher code;
                   5794: see the SSL or TLS specifications for more information.
                   5795: .It Ar Session-ID
                   5796: The SSL session ID in hex format.
                   5797: .It Ar Session-ID-ctx
                   5798: The session ID context in hex format.
                   5799: .It Ar Master-Key
                   5800: This is the SSL session master key.
                   5801: .It Ar Key-Arg
                   5802: The key argument; this is only used in SSL v2.
                   5803: .It Ar Start Time
                   5804: This is the session start time, represented as an integer in standard
                   5805: .Ux
                   5806: format.
                   5807: .It Ar Timeout
                   5808: The timeout in seconds.
                   5809: .It Ar Verify return code
                   5810: This is the return code when an SSL client certificate is verified.
                   5811: .El
                   5812: .Sh SESS_ID NOTES
                   5813: The PEM-encoded session format uses the header and footer lines:
                   5814: .Bd -unfilled -offset indent
                   5815: -----BEGIN SSL SESSION PARAMETERS-----
                   5816: -----END SSL SESSION PARAMETERS-----
                   5817: .Ed
                   5818: .Pp
                   5819: Since the SSL session output contains the master key, it is possible to read
                   5820: the contents of an encrypted session using this information.
                   5821: Therefore appropriate security precautions
                   5822: should be taken if the information is being output by a
                   5823: .Qq real
                   5824: application.
                   5825: This is, however, strongly discouraged and should only be used for
                   5826: debugging purposes.
                   5827: .Sh SESS_ID BUGS
                   5828: The cipher and start time should be printed out in human readable form.
                   5829: .\"
                   5830: .\" SMIME
                   5831: .\"
                   5832: .Sh SMIME
                   5833: .nr nS 1
                   5834: .Nm "openssl smime"
                   5835: .Bk -words
                   5836: .Oo
                   5837: .Fl aes128 | aes192 | aes256 | des |
                   5838: .Fl des3 | rc2-40 | rc2-64 | rc2-128
                   5839: .Oc
                   5840: .Op Fl binary
                   5841: .Op Fl CAfile Ar file
                   5842: .Op Fl CApath Ar directory
                   5843: .Op Fl certfile Ar file
                   5844: .Op Fl check_ss_sig
                   5845: .Op Fl content Ar file
                   5846: .Op Fl crl_check
                   5847: .Op Fl crl_check_all
                   5848: .Op Fl decrypt
                   5849: .Op Fl encrypt
                   5850: .Op Fl extended_crl
                   5851: .Op Fl from Ar addr
                   5852: .Op Fl ignore_critical
                   5853: .Op Fl in Ar file
                   5854: .Op Fl indef
                   5855: .Op Fl inform Ar DER | PEM | SMIME
                   5856: .Op Fl inkey Ar file
                   5857: .Op Fl issuer_checks
1.22      bcook    5858: .Op Fl keyform Ar PEM
1.1       jsing    5859: .Op Fl md Ar digest
                   5860: .Op Fl noattr
                   5861: .Op Fl nocerts
                   5862: .Op Fl nochain
                   5863: .Op Fl nodetach
                   5864: .Op Fl noindef
                   5865: .Op Fl nointern
                   5866: .Op Fl nosigs
                   5867: .Op Fl noverify
                   5868: .Op Fl out Ar file
                   5869: .Op Fl outform Ar DER | PEM | SMIME
                   5870: .Op Fl passin Ar arg
                   5871: .Op Fl pk7out
                   5872: .Op Fl policy_check
                   5873: .Op Fl recip Ar file
                   5874: .Op Fl resign
                   5875: .Op Fl sign
                   5876: .Op Fl signer Ar file
                   5877: .Op Fl stream
                   5878: .Op Fl subject Ar s
                   5879: .Op Fl text
                   5880: .Op Fl to Ar addr
                   5881: .Op Fl verify
                   5882: .Op Fl x509_strict
                   5883: .Op Ar cert.pem ...
                   5884: .Ek
                   5885: .nr nS 0
                   5886: .Pp
                   5887: The
                   5888: .Nm smime
                   5889: command handles
                   5890: .Em S/MIME
                   5891: mail.
                   5892: It can encrypt, decrypt, sign, and verify
                   5893: .Em S/MIME
                   5894: messages.
                   5895: .Pp
                   5896: There are six operation options that set the type of operation to be performed.
                   5897: The meaning of the other options varies according to the operation type.
                   5898: .Pp
                   5899: The six operation options are as follows:
                   5900: .Bl -tag -width "XXXX"
                   5901: .It Fl decrypt
                   5902: Decrypt mail using the supplied certificate and private key.
                   5903: Expects an encrypted mail message in
                   5904: .Em MIME
                   5905: format for the input file.
                   5906: The decrypted mail is written to the output file.
                   5907: .It Fl encrypt
                   5908: Encrypt mail for the given recipient certificates.
                   5909: Input file is the message to be encrypted.
                   5910: The output file is the encrypted mail in
                   5911: .Em MIME
                   5912: format.
                   5913: .It Fl pk7out
                   5914: Takes an input message and writes out a PEM-encoded PKCS#7 structure.
                   5915: .It Fl resign
                   5916: Resign a message: take an existing message and one or more new signers.
                   5917: .It Fl sign
                   5918: Sign mail using the supplied certificate and private key.
                   5919: Input file is the message to be signed.
                   5920: The signed message in
                   5921: .Em MIME
                   5922: format is written to the output file.
                   5923: .It Fl verify
                   5924: Verify signed mail.
                   5925: Expects a signed mail message on input and outputs the signed data.
                   5926: Both clear text and opaque signing is supported.
                   5927: .El
                   5928: .Pp
1.14      jmc      5929: The remaining options are as follows:
1.1       jsing    5930: .Bl -tag -width "XXXX"
                   5931: .It Xo
                   5932: .Fl aes128 | aes192 | aes256 | des |
                   5933: .Fl des3 | rc2-40 | rc2-64 | rc2-128
                   5934: .Xc
                   5935: The encryption algorithm to use.
                   5936: 128-, 192-, or 256-bit AES,
                   5937: DES
                   5938: .Pq 56 bits ,
                   5939: triple DES
                   5940: .Pq 168 bits ,
                   5941: or 40-, 64-, or 128-bit RC2, respectively;
                   5942: if not specified, 40-bit RC2 is
                   5943: used.
                   5944: Only used with
                   5945: .Fl encrypt .
                   5946: .It Fl binary
                   5947: Normally, the input message is converted to
                   5948: .Qq canonical
                   5949: format which is effectively using CR and LF as end of line \-
                   5950: as required by the
                   5951: .Em S/MIME
                   5952: specification.
                   5953: When this option is present no translation occurs.
                   5954: This is useful when handling binary data which may not be in
                   5955: .Em MIME
                   5956: format.
                   5957: .It Fl CAfile Ar file
                   5958: A
                   5959: .Ar file
                   5960: containing trusted CA certificates; only used with
                   5961: .Fl verify .
                   5962: .It Fl CApath Ar directory
                   5963: A
                   5964: .Ar directory
                   5965: containing trusted CA certificates; only used with
                   5966: .Fl verify .
                   5967: This directory must be a standard certificate directory:
                   5968: that is, a hash of each subject name (using
                   5969: .Nm x509 -hash )
                   5970: should be linked to each certificate.
                   5971: .It Ar cert.pem ...
                   5972: One or more certificates of message recipients: used when encrypting
                   5973: a message.
                   5974: .It Fl certfile Ar file
                   5975: Allows additional certificates to be specified.
                   5976: When signing, these will be included with the message.
                   5977: When verifying, these will be searched for the signers' certificates.
                   5978: The certificates should be in PEM format.
                   5979: .It Xo
                   5980: .Fl check_ss_sig ,
                   5981: .Fl crl_check ,
                   5982: .Fl crl_check_all ,
                   5983: .Fl extended_crl ,
                   5984: .Fl ignore_critical ,
                   5985: .Fl issuer_checks ,
                   5986: .Fl policy_check ,
                   5987: .Fl x509_strict
                   5988: .Xc
                   5989: Set various certificate chain validation options.
                   5990: See the
                   5991: .Nm VERIFY
                   5992: command for details.
                   5993: .It Fl content Ar file
                   5994: This specifies a file containing the detached content.
                   5995: This is only useful with the
                   5996: .Fl verify
                   5997: command.
                   5998: This is only usable if the PKCS#7 structure is using the detached
                   5999: signature form where the content is not included.
                   6000: This option will override any content if the input format is
                   6001: .Em S/MIME
                   6002: and it uses the multipart/signed
                   6003: .Em MIME
                   6004: content type.
                   6005: .It Xo
                   6006: .Fl from Ar addr ,
                   6007: .Fl subject Ar s ,
                   6008: .Fl to Ar addr
                   6009: .Xc
                   6010: The relevant mail headers.
                   6011: These are included outside the signed
                   6012: portion of a message so they may be included manually.
                   6013: When signing, many
                   6014: .Em S/MIME
                   6015: mail clients check that the signer's certificate email
                   6016: address matches the From: address.
                   6017: .It Fl in Ar file
                   6018: The input message to be encrypted or signed or the
                   6019: .Em MIME
                   6020: message to
                   6021: be decrypted or verified.
                   6022: .It Fl indef
                   6023: Enable streaming I/O for encoding operations.
                   6024: This permits single pass processing of data without
                   6025: the need to hold the entire contents in memory,
                   6026: potentially supporting very large files.
                   6027: Streaming is automatically set for S/MIME signing with detached
                   6028: data if the output format is SMIME;
                   6029: it is currently off by default for all other operations.
                   6030: .It Fl inform Ar DER | PEM | SMIME
                   6031: This specifies the input format for the PKCS#7 structure.
                   6032: The default is
                   6033: .Em SMIME ,
                   6034: which reads an
                   6035: .Em S/MIME
                   6036: format message.
                   6037: .Ar PEM
                   6038: and
                   6039: .Ar DER
                   6040: format change this to expect PEM and DER format PKCS#7 structures
                   6041: instead.
                   6042: This currently only affects the input format of the PKCS#7
                   6043: structure; if no PKCS#7 structure is being input (for example with
                   6044: .Fl encrypt
                   6045: or
                   6046: .Fl sign ) ,
                   6047: this option has no effect.
                   6048: .It Fl inkey Ar file
                   6049: The private key to use when signing or decrypting.
                   6050: This must match the corresponding certificate.
                   6051: If this option is not specified, the private key must be included
                   6052: in the certificate file specified with
                   6053: the
                   6054: .Fl recip
                   6055: or
                   6056: .Fl signer
                   6057: file.
                   6058: When signing,
                   6059: this option can be used multiple times to specify successive keys.
1.22      bcook    6060: .It Fl keyform Ar PEM
1.1       jsing    6061: Input private key format.
                   6062: .It Fl md Ar digest
                   6063: The digest algorithm to use when signing or resigning.
                   6064: If not present then the default digest algorithm for the signing key is used
                   6065: (usually SHA1).
                   6066: .It Fl noattr
                   6067: Normally, when a message is signed a set of attributes are included which
                   6068: include the signing time and supported symmetric algorithms.
                   6069: With this option they are not included.
                   6070: .It Fl nocerts
                   6071: When signing a message, the signer's certificate is normally included;
                   6072: with this option it is excluded.
                   6073: This will reduce the size of the signed message but the verifier must
                   6074: have a copy of the signer's certificate available locally (passed using the
                   6075: .Fl certfile
                   6076: option, for example).
                   6077: .It Fl nochain
                   6078: Do not do chain verification of signers' certificates: that is,
                   6079: don't use the certificates in the signed message as untrusted CAs.
                   6080: .It Fl nodetach
                   6081: When signing a message use opaque signing: this form is more resistant
                   6082: to translation by mail relays but it cannot be read by mail agents that
                   6083: do not support
                   6084: .Em S/MIME .
                   6085: Without this option cleartext signing with the
                   6086: .Em MIME
                   6087: type multipart/signed is used.
                   6088: .It Fl noindef
                   6089: Disable streaming I/O where it would produce an encoding of indefinite length.
                   6090: This option currently has no effect.
                   6091: In future streaming will be enabled by default on all relevant operations
                   6092: and this option will disable it.
                   6093: .It Fl nointern
                   6094: When verifying a message, normally certificates
                   6095: .Pq if any
                   6096: included in the message are searched for the signing certificate.
                   6097: With this option, only the certificates specified in the
                   6098: .Fl certfile
                   6099: option are used.
                   6100: The supplied certificates can still be used as untrusted CAs however.
                   6101: .It Fl nosigs
                   6102: Don't try to verify the signatures on the message.
                   6103: .It Fl noverify
                   6104: Do not verify the signer's certificate of a signed message.
                   6105: .It Fl out Ar file
                   6106: The message text that has been decrypted or verified, or the output
                   6107: .Em MIME
                   6108: format message that has been signed or verified.
                   6109: .It Fl outform Ar DER | PEM | SMIME
                   6110: This specifies the output format for the PKCS#7 structure.
                   6111: The default is
                   6112: .Em SMIME ,
                   6113: which writes an
                   6114: .Em S/MIME
                   6115: format message.
                   6116: .Ar PEM
                   6117: and
                   6118: .Ar DER
                   6119: format change this to write PEM and DER format PKCS#7 structures
                   6120: instead.
                   6121: This currently only affects the output format of the PKCS#7
                   6122: structure; if no PKCS#7 structure is being output (for example with
                   6123: .Fl verify
                   6124: or
                   6125: .Fl decrypt )
                   6126: this option has no effect.
                   6127: .It Fl passin Ar arg
                   6128: The key password source.
                   6129: .It Fl recip Ar file
                   6130: The recipients certificate when decrypting a message.
                   6131: This certificate
                   6132: must match one of the recipients of the message or an error occurs.
                   6133: .It Fl signer Ar file
                   6134: A signing certificate when signing or resigning a message;
                   6135: this option can be used multiple times if more than one signer is required.
                   6136: If a message is being verified, the signer's certificates will be
                   6137: written to this file if the verification was successful.
                   6138: .It Fl stream
                   6139: The same as
                   6140: .Fl indef .
                   6141: .It Fl text
                   6142: This option adds plain text
                   6143: .Pq text/plain
                   6144: .Em MIME
                   6145: headers to the supplied message if encrypting or signing.
                   6146: If decrypting or verifying, it strips off text headers:
                   6147: if the decrypted or verified message is not of
                   6148: .Em MIME
                   6149: type text/plain then an error occurs.
                   6150: .El
                   6151: .Sh SMIME NOTES
                   6152: The
                   6153: .Em MIME
                   6154: message must be sent without any blank lines between the
                   6155: headers and the output.
                   6156: Some mail programs will automatically add a blank line.
1.3       jmc      6157: Piping the mail directly to an MTA is one way to
1.1       jsing    6158: achieve the correct format.
                   6159: .Pp
                   6160: The supplied message to be signed or encrypted must include the
                   6161: necessary
                   6162: .Em MIME
                   6163: headers or many
                   6164: .Em S/MIME
                   6165: clients won't display it properly
                   6166: .Pq if at all .
                   6167: You can use the
                   6168: .Fl text
                   6169: option to automatically add plain text headers.
                   6170: .Pp
                   6171: A
                   6172: .Qq signed and encrypted
                   6173: message is one where a signed message is then encrypted.
                   6174: This can be produced by encrypting an already signed message:
                   6175: see the
                   6176: .Sx SMIME EXAMPLES
                   6177: section.
                   6178: .Pp
                   6179: This version of the program only allows one signer per message, but it
                   6180: will verify multiple signers on received messages.
                   6181: Some
                   6182: .Em S/MIME
                   6183: clients choke if a message contains multiple signers.
                   6184: It is possible to sign messages
                   6185: .Qq in parallel
                   6186: by signing an already signed message.
                   6187: .Pp
                   6188: The options
                   6189: .Fl encrypt
                   6190: and
                   6191: .Fl decrypt
                   6192: reflect common usage in
                   6193: .Em S/MIME
                   6194: clients.
                   6195: Strictly speaking these process PKCS#7 enveloped data: PKCS#7
                   6196: encrypted data is used for other purposes.
                   6197: .Pp
                   6198: The
                   6199: .Fl resign
                   6200: option uses an existing message digest when adding a new signer.
                   6201: This means that attributes must be present in at least one existing
                   6202: signer using the same message digest or this operation will fail.
                   6203: .Pp
                   6204: The
                   6205: .Fl stream
                   6206: and
                   6207: .Fl indef
                   6208: options enable experimental streaming I/O support.
                   6209: As a result the encoding is BER using indefinite length constructed encoding
                   6210: and no longer DER.
                   6211: Streaming is supported for the
                   6212: .Fl encrypt
                   6213: and
                   6214: .Fl sign
                   6215: operations if the content is not detached.
                   6216: .Pp
                   6217: Streaming is always used for the
                   6218: .Fl sign
                   6219: operation with detached data
                   6220: but since the content is no longer part of the PKCS#7 structure
                   6221: the encoding remains DER.
                   6222: .Sh SMIME EXIT CODES
                   6223: .Bl -tag -width "XXXX"
                   6224: .It Ar 0
                   6225: The operation was completely successful.
                   6226: .It Ar 1
                   6227: An error occurred parsing the command options.
                   6228: .It Ar 2
                   6229: One of the input files could not be read.
                   6230: .It Ar 3
                   6231: An error occurred creating the PKCS#7 file or when reading the
                   6232: .Em MIME
                   6233: message.
                   6234: .It Ar 4
                   6235: An error occurred decrypting or verifying the message.
                   6236: .It Ar 5
                   6237: The message was verified correctly, but an error occurred writing out
                   6238: the signer's certificates.
                   6239: .El
                   6240: .Sh SMIME EXAMPLES
                   6241: Create a cleartext signed message:
                   6242: .Bd -literal -offset indent
                   6243: $ openssl smime -sign -in message.txt -text -out mail.msg \e
                   6244:        -signer mycert.pem
                   6245: .Ed
                   6246: .Pp
                   6247: Create an opaque signed message:
                   6248: .Bd -literal -offset indent
                   6249: $ openssl smime -sign -in message.txt -text -out mail.msg \e
                   6250:        -nodetach -signer mycert.pem
                   6251: .Ed
                   6252: .Pp
                   6253: Create a signed message, include some additional certificates and
                   6254: read the private key from another file:
                   6255: .Bd -literal -offset indent
                   6256: $ openssl smime -sign -in in.txt -text -out mail.msg \e
                   6257:        -signer mycert.pem -inkey mykey.pem -certfile mycerts.pem
                   6258: .Ed
                   6259: .Pp
                   6260: Create a signed message with two signers:
                   6261: .Bd -literal -offset indent
                   6262: openssl smime -sign -in message.txt -text -out mail.msg \e
                   6263:        -signer mycert.pem -signer othercert.pem
                   6264: .Ed
                   6265: .Pp
                   6266: Send a signed message under
                   6267: .Ux
                   6268: directly to
                   6269: .Xr sendmail 8 ,
                   6270: including headers:
                   6271: .Bd -literal -offset indent
                   6272: $ openssl smime -sign -in in.txt -text -signer mycert.pem \e
                   6273:        -from steve@openssl.org -to someone@somewhere \e
                   6274:        -subject "Signed message" | sendmail someone@somewhere
                   6275: .Ed
                   6276: .Pp
                   6277: Verify a message and extract the signer's certificate if successful:
                   6278: .Bd -literal -offset indent
                   6279: $ openssl smime -verify -in mail.msg -signer user.pem \e
                   6280:        -out signedtext.txt
                   6281: .Ed
                   6282: .Pp
                   6283: Send encrypted mail using triple DES:
                   6284: .Bd -literal -offset indent
                   6285: $ openssl smime -encrypt -in in.txt -from steve@openssl.org \e
                   6286:        -to someone@somewhere -subject "Encrypted message" \e
                   6287:        -des3 -out mail.msg user.pem
                   6288: .Ed
                   6289: .Pp
                   6290: Sign and encrypt mail:
                   6291: .Bd -literal -offset indent
                   6292: $ openssl smime -sign -in ml.txt -signer my.pem -text | \e
                   6293:        openssl smime -encrypt -out mail.msg \e
                   6294:        -from steve@openssl.org -to someone@somewhere \e
                   6295:        -subject "Signed and Encrypted message" -des3 user.pem
                   6296: .Ed
                   6297: .Pp
                   6298: .Sy Note :
                   6299: The encryption command does not include the
                   6300: .Fl text
                   6301: option because the message being encrypted already has
                   6302: .Em MIME
                   6303: headers.
                   6304: .Pp
                   6305: Decrypt mail:
                   6306: .Bd -literal -offset indent
                   6307: $ openssl smime -decrypt -in mail.msg -recip mycert.pem \e
                   6308:        -inkey key.pem"
                   6309: .Ed
                   6310: .Pp
                   6311: The output from Netscape form signing is a PKCS#7 structure with the
                   6312: detached signature format.
                   6313: You can use this program to verify the signature by line wrapping the
                   6314: base64-encoded structure and surrounding it with:
                   6315: .Bd -unfilled -offset indent
                   6316: -----BEGIN PKCS7-----
                   6317: -----END PKCS7-----
                   6318: .Ed
                   6319: .Pp
                   6320: and using the command:
                   6321: .Bd -literal -offset indent
                   6322: $ openssl smime -verify -inform PEM -in signature.pem \e
                   6323:        -content content.txt
                   6324: .Ed
                   6325: .Pp
                   6326: Alternatively, you can base64 decode the signature and use:
                   6327: .Bd -literal -offset indent
                   6328: $ openssl smime -verify -inform DER -in signature.der \e
                   6329:        -content content.txt
                   6330: .Ed
                   6331: .Pp
                   6332: Create an encrypted message using 128-bit AES:
                   6333: .Bd -literal -offset indent
                   6334: openssl smime -encrypt -in plain.txt -aes128 \e
                   6335:        -out mail.msg cert.pem
                   6336: .Ed
                   6337: .Pp
                   6338: Add a signer to an existing message:
                   6339: .Bd -literal -offset indent
                   6340: openssl smime -resign -in mail.msg -signer newsign.pem \e
                   6341:        -out mail2.msg
                   6342: .Ed
                   6343: .Sh SMIME BUGS
                   6344: The
                   6345: .Em MIME
                   6346: parser isn't very clever: it seems to handle most messages that I've thrown
                   6347: at it, but it may choke on others.
                   6348: .Pp
                   6349: The code currently will only write out the signer's certificate to a file:
                   6350: if the signer has a separate encryption certificate this must be manually
                   6351: extracted.
                   6352: There should be some heuristic that determines the correct encryption
                   6353: certificate.
                   6354: .Pp
                   6355: Ideally, a database should be maintained of a certificate for each email
                   6356: address.
                   6357: .Pp
                   6358: The code doesn't currently take note of the permitted symmetric encryption
                   6359: algorithms as supplied in the
                   6360: .Em SMIMECapabilities
                   6361: signed attribute.
                   6362: This means the user has to manually include the correct encryption algorithm.
                   6363: It should store the list of permitted ciphers in a database and only use those.
                   6364: .Pp
                   6365: No revocation checking is done on the signer's certificate.
                   6366: .Pp
                   6367: The current code can only handle
                   6368: .Em S/MIME
                   6369: v2 messages; the more complex
                   6370: .Em S/MIME
                   6371: v3 structures may cause parsing errors.
                   6372: .Sh SMIME HISTORY
                   6373: The use of multiple
                   6374: .Fl signer
                   6375: options and the
                   6376: .Fl resign
                   6377: command were first added in
                   6378: .Nm OpenSSL
                   6379: 1.0.0.
                   6380: .\"
                   6381: .\" SPEED
                   6382: .\"
                   6383: .Sh SPEED
                   6384: .nr nS 1
                   6385: .Nm "openssl speed"
                   6386: .Bk -words
                   6387: .Op Cm aes
                   6388: .Op Cm aes-128-cbc
                   6389: .Op Cm aes-192-cbc
                   6390: .Op Cm aes-256-cbc
1.25      bcook    6391: .Op Cm aes-128-gcm
                   6392: .Op Cm aes-256-gcm
1.1       jsing    6393: .Op Cm blowfish
                   6394: .Op Cm bf-cbc
                   6395: .Op Cm cast
                   6396: .Op Cm cast-cbc
1.25      bcook    6397: .Op Cm chacha20-poly1305
1.1       jsing    6398: .Op Cm des
                   6399: .Op Cm des-cbc
                   6400: .Op Cm des-ede3
                   6401: .Op Cm dsa
                   6402: .Op Cm dsa512
                   6403: .Op Cm dsa1024
                   6404: .Op Cm dsa2048
                   6405: .Op Cm hmac
1.28      doug     6406: .Op Cm md4
1.1       jsing    6407: .Op Cm md5
                   6408: .Op Cm rc2
                   6409: .Op Cm rc2-cbc
                   6410: .Op Cm rc4
                   6411: .Op Cm rmd160
                   6412: .Op Cm rsa
                   6413: .Op Cm rsa512
                   6414: .Op Cm rsa1024
                   6415: .Op Cm rsa2048
                   6416: .Op Cm rsa4096
                   6417: .Op Cm sha1
                   6418: .Op Fl decrypt
                   6419: .Op Fl elapsed
                   6420: .Op Fl evp Ar e
                   6421: .Op Fl mr
                   6422: .Op Fl multi Ar number
                   6423: .Ek
                   6424: .nr nS 0
                   6425: .Pp
                   6426: The
                   6427: .Nm speed
                   6428: command is used to test the performance of cryptographic algorithms.
                   6429: .Bl -tag -width "XXXX"
                   6430: .It Bq Cm zero or more test algorithms
                   6431: If any options are given,
                   6432: .Nm speed
                   6433: tests those algorithms, otherwise all of the above are tested.
                   6434: .It Fl decrypt
                   6435: Time decryption instead of encryption
                   6436: .Pq only EVP .
                   6437: .It Fl elapsed
                   6438: Measure time in real time instead of CPU user time.
                   6439: .It Fl evp Ar e
                   6440: Use EVP
                   6441: .Ar e .
                   6442: .It Fl mr
                   6443: Produce machine readable output.
                   6444: .It Fl multi Ar number
                   6445: Run
                   6446: .Ar number
                   6447: benchmarks in parallel.
                   6448: .El
                   6449: .\"
                   6450: .\" TS
                   6451: .\"
                   6452: .Sh TS
                   6453: .nr nS 1
                   6454: .Nm "openssl ts"
                   6455: .Bk -words
                   6456: .Fl query
1.29      bcook    6457: .Op Fl md4 | md5 | ripemd160 | sha1
1.1       jsing    6458: .Op Fl cert
                   6459: .Op Fl config Ar configfile
                   6460: .Op Fl data Ar file_to_hash
                   6461: .Op Fl digest Ar digest_bytes
                   6462: .Op Fl in Ar request.tsq
                   6463: .Op Fl no_nonce
                   6464: .Op Fl out Ar request.tsq
                   6465: .Op Fl policy Ar object_id
                   6466: .Op Fl text
                   6467: .Ek
                   6468: .nr nS 0
                   6469: .Pp
                   6470: .nr nS 1
                   6471: .Nm "openssl ts"
                   6472: .Bk -words
                   6473: .Fl reply
                   6474: .Op Fl chain Ar certs_file.pem
                   6475: .Op Fl config Ar configfile
                   6476: .Op Fl in Ar response.tsr
                   6477: .Op Fl inkey Ar private.pem
                   6478: .Op Fl out Ar response.tsr
                   6479: .Op Fl passin Ar arg
                   6480: .Op Fl policy Ar object_id
                   6481: .Op Fl queryfile Ar request.tsq
                   6482: .Op Fl section Ar tsa_section
                   6483: .Op Fl signer Ar tsa_cert.pem
                   6484: .Op Fl text
                   6485: .Op Fl token_in
                   6486: .Op Fl token_out
                   6487: .Ek
                   6488: .nr nS 0
                   6489: .Pp
                   6490: .nr nS 1
                   6491: .Nm "openssl ts"
                   6492: .Bk -words
                   6493: .Fl verify
                   6494: .Op Fl CAfile Ar trusted_certs.pem
                   6495: .Op Fl CApath Ar trusted_cert_path
                   6496: .Op Fl data Ar file_to_hash
                   6497: .Op Fl digest Ar digest_bytes
                   6498: .Op Fl in Ar response.tsr
                   6499: .Op Fl queryfile Ar request.tsq
                   6500: .Op Fl token_in
                   6501: .Op Fl untrusted Ar cert_file.pem
                   6502: .Ek
                   6503: .nr nS 0
                   6504: .Pp
                   6505: The
                   6506: .Nm ts
                   6507: command is a basic Time Stamping Authority (TSA) client and server
                   6508: application as specified in RFC 3161 (Time-Stamp Protocol, TSP).
                   6509: A TSA can be part of a PKI deployment and its role is to provide long
                   6510: term proof of the existence of a certain datum before a particular time.
                   6511: Here is a brief description of the protocol:
                   6512: .Bl -enum
                   6513: .It
                   6514: The TSA client computes a one-way hash value for a data file and sends
                   6515: the hash to the TSA.
                   6516: .It
                   6517: The TSA attaches the current date and time to the received hash value,
                   6518: signs them and sends the time stamp token back to the client.
                   6519: By creating this token the TSA certifies the existence of the original
                   6520: data file at the time of response generation.
                   6521: .It
                   6522: The TSA client receives the time stamp token and verifies the
                   6523: signature on it.
                   6524: It also checks if the token contains the same hash
                   6525: value that it had sent to the TSA.
                   6526: .El
                   6527: .Pp
                   6528: There is one DER-encoded protocol data unit defined for transporting a time
                   6529: stamp request to the TSA and one for sending the time stamp response
                   6530: back to the client.
                   6531: The
                   6532: .Nm ts
                   6533: command has three main functions:
                   6534: creating a time stamp request based on a data file;
                   6535: creating a time stamp response based on a request;
                   6536: and verifying if a response corresponds
                   6537: to a particular request or a data file.
                   6538: .Pp
                   6539: There is no support for sending the requests/responses automatically
                   6540: over HTTP or TCP yet as suggested in RFC 3161.
                   6541: Users must send the requests either by FTP or email.
                   6542: .Pp
                   6543: The
                   6544: .Fl query
                   6545: switch can be used for creating and printing a time stamp
                   6546: request with the following options:
                   6547: .Bl -tag -width Ds
                   6548: .It Fl cert
                   6549: The TSA is expected to include its signing certificate in the
                   6550: response.
                   6551: .It Fl config Ar configfile
                   6552: The configuration file to use.
                   6553: This option overrides the
                   6554: .Ev OPENSSL_CONF
                   6555: environment variable.
                   6556: Only the OID section of the config file is used with the
                   6557: .Fl query
                   6558: command.
                   6559: .It Fl data Ar file_to_hash
                   6560: The data file for which the time stamp request needs to be created.
                   6561: stdin is the default if neither the
                   6562: .Fl data
                   6563: nor the
                   6564: .Fl digest
                   6565: option is specified.
                   6566: .It Fl digest Ar digest_bytes
                   6567: It is possible to specify the message imprint explicitly without the data
                   6568: file.
                   6569: The imprint must be specified in a hexadecimal format,
                   6570: two characters per byte,
                   6571: the bytes optionally separated by colons (e.g. 1A:F6:01:... or 1AF601...).
                   6572: The number of bytes must match the message digest algorithm in use.
                   6573: .It Fl in Ar request.tsq
                   6574: This option specifies a previously created time stamp request in DER
                   6575: format that will be printed into the output file.
                   6576: Useful when you need to examine the content of a request in human-readable
                   6577: format.
1.28      doug     6578: .It Fl md4|md5|ripemd160|sha|sha1
1.1       jsing    6579: The message digest to apply to the data file.
                   6580: It supports all the message digest algorithms that are supported by the
                   6581: .Nm dgst
                   6582: command.
                   6583: The default is SHA-1.
                   6584: .It Fl no_nonce
                   6585: No nonce is specified in the request if this option is given.
                   6586: Otherwise a 64-bit long pseudo-random none is
                   6587: included in the request.
                   6588: It is recommended to use nonce to protect against replay-attacks.
                   6589: .It Fl out Ar request.tsq
                   6590: Name of the output file to which the request will be written.
                   6591: The default is stdout.
                   6592: .It Fl policy Ar object_id
                   6593: The policy that the client expects the TSA to use for creating the
                   6594: time stamp token.
                   6595: Either the dotted OID notation or OID names defined
                   6596: in the config file can be used.
                   6597: If no policy is requested the TSA will
                   6598: use its own default policy.
                   6599: .It Fl text
                   6600: If this option is specified the output is in human-readable text format
                   6601: instead of DER.
                   6602: .El
                   6603: .Pp
                   6604: A time stamp response (TimeStampResp) consists of a response status
                   6605: and the time stamp token itself (ContentInfo),
                   6606: if the token generation was successful.
                   6607: The
                   6608: .Fl reply
                   6609: command is for creating a time stamp
                   6610: response or time stamp token based on a request and printing the
                   6611: response/token in human-readable format.
                   6612: If
                   6613: .Fl token_out
                   6614: is not specified the output is always a time stamp response (TimeStampResp),
                   6615: otherwise it is a time stamp token (ContentInfo).
                   6616: .Bl -tag -width Ds
                   6617: .It Fl chain Ar certs_file.pem
                   6618: The collection of certificates, in PEM format,
                   6619: that will be included in the response
                   6620: in addition to the signer certificate if the
                   6621: .Fl cert
                   6622: option was used for the request.
                   6623: This file is supposed to contain the certificate chain
                   6624: for the signer certificate from its issuer upwards.
                   6625: The
                   6626: .Fl reply
                   6627: command does not build a certificate chain automatically.
                   6628: .It Fl config Ar configfile
                   6629: The configuration file to use.
                   6630: This option overrides the
                   6631: .Ev OPENSSL_CONF
                   6632: environment variable.
                   6633: See
                   6634: .Sx TS CONFIGURATION FILE OPTIONS
                   6635: for configurable variables.
                   6636: .It Fl in Ar response.tsr
                   6637: Specifies a previously created time stamp response or time stamp token, if
                   6638: .Fl token_in
                   6639: is also specified,
                   6640: in DER format that will be written to the output file.
                   6641: This option does not require a request;
                   6642: it is useful, for example,
                   6643: when you need to examine the content of a response or token
                   6644: or you want to extract the time stamp token from a response.
                   6645: If the input is a token and the output is a time stamp response a default
                   6646: .Dq granted
                   6647: status info is added to the token.
                   6648: .It Fl inkey Ar private.pem
                   6649: The signer private key of the TSA in PEM format.
                   6650: Overrides the
                   6651: .Cm signer_key
                   6652: config file option.
                   6653: .It Fl out Ar response.tsr
                   6654: The response is written to this file.
                   6655: The format and content of the file depends on other options (see
                   6656: .Fl text
                   6657: and
                   6658: .Fl token_out ) .
                   6659: The default is stdout.
                   6660: .It Fl passin Ar arg
                   6661: The key password source.
                   6662: .It Fl policy Ar object_id
                   6663: The default policy to use for the response unless the client
                   6664: explicitly requires a particular TSA policy.
                   6665: The OID can be specified either in dotted notation or with its name.
                   6666: Overrides the
                   6667: .Cm default_policy
                   6668: config file option.
                   6669: .It Fl queryfile Ar request.tsq
                   6670: The name of the file containing a DER-encoded time stamp request.
                   6671: .It Fl section Ar tsa_section
                   6672: The name of the config file section containing the settings for the
                   6673: response generation.
                   6674: If not specified the default TSA section is used; see
                   6675: .Sx TS CONFIGURATION FILE OPTIONS
                   6676: for details.
                   6677: .It Fl signer Ar tsa_cert.pem
                   6678: The signer certificate of the TSA in PEM format.
                   6679: The TSA signing certificate must have exactly one extended key usage
                   6680: assigned to it: timeStamping.
                   6681: The extended key usage must also be critical,
                   6682: otherwise the certificate is going to be refused.
                   6683: Overrides the
                   6684: .Cm signer_cert
                   6685: variable of the config file.
                   6686: .It Fl text
                   6687: If this option is specified the output is human-readable text format
                   6688: instead of DER.
                   6689: .It Fl token_in
                   6690: This flag can be used together with the
                   6691: .Fl in
                   6692: option and indicates that the input is a DER-encoded time stamp token
                   6693: (ContentInfo) instead of a time stamp response (TimeStampResp).
                   6694: .It Fl token_out
                   6695: The output is a time stamp token (ContentInfo) instead of time stamp
                   6696: response (TimeStampResp).
                   6697: .El
                   6698: .Pp
                   6699: The
                   6700: .Fl verify
                   6701: command is for verifying if a time stamp response or time stamp token
                   6702: is valid and matches a particular time stamp request or data file.
                   6703: The
                   6704: .Fl verify
                   6705: command does not use the configuration file.
                   6706: .Bl -tag -width Ds
                   6707: .It Fl CAfile Ar trusted_certs.pem
                   6708: The name of the file containing a set of trusted self-signed CA
                   6709: certificates in PEM format.
                   6710: See the similar option of
                   6711: .Nm verify
                   6712: for additional details.
                   6713: Either this option or
                   6714: .Fl CApath
                   6715: must be specified.
                   6716: .It Fl CApath Ar trusted_cert_path
                   6717: The name of the directory containing the trused CA certificates of the
                   6718: client.
                   6719: See the similar option of
                   6720: .Nm verify
                   6721: for additional details.
                   6722: Either this option or
                   6723: .Fl CAfile
                   6724: must be specified.
                   6725: .It Fl data Ar file_to_hash
                   6726: The response or token must be verified against
                   6727: .Ar file_to_hash .
                   6728: The file is hashed with the message digest algorithm specified in the token.
                   6729: The
                   6730: .Fl digest
                   6731: and
                   6732: .Fl queryfile
                   6733: options must not be specified with this one.
                   6734: .It Fl digest Ar digest_bytes
                   6735: The response or token must be verified against the message digest specified
                   6736: with this option.
                   6737: The number of bytes must match the message digest algorithm
                   6738: specified in the token.
                   6739: The
                   6740: .Fl data
                   6741: and
                   6742: .Fl queryfile
                   6743: options must not be specified with this one.
                   6744: .It Fl in Ar response.tsr
                   6745: The time stamp response that needs to be verified, in DER format.
                   6746: This option in mandatory.
                   6747: .It Fl queryfile Ar request.tsq
                   6748: The original time stamp request, in DER format.
                   6749: The
                   6750: .Fl data
                   6751: and
                   6752: .Fl digest
                   6753: options must not be specified with this one.
                   6754: .It Fl token_in
                   6755: This flag can be used together with the
                   6756: .Fl in
                   6757: option and indicates that the input is a DER-encoded time stamp token
                   6758: (ContentInfo) instead of a time stamp response (TimeStampResp).
                   6759: .It Fl untrusted Ar cert_file.pem
                   6760: Set of additional untrusted certificates in PEM format which may be
                   6761: needed when building the certificate chain for the TSA's signing
                   6762: certificate.
                   6763: This file must contain the TSA signing certificate and
                   6764: all intermediate CA certificates unless the response includes them.
                   6765: .El
                   6766: .Sh TS CONFIGURATION FILE OPTIONS
                   6767: The
                   6768: .Fl query
                   6769: and
                   6770: .Fl reply
                   6771: options make use of a configuration file defined by the
                   6772: .Ev OPENSSL_CONF
                   6773: environment variable.
                   6774: The
                   6775: .Fl query
                   6776: option uses only the symbolic OID names section
                   6777: and it can work without it.
                   6778: However, the
                   6779: .Fl reply
                   6780: option needs the config file for its operation.
                   6781: .Pp
                   6782: When there is a command line switch equivalent of a variable the
                   6783: switch always overrides the settings in the config file.
                   6784: .Bl -tag -width Ds
                   6785: .It Cm tsa Ar section , Cm default_tsa
                   6786: This is the main section and it specifies the name of another section
                   6787: that contains all the options for the
                   6788: .Fl reply
                   6789: option.
                   6790: This default section can be overridden with the
                   6791: .Fl section
                   6792: command line switch.
                   6793: .It Cm oid_file
                   6794: See
                   6795: .Nm ca
                   6796: for a description.
                   6797: .It Cm oid_section
                   6798: See
                   6799: .Nm ca
                   6800: for a description.
                   6801: .It Cm serial
                   6802: The name of the file containing the hexadecimal serial number of the
                   6803: last time stamp response created.
                   6804: This number is incremented by 1 for each response.
                   6805: If the file does not exist at the time of response
                   6806: generation a new file is created with serial number 1.
                   6807: This parameter is mandatory.
                   6808: .It Cm signer_cert
                   6809: TSA signing certificate, in PEM format.
                   6810: The same as the
                   6811: .Fl signer
                   6812: command line option.
                   6813: .It Cm certs
                   6814: A file containing a set of PEM-encoded certificates that need to be
                   6815: included in the response.
                   6816: The same as the
                   6817: .Fl chain
                   6818: command line option.
                   6819: .It Cm signer_key
                   6820: The private key of the TSA, in PEM format.
                   6821: The same as the
                   6822: .Fl inkey
                   6823: command line option.
                   6824: .It Cm default_policy
                   6825: The default policy to use when the request does not mandate any policy.
                   6826: The same as the
                   6827: .Fl policy
                   6828: command line option.
                   6829: .It Cm other_policies
                   6830: Comma separated list of policies that are also acceptable by the TSA
                   6831: and used only if the request explicitly specifies one of them.
                   6832: .It Cm digests
                   6833: The list of message digest algorithms that the TSA accepts.
                   6834: At least one algorithm must be specified.
                   6835: This parameter is mandatory.
                   6836: .It Cm accuracy
                   6837: The accuracy of the time source of the TSA in seconds, milliseconds
                   6838: and microseconds.
                   6839: For example, secs:1, millisecs:500, microsecs:100.
                   6840: If any of the components is missing,
                   6841: zero is assumed for that field.
                   6842: .It Cm clock_precision_digits
                   6843: Specifies the maximum number of digits, which represent the fraction of
                   6844: seconds, that need to be included in the time field.
                   6845: The trailing zeroes must be removed from the time,
                   6846: so there might actually be fewer digits,
                   6847: or no fraction of seconds at all.
                   6848: The maximum value is 6;
                   6849: the default is 0.
                   6850: .It Cm ordering
                   6851: If this option is yes,
                   6852: the responses generated by this TSA can always be ordered,
                   6853: even if the time difference between two responses is less
                   6854: than the sum of their accuracies.
                   6855: The default is no.
                   6856: .It Cm tsa_name
                   6857: Set this option to yes if the subject name of the TSA must be included in
                   6858: the TSA name field of the response.
                   6859: The default is no.
                   6860: .It Cm ess_cert_id_chain
                   6861: The SignedData objects created by the TSA always contain the
                   6862: certificate identifier of the signing certificate in a signed
                   6863: attribute (see RFC 2634, Enhanced Security Services).
                   6864: If this option is set to yes and either the
                   6865: .Cm certs
                   6866: variable or the
                   6867: .Fl chain
                   6868: option is specified then the certificate identifiers of the chain will also
                   6869: be included in the SigningCertificate signed attribute.
                   6870: If this variable is set to no,
                   6871: only the signing certificate identifier is included.
                   6872: The default is no.
                   6873: .El
                   6874: .Sh TS ENVIRONMENT VARIABLES
                   6875: .Ev OPENSSL_CONF
                   6876: contains the path of the configuration file and can be
                   6877: overridden by the
                   6878: .Fl config
                   6879: command line option.
                   6880: .Sh TS EXAMPLES
                   6881: All the examples below presume that
                   6882: .Ev OPENSSL_CONF
                   6883: is set to a proper configuration file,
                   6884: e.g. the example configuration file
                   6885: .Pa openssl/apps/openssl.cnf
                   6886: will do.
                   6887: .Pp
                   6888: To create a time stamp request for design1.txt with SHA-1
                   6889: without nonce and policy and no certificate is required in the response:
                   6890: .Bd -literal -offset indent
                   6891: $ openssl ts -query -data design1.txt -no_nonce \e
                   6892:        -out design1.tsq
                   6893: .Ed
                   6894: .Pp
                   6895: To create a similar time stamp request but specifying the message imprint
                   6896: explicitly:
                   6897: .Bd -literal -offset indent
                   6898: $ openssl ts -query \e
                   6899:        -digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \e
                   6900:        -no_nonce -out design1.tsq
                   6901: .Ed
                   6902: .Pp
                   6903: To print the content of the previous request in human readable format:
                   6904: .Bd -literal -offset indent
                   6905: $ openssl ts -query -in design1.tsq -text
                   6906: .Ed
                   6907: .Pp
                   6908: To create a time stamp request which includes the MD5 digest
                   6909: of design2.txt, requests the signer certificate and nonce,
                   6910: specifies a policy ID
                   6911: (assuming the tsa_policy1 name is defined in the
                   6912: OID section of the config file):
                   6913: .Bd -literal -offset indent
                   6914: $ openssl ts -query -data design2.txt -md5 \e
                   6915:        -policy tsa_policy1 -cert -out design2.tsq
                   6916: .Ed
                   6917: .Pp
                   6918: Before generating a response,
                   6919: a signing certificate must be created for the TSA that contains the
                   6920: .Cm timeStamping
                   6921: critical extended key usage extension
                   6922: without any other key usage extensions.
                   6923: You can add the
                   6924: .Dq extendedKeyUsage = critical,timeStamping
                   6925: line to the user certificate section
                   6926: of the config file to generate a proper certificate.
                   6927: See the
                   6928: .Nm req ,
                   6929: .Nm ca ,
                   6930: and
                   6931: .Nm x509
                   6932: commands for instructions.
                   6933: The examples below assume that cacert.pem contains the certificate of the CA,
                   6934: tsacert.pem is the signing certificate issued by cacert.pem and
                   6935: tsakey.pem is the private key of the TSA.
                   6936: .Pp
                   6937: To create a time stamp response for a request:
                   6938: .Bd -literal -offset indent
                   6939: $ openssl ts -reply -queryfile design1.tsq -inkey tsakey.pem \e
                   6940:        -signer tsacert.pem -out design1.tsr
                   6941: .Ed
                   6942: .Pp
                   6943: If you want to use the settings in the config file you could just write:
                   6944: .Bd -literal -offset indent
                   6945: $ openssl ts -reply -queryfile design1.tsq -out design1.tsr
                   6946: .Ed
                   6947: .Pp
                   6948: To print a time stamp reply to stdout in human readable format:
                   6949: .Bd -literal -offset indent
                   6950: $ openssl ts -reply -in design1.tsr -text
                   6951: .Ed
                   6952: .Pp
                   6953: To create a time stamp token instead of time stamp response:
                   6954: .Bd -literal -offset indent
                   6955: $ openssl ts -reply -queryfile design1.tsq \e
                   6956:        -out design1_token.der -token_out
                   6957: .Ed
                   6958: .Pp
                   6959: To print a time stamp token to stdout in human readable format:
                   6960: .Bd -literal -offset indent
                   6961: $ openssl ts -reply -in design1_token.der -token_in \e
                   6962:        -text -token_out
                   6963: .Ed
                   6964: .Pp
                   6965: To extract the time stamp token from a response:
                   6966: .Bd -literal -offset indent
                   6967: $ openssl ts -reply -in design1.tsr -out design1_token.der \e
                   6968:        -token_out
                   6969: .Ed
                   6970: .Pp
                   6971: To add
                   6972: .Dq granted
                   6973: status info to a time stamp token thereby creating a valid response:
                   6974: .Bd -literal -offset indent
                   6975: $ openssl ts -reply -in design1_token.der \e
                   6976:        -token_in -out design1.tsr
                   6977: .Ed
                   6978: .Pp
                   6979: To verify a time stamp reply against a request:
                   6980: .Bd -literal -offset indent
                   6981: $ openssl ts -verify -queryfile design1.tsq -in design1.tsr \e
                   6982:        -CAfile cacert.pem -untrusted tsacert.pem
                   6983: .Ed
                   6984: .Pp
                   6985: To verify a time stamp reply that includes the certificate chain:
                   6986: .Bd -literal -offset indent
                   6987: $ openssl ts -verify -queryfile design2.tsq -in design2.tsr \e
                   6988:        -CAfile cacert.pem
                   6989: .Ed
                   6990: .Pp
                   6991: To verify a time stamp token against the original data file:
                   6992: .Bd -literal -offset indent
                   6993: $ openssl ts -verify -data design2.txt -in design2.tsr \e
                   6994:        -CAfile cacert.pem
                   6995: .Ed
                   6996: .Pp
                   6997: To verify a time stamp token against a message imprint:
                   6998: .Bd -literal -offset indent
                   6999: $ openssl ts -verify \e
                   7000:        -digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \e
                   7001:        -in design2.tsr -CAfile cacert.pem
                   7002: .Ed
                   7003: .Sh TS BUGS
                   7004: No support for time stamps over SMTP, though it is quite easy
                   7005: to implement an automatic email-based TSA with
                   7006: .Xr procmail
                   7007: and
                   7008: .Xr perl 1 .
                   7009: Pure TCP/IP is not supported.
                   7010: .Pp
                   7011: The file containing the last serial number of the TSA is not
                   7012: locked when being read or written.
                   7013: This is a problem if more than one instance of
                   7014: .Nm OpenSSL
                   7015: is trying to create a time stamp
                   7016: response at the same time.
                   7017: .Pp
                   7018: Look for the FIXME word in the source files.
                   7019: .Pp
                   7020: The source code should really be reviewed by somebody else, too.
                   7021: .Pp
                   7022: More testing is needed.
                   7023: .Sh TS AUTHORS
                   7024: .An Zoltan Glozik Aq Mt zglozik@opentsa.org ,
                   7025: OpenTSA project
                   7026: .Pq Lk http://www.opentsa.org .
                   7027: .\"
                   7028: .\" SPKAC
                   7029: .\"
                   7030: .Sh SPKAC
                   7031: .nr nS 1
                   7032: .Nm "openssl spkac"
                   7033: .Bk -words
                   7034: .Op Fl challenge Ar string
                   7035: .Op Fl in Ar file
                   7036: .Op Fl key Ar keyfile
                   7037: .Op Fl noout
                   7038: .Op Fl out Ar file
                   7039: .Op Fl passin Ar arg
                   7040: .Op Fl pubkey
                   7041: .Op Fl spkac Ar spkacname
                   7042: .Op Fl spksect Ar section
                   7043: .Op Fl verify
                   7044: .Ek
                   7045: .nr nS 0
                   7046: .Pp
                   7047: The
                   7048: .Nm spkac
                   7049: command processes Netscape signed public key and challenge
                   7050: .Pq SPKAC
                   7051: files.
                   7052: It can print out their contents, verify the signature,
                   7053: and produce its own SPKACs from a supplied private key.
                   7054: .Pp
                   7055: The options are as follows:
                   7056: .Bl -tag -width Ds
                   7057: .It Fl challenge Ar string
                   7058: Specifies the challenge string if an SPKAC is being created.
                   7059: .It Fl in Ar file
                   7060: This specifies the input
                   7061: .Ar file
                   7062: to read from, or standard input if this option is not specified.
                   7063: Ignored if the
                   7064: .Fl key
                   7065: option is used.
                   7066: .It Fl key Ar keyfile
                   7067: Create an SPKAC file using the private key in
                   7068: .Ar keyfile .
                   7069: The
                   7070: .Fl in , noout , spksect ,
                   7071: and
                   7072: .Fl verify
                   7073: options are ignored if present.
                   7074: .It Fl noout
                   7075: Don't output the text version of the SPKAC
                   7076: .Pq not used if an SPKAC is being created .
                   7077: .It Fl out Ar file
                   7078: Specifies the output
                   7079: .Ar file
                   7080: to write to, or standard output by default.
                   7081: .It Fl passin Ar arg
                   7082: The key password source.
                   7083: .It Fl pubkey
                   7084: Output the public key of an SPKAC
                   7085: .Pq not used if an SPKAC is being created .
                   7086: .It Fl spkac Ar spkacname
                   7087: Allows an alternative name for the variable containing the SPKAC.
                   7088: The default is "SPKAC".
                   7089: This option affects both generated and input SPKAC files.
                   7090: .It Fl spksect Ar section
                   7091: Allows an alternative name for the
                   7092: .Ar section
                   7093: containing the SPKAC.
                   7094: The default is the default section.
                   7095: .It Fl verify
                   7096: Verifies the digital signature on the supplied SPKAC.
                   7097: .El
                   7098: .Sh SPKAC EXAMPLES
                   7099: Print out the contents of an SPKAC:
                   7100: .Pp
                   7101: .Dl $ openssl spkac -in spkac.cnf
                   7102: .Pp
                   7103: Verify the signature of an SPKAC:
                   7104: .Pp
                   7105: .Dl $ openssl spkac -in spkac.cnf -noout -verify
                   7106: .Pp
                   7107: Create an SPKAC using the challenge string
                   7108: .Qq hello :
                   7109: .Pp
                   7110: .Dl $ openssl spkac -key key.pem -challenge hello -out spkac.cnf
                   7111: .Pp
                   7112: Example of an SPKAC,
                   7113: .Pq long lines split up for clarity :
                   7114: .Bd -unfilled -offset indent
                   7115: SPKAC=MIG5MGUwXDANBgkqhkiG9w0BAQEFAANLADBIAkEA1cCoq2Wa3Ixs47uI7F\e
                   7116: PVwHVIPDx5yso105Y6zpozam135a8R0CpoRvkkigIyXfcCjiVi5oWk+6FfPaD03u\e
                   7117: PFoQIDAQABFgVoZWxsbzANBgkqhkiG9w0BAQQFAANBAFpQtY/FojdwkJh1bEIYuc\e
                   7118: 2EeM2KHTWPEepWYeawvHD0gQ3DngSC75YCWnnDdq+NQ3F+X4deMx9AaEglZtULwV\e
                   7119: 4=
                   7120: .Ed
                   7121: .Sh SPKAC NOTES
                   7122: A created SPKAC with suitable DN components appended can be fed into
                   7123: the
                   7124: .Nm ca
                   7125: utility.
                   7126: .Pp
                   7127: SPKACs are typically generated by Netscape when a form is submitted
                   7128: containing the
                   7129: .Em KEYGEN
                   7130: tag as part of the certificate enrollment process.
                   7131: .Pp
                   7132: The challenge string permits a primitive form of proof of possession
                   7133: of private key.
                   7134: By checking the SPKAC signature and a random challenge
                   7135: string, some guarantee is given that the user knows the private key
                   7136: corresponding to the public key being certified.
                   7137: This is important in some applications.
                   7138: Without this it is possible for a previous SPKAC
                   7139: to be used in a
                   7140: .Qq replay attack .
                   7141: .\"
                   7142: .\" VERIFY
                   7143: .\"
                   7144: .Sh VERIFY
                   7145: .nr nS 1
                   7146: .Nm "openssl verify"
                   7147: .Bk -words
                   7148: .Op Fl CAfile Ar file
                   7149: .Op Fl CApath Ar directory
                   7150: .Op Fl check_ss_sig
                   7151: .Op Fl crl_check
                   7152: .Op Fl crl_check_all
                   7153: .Op Fl explicit_policy
                   7154: .Op Fl extended_crl
                   7155: .Op Fl help
                   7156: .Op Fl ignore_critical
                   7157: .Op Fl inhibit_any
                   7158: .Op Fl inhibit_map
                   7159: .Op Fl issuer_checks
                   7160: .Op Fl policy_check
                   7161: .Op Fl purpose Ar purpose
                   7162: .Op Fl untrusted Ar file
                   7163: .Op Fl verbose
                   7164: .Op Fl x509_strict
                   7165: .Op Fl
                   7166: .Op Ar certificates
                   7167: .Ek
                   7168: .nr nS 0
                   7169: .Pp
                   7170: The
                   7171: .Nm verify
                   7172: command verifies certificate chains.
                   7173: .Pp
                   7174: The options are as follows:
                   7175: .Bl -tag -width Ds
                   7176: .It Fl check_ss_sig
                   7177: Verify the signature on the self-signed root CA.
                   7178: This is disabled by default
                   7179: because it doesn't add any security.
                   7180: .It Fl CAfile Ar file
                   7181: A
                   7182: .Ar file
                   7183: of trusted certificates.
                   7184: The
                   7185: .Ar file
                   7186: should contain multiple certificates in PEM format, concatenated together.
                   7187: .It Fl CApath Ar directory
                   7188: A
                   7189: .Ar directory
                   7190: of trusted certificates.
                   7191: The certificates should have names of the form
                   7192: .Em hash.0 ,
                   7193: or have symbolic links to them of this form
                   7194: ("hash" is the hashed certificate subject name: see the
                   7195: .Fl hash
                   7196: option of the
                   7197: .Nm x509
                   7198: utility).
                   7199: The
                   7200: .Nm c_rehash
                   7201: script distributed with OpenSSL
                   7202: will automatically create symbolic links to a directory of certificates.
                   7203: .It Fl crl_check
                   7204: Checks end entity certificate validity by attempting to look up a valid CRL.
                   7205: If a valid CRL cannot be found an error occurs.
                   7206: .It Fl crl_check_all
                   7207: Checks the validity of all certificates in the chain by attempting
                   7208: to look up valid CRLs.
                   7209: .It Fl explicit_policy
                   7210: Set policy variable require-explicit-policy (see RFC 3280 et al).
                   7211: .It Fl extended_crl
                   7212: Enable extended CRL features such as indirect CRLs and alternate CRL
                   7213: signing keys.
                   7214: .It Fl help
                   7215: Prints out a usage message.
                   7216: .It Fl ignore_critical
                   7217: Normally if an unhandled critical extension is present which is not
                   7218: supported by
                   7219: .Nm OpenSSL ,
                   7220: the certificate is rejected (as required by RFC 3280 et al).
                   7221: If this option is set, critical extensions are ignored.
                   7222: .It Fl inhibit_any
                   7223: Set policy variable inhibit-any-policy (see RFC 3280 et al).
                   7224: .It Fl inhibit_map
                   7225: Set policy variable inhibit-policy-mapping (see RFC 3280 et al).
                   7226: .It Fl issuer_checks
                   7227: Print out diagnostics relating to searches for the issuer certificate
                   7228: of the current certificate.
                   7229: This shows why each candidate issuer certificate was rejected.
                   7230: However the presence of rejection messages
                   7231: does not itself imply that anything is wrong: during the normal
                   7232: verify process several rejections may take place.
                   7233: .It Fl policy_check
                   7234: Enables certificate policy processing.
                   7235: .It Fl purpose Ar purpose
                   7236: The intended use for the certificate.
                   7237: Without this option no chain verification will be done.
                   7238: Currently accepted uses are
                   7239: .Ar sslclient , sslserver ,
                   7240: .Ar nssslserver , smimesign ,
                   7241: .Ar smimeencrypt , crlsign ,
                   7242: .Ar any ,
                   7243: and
                   7244: .Ar ocsphelper .
                   7245: See the
                   7246: .Sx VERIFY OPERATION
                   7247: section for more information.
                   7248: .It Fl untrusted Ar file
                   7249: A
                   7250: .Ar file
                   7251: of untrusted certificates.
                   7252: The
                   7253: .Ar file
                   7254: should contain multiple certificates.
                   7255: .It Fl verbose
                   7256: Print extra information about the operations being performed.
                   7257: .It Fl x509_strict
                   7258: Disable workarounds for broken certificates which have to be disabled
                   7259: for strict X.509 compliance.
                   7260: .It Fl
                   7261: Marks the last option.
                   7262: All arguments following this are assumed to be certificate files.
                   7263: This is useful if the first certificate filename begins with a
                   7264: .Sq - .
                   7265: .It Ar certificates
                   7266: One or more
                   7267: .Ar certificates
                   7268: to verify.
                   7269: If no certificate files are included, an attempt is made to read
                   7270: a certificate from standard input.
                   7271: They should all be in PEM format.
                   7272: .El
                   7273: .Sh VERIFY OPERATION
                   7274: The
                   7275: .Nm verify
                   7276: program uses the same functions as the internal SSL and S/MIME verification,
                   7277: therefore this description applies to these verify operations too.
                   7278: .Pp
                   7279: There is one crucial difference between the verify operations performed
                   7280: by the
                   7281: .Nm verify
                   7282: program: wherever possible an attempt is made to continue
                   7283: after an error, whereas normally the verify operation would halt on the
                   7284: first error.
                   7285: This allows all the problems with a certificate chain to be determined.
                   7286: .Pp
                   7287: The verify operation consists of a number of separate steps:
                   7288: .Pp
                   7289: Firstly a certificate chain is built up starting from the supplied certificate
                   7290: and ending in the root CA.
                   7291: It is an error if the whole chain cannot be built up.
                   7292: The chain is built up by looking up the issuer's certificate of the current
                   7293: certificate.
                   7294: If a certificate is found which is its own issuer, it is assumed
                   7295: to be the root CA.
                   7296: .Pp
                   7297: The process of
                   7298: .Qq looking up the issuer's certificate
                   7299: itself involves a number of steps.
                   7300: In versions of
                   7301: .Nm OpenSSL
                   7302: before 0.9.5a the first certificate whose subject name matched the issuer
                   7303: of the current certificate was assumed to be the issuer's certificate.
                   7304: In
                   7305: .Nm OpenSSL
                   7306: 0.9.6 and later all certificates whose subject name matches the issuer name
                   7307: of the current certificate are subject to further tests.
                   7308: The relevant authority key identifier components of the current certificate
                   7309: .Pq if present
                   7310: must match the subject key identifier
                   7311: .Pq if present
                   7312: and issuer and serial number of the candidate issuer; in addition the
                   7313: .Em keyUsage
                   7314: extension of the candidate issuer
                   7315: .Pq if present
                   7316: must permit certificate signing.
                   7317: .Pp
                   7318: The lookup first looks in the list of untrusted certificates and if no match
                   7319: is found the remaining lookups are from the trusted certificates.
                   7320: The root CA is always looked up in the trusted certificate list: if the
                   7321: certificate to verify is a root certificate, then an exact match must be
                   7322: found in the trusted list.
                   7323: .Pp
                   7324: The second operation is to check every untrusted certificate's extensions for
                   7325: consistency with the supplied purpose.
                   7326: If the
                   7327: .Fl purpose
                   7328: option is not included, then no checks are done.
                   7329: The supplied or
                   7330: .Qq leaf
                   7331: certificate must have extensions compatible with the supplied purpose
                   7332: and all other certificates must also be valid CA certificates.
                   7333: The precise extensions required are described in more detail in
                   7334: the
                   7335: .Sx X.509 CERTIFICATE EXTENSIONS
                   7336: section below.
                   7337: .Pp
                   7338: The third operation is to check the trust settings on the root CA.
                   7339: The root CA should be trusted for the supplied purpose.
                   7340: For compatibility with previous versions of
                   7341: .Nm SSLeay
                   7342: and
                   7343: .Nm OpenSSL ,
                   7344: a certificate with no trust settings is considered to be valid for
                   7345: all purposes.
                   7346: .Pp
                   7347: The final operation is to check the validity of the certificate chain.
                   7348: The validity period is checked against the current system time and the
                   7349: .Em notBefore
                   7350: and
                   7351: .Em notAfter
                   7352: dates in the certificate.
                   7353: The certificate signatures are also checked at this point.
                   7354: .Pp
                   7355: If all operations complete successfully, the certificate is considered
                   7356: valid.
                   7357: If any operation fails then the certificate is not valid.
                   7358: .Sh VERIFY DIAGNOSTICS
                   7359: When a verify operation fails, the output messages can be somewhat cryptic.
                   7360: The general form of the error message is:
                   7361: .Bd -unfilled
                   7362: \& server.pem: /C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test CA (1024-bit)
                   7363: \& error 24 at 1 depth lookup:invalid CA certificate
                   7364: .Ed
                   7365: .Pp
                   7366: The first line contains the name of the certificate being verified, followed by
                   7367: the subject name of the certificate.
                   7368: The second line contains the error number and the depth.
                   7369: The depth is the number of the certificate being verified when a
                   7370: problem was detected starting with zero for the certificate being verified
                   7371: itself, then 1 for the CA that signed the certificate and so on.
                   7372: Finally a text version of the error number is presented.
                   7373: .Pp
                   7374: An exhaustive list of the error codes and messages is shown below; this also
                   7375: includes the name of the error code as defined in the header file
1.12      bentley  7376: .In openssl/x509_vfy.h .
1.1       jsing    7377: Some of the error codes are defined but never returned: these are described
                   7378: as
                   7379: .Qq unused .
                   7380: .Bl -tag -width "XXXX"
                   7381: .It Ar "0 X509_V_OK: ok"
                   7382: The operation was successful.
                   7383: .It Ar 2 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: unable to get issuer certificate
                   7384: The issuer certificate could not be found: this occurs if the issuer certificate
                   7385: of an untrusted certificate cannot be found.
                   7386: .It Ar 3 X509_V_ERR_UNABLE_TO_GET_CRL: unable to get certificate CRL
                   7387: The CRL of a certificate could not be found.
                   7388: .It Ar 4 X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE: unable to decrypt certificate's signature
                   7389: The certificate signature could not be decrypted.
                   7390: This means that the actual signature value could not be determined rather
                   7391: than it not matching the expected value.
                   7392: This is only meaningful for RSA keys.
                   7393: .It Ar 5 X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE: unable to decrypt CRL's signature
                   7394: The CRL signature could not be decrypted: this means that the actual
                   7395: signature value could not be determined rather than it not matching the
                   7396: expected value.
                   7397: Unused.
                   7398: .It Ar 6 X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY: unable to decode issuer public key
                   7399: The public key in the certificate
                   7400: .Em SubjectPublicKeyInfo
                   7401: could not be read.
                   7402: .It Ar 7 X509_V_ERR_CERT_SIGNATURE_FAILURE: certificate signature failure
                   7403: The signature of the certificate is invalid.
                   7404: .It Ar 8 X509_V_ERR_CRL_SIGNATURE_FAILURE: CRL signature failure
                   7405: The signature of the certificate is invalid.
                   7406: .It Ar 9 X509_V_ERR_CERT_NOT_YET_VALID: certificate is not yet valid
                   7407: The certificate is not yet valid: the
                   7408: .Em notBefore
                   7409: date is after the current time.
                   7410: .It Ar 10 X509_V_ERR_CERT_HAS_EXPIRED: certificate has expired
                   7411: The certificate has expired; that is, the
                   7412: .Em notAfter
                   7413: date is before the current time.
                   7414: .It Ar 11 X509_V_ERR_CRL_NOT_YET_VALID: CRL is not yet valid
                   7415: The CRL is not yet valid.
                   7416: .It Ar 12 X509_V_ERR_CRL_HAS_EXPIRED: CRL has expired
                   7417: The CRL has expired.
                   7418: .It Ar 13 X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: format error in certificate's notBefore field
                   7419: The certificate
                   7420: .Em notBefore
                   7421: field contains an invalid time.
                   7422: .It Ar 14 X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD: format error in certificate's notAfter field
                   7423: The certificate
                   7424: .Em notAfter
                   7425: field contains an invalid time.
                   7426: .It Ar 15 X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD: format error in CRL's lastUpdate field
                   7427: The CRL
                   7428: .Em lastUpdate
                   7429: field contains an invalid time.
                   7430: .It Ar 16 X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD: format error in CRL's nextUpdate field
                   7431: The CRL
                   7432: .Em nextUpdate
                   7433: field contains an invalid time.
                   7434: .It Ar 17 X509_V_ERR_OUT_OF_MEM: out of memory
                   7435: An error occurred trying to allocate memory.
                   7436: This should never happen.
                   7437: .It Ar 18 X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: self signed certificate
                   7438: The passed certificate is self-signed and the same certificate cannot be
                   7439: found in the list of trusted certificates.
                   7440: .It Ar 19 X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: self signed certificate in certificate chain
                   7441: The certificate chain could be built up using the untrusted certificates but
                   7442: the root could not be found locally.
                   7443: .It Ar 20 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: unable to get local issuer certificate
                   7444: The issuer certificate of a locally looked up certificate could not be found.
                   7445: This normally means the list of trusted certificates is not complete.
                   7446: .It Ar 21 X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: unable to verify the first certificate
                   7447: No signatures could be verified because the chain contains only one
                   7448: certificate and it is not self-signed.
                   7449: .It Ar 22 X509_V_ERR_CERT_CHAIN_TOO_LONG: certificate chain too long
                   7450: The certificate chain length is greater than the supplied maximum depth.
                   7451: Unused.
                   7452: .It Ar 23 X509_V_ERR_CERT_REVOKED: certificate revoked
                   7453: The certificate has been revoked.
                   7454: .It Ar 24 X509_V_ERR_INVALID_CA: invalid CA certificate
                   7455: A CA certificate is invalid.
                   7456: Either it is not a CA or its extensions are not consistent
                   7457: with the supplied purpose.
                   7458: .It Ar 25 X509_V_ERR_PATH_LENGTH_EXCEEDED: path length constraint exceeded
                   7459: The
                   7460: .Em basicConstraints
                   7461: pathlength parameter has been exceeded.
                   7462: .It Ar 26 X509_V_ERR_INVALID_PURPOSE: unsupported certificate purpose
                   7463: The supplied certificate cannot be used for the specified purpose.
                   7464: .It Ar 27 X509_V_ERR_CERT_UNTRUSTED: certificate not trusted
                   7465: The root CA is not marked as trusted for the specified purpose.
                   7466: .It Ar 28 X509_V_ERR_CERT_REJECTED: certificate rejected
                   7467: The root CA is marked to reject the specified purpose.
                   7468: .It Ar 29 X509_V_ERR_SUBJECT_ISSUER_MISMATCH: subject issuer mismatch
                   7469: The current candidate issuer certificate was rejected because its subject name
                   7470: did not match the issuer name of the current certificate.
                   7471: Only displayed when the
                   7472: .Fl issuer_checks
                   7473: option is set.
                   7474: .It Ar 30 X509_V_ERR_AKID_SKID_MISMATCH: authority and subject key identifier mismatch
                   7475: The current candidate issuer certificate was rejected because its subject key
                   7476: identifier was present and did not match the authority key identifier current
                   7477: certificate.
                   7478: Only displayed when the
                   7479: .Fl issuer_checks
                   7480: option is set.
                   7481: .It Ar 31 X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH: authority and issuer serial number mismatch
                   7482: The current candidate issuer certificate was rejected because its issuer name
                   7483: and serial number were present and did not match the authority key identifier
                   7484: of the current certificate.
                   7485: Only displayed when the
                   7486: .Fl issuer_checks
                   7487: option is set.
                   7488: .It Ar 32 X509_V_ERR_KEYUSAGE_NO_CERTSIGN:key usage does not include certificate signing
                   7489: The current candidate issuer certificate was rejected because its
                   7490: .Em keyUsage
                   7491: extension does not permit certificate signing.
                   7492: .It Ar 50 X509_V_ERR_APPLICATION_VERIFICATION: application verification failure
                   7493: An application specific error.
                   7494: Unused.
                   7495: .El
                   7496: .Sh VERIFY BUGS
                   7497: Although the issuer checks are a considerable improvement over the old
                   7498: technique, they still suffer from limitations in the underlying
                   7499: X509_LOOKUP API.
                   7500: One consequence of this is that trusted certificates with matching subject
                   7501: name must either appear in a file (as specified by the
                   7502: .Fl CAfile
                   7503: option) or a directory (as specified by
                   7504: .Fl CApath ) .
                   7505: If they occur in both, only the certificates in the file will
                   7506: be recognised.
                   7507: .Pp
                   7508: Previous versions of
                   7509: .Nm OpenSSL
                   7510: assumed certificates with matching subject name were identical and
                   7511: mishandled them.
                   7512: .\"
                   7513: .\" VERSION
                   7514: .\"
                   7515: .Sh VERSION
                   7516: .Nm openssl version
                   7517: .Op Fl abdfopv
                   7518: .Pp
                   7519: The
                   7520: .Nm version
                   7521: command is used to print out version information about
                   7522: .Nm OpenSSL .
                   7523: .Pp
                   7524: The options are as follows:
                   7525: .Bl -tag -width Ds
                   7526: .It Fl a
                   7527: All information: this is the same as setting all the other flags.
                   7528: .It Fl b
                   7529: The date the current version of
                   7530: .Nm OpenSSL
                   7531: was built.
                   7532: .It Fl d
                   7533: .Ev OPENSSLDIR
                   7534: setting.
                   7535: .It Fl f
                   7536: Compilation flags.
                   7537: .It Fl o
                   7538: Option information: various options set when the library was built.
                   7539: .It Fl p
                   7540: Platform setting.
                   7541: .It Fl v
                   7542: The current
                   7543: .Nm OpenSSL
                   7544: version.
                   7545: .El
                   7546: .Sh VERSION NOTES
                   7547: The output of
                   7548: .Nm openssl version -a
                   7549: would typically be used when sending in a bug report.
                   7550: .Sh VERSION HISTORY
                   7551: The
                   7552: .Fl d
                   7553: option was added in
                   7554: .Nm OpenSSL
                   7555: 0.9.7.
                   7556: .\"
                   7557: .\" X509
                   7558: .\"
                   7559: .Sh X509
                   7560: .nr nS 1
                   7561: .Nm "openssl x509"
                   7562: .Bk -words
                   7563: .Op Fl C
                   7564: .Op Fl addreject Ar arg
                   7565: .Op Fl addtrust Ar arg
                   7566: .Op Fl alias
                   7567: .Op Fl CA Ar file
                   7568: .Op Fl CAcreateserial
                   7569: .Op Fl CAform Ar DER | PEM
                   7570: .Op Fl CAkey Ar file
                   7571: .Op Fl CAkeyform Ar DER | PEM
                   7572: .Op Fl CAserial Ar file
                   7573: .Op Fl certopt Ar option
                   7574: .Op Fl checkend Ar arg
                   7575: .Op Fl clrext
                   7576: .Op Fl clrreject
                   7577: .Op Fl clrtrust
                   7578: .Op Fl dates
                   7579: .Op Fl days Ar arg
                   7580: .Op Fl email
                   7581: .Op Fl enddate
                   7582: .Op Fl extensions Ar section
                   7583: .Op Fl extfile Ar file
                   7584: .Op Fl fingerprint
                   7585: .Op Fl hash
                   7586: .Op Fl in Ar file
                   7587: .Op Fl inform Ar DER | NET | PEM
                   7588: .Op Fl issuer
                   7589: .Op Fl issuer_hash
                   7590: .Op Fl issuer_hash_old
                   7591: .Op Fl keyform Ar DER | PEM
1.29      bcook    7592: .Op Fl md5 | sha1
1.1       jsing    7593: .Op Fl modulus
                   7594: .Op Fl nameopt Ar option
                   7595: .Op Fl noout
                   7596: .Op Fl ocsp_uri
                   7597: .Op Fl ocspid
                   7598: .Op Fl out Ar file
                   7599: .Op Fl outform Ar DER | NET | PEM
                   7600: .Op Fl passin Ar arg
                   7601: .Op Fl pubkey
                   7602: .Op Fl purpose
                   7603: .Op Fl req
                   7604: .Op Fl serial
                   7605: .Op Fl set_serial Ar n
                   7606: .Op Fl setalias Ar arg
                   7607: .Op Fl signkey Ar file
                   7608: .Op Fl startdate
                   7609: .Op Fl subject
                   7610: .Op Fl subject_hash
                   7611: .Op Fl subject_hash_old
                   7612: .Op Fl text
                   7613: .Op Fl trustout
                   7614: .Op Fl x509toreq
                   7615: .Ek
                   7616: .nr nS 0
                   7617: .Pp
                   7618: The
                   7619: .Nm x509
                   7620: command is a multi-purpose certificate utility.
                   7621: It can be used to display certificate information, convert certificates to
                   7622: various forms, sign certificate requests like a
                   7623: .Qq mini CA ,
                   7624: or edit certificate trust settings.
                   7625: .Pp
                   7626: Since there are a large number of options, they are split up into
                   7627: various sections.
                   7628: .Sh X509 INPUT, OUTPUT, AND GENERAL PURPOSE OPTIONS
                   7629: .Bl -tag -width "XXXX"
                   7630: .It Fl in Ar file
                   7631: This specifies the input
                   7632: .Ar file
                   7633: to read a certificate from, or standard input if this option is not specified.
                   7634: .It Fl inform Ar DER | NET | PEM
                   7635: This specifies the input format.
                   7636: Normally, the command will expect an X.509 certificate,
                   7637: but this can change if other options such as
                   7638: .Fl req
                   7639: are present.
                   7640: The
                   7641: .Ar DER
                   7642: format is the DER encoding of the certificate and
                   7643: .Ar PEM
                   7644: is the base64 encoding of the DER encoding with header and footer lines added.
                   7645: The
                   7646: .Ar NET
                   7647: option is an obscure Netscape server format that is now
                   7648: obsolete.
1.29      bcook    7649: .It Fl md5 | sha1
1.1       jsing    7650: The digest to use.
                   7651: This affects any signing or display option that uses a message digest,
                   7652: such as the
                   7653: .Fl fingerprint , signkey ,
                   7654: and
                   7655: .Fl CA
                   7656: options.
                   7657: If not specified, MD5 is used.
                   7658: If the key being used to sign with is a DSA key,
                   7659: this option has no effect: SHA1 is always used with DSA keys.
                   7660: .It Fl out Ar file
                   7661: This specifies the output
                   7662: .Ar file
                   7663: to write to, or standard output by default.
                   7664: .It Fl outform Ar DER | NET | PEM
                   7665: This specifies the output format; the options have the same meaning as the
                   7666: .Fl inform
                   7667: option.
                   7668: .It Fl passin Ar arg
                   7669: The key password source.
                   7670: .El
                   7671: .Sh X509 DISPLAY OPTIONS
                   7672: .Sy Note :
                   7673: The
                   7674: .Fl alias
                   7675: and
                   7676: .Fl purpose
                   7677: options are also display options but are described in the
                   7678: .Sx X509 TRUST SETTINGS
                   7679: section.
                   7680: .Bl -tag -width "XXXX"
                   7681: .It Fl C
                   7682: This outputs the certificate in the form of a C source file.
                   7683: .It Fl certopt Ar option
                   7684: Customise the output format used with
                   7685: .Fl text .
                   7686: The
                   7687: .Ar option
                   7688: argument can be a single option or multiple options separated by commas.
                   7689: The
                   7690: .Fl certopt
                   7691: switch may also be used more than once to set multiple options.
                   7692: See the
                   7693: .Sx X509 TEXT OPTIONS
                   7694: section for more information.
                   7695: .It Fl dates
                   7696: Prints out the start and expiry dates of a certificate.
                   7697: .It Fl email
                   7698: Outputs the email address(es), if any.
                   7699: .It Fl enddate
                   7700: Prints out the expiry date of the certificate; that is, the
                   7701: .Em notAfter
                   7702: date.
                   7703: .It Fl fingerprint
                   7704: Prints out the digest of the DER-encoded version of the whole certificate
                   7705: (see
                   7706: .Sx DIGEST OPTIONS ) .
                   7707: .It Fl hash
                   7708: A synonym for
                   7709: .Fl subject_hash ,
                   7710: for backwards compatibility.
                   7711: .It Fl issuer
                   7712: Outputs the issuer name.
                   7713: .It Fl issuer_hash
                   7714: Outputs the
                   7715: .Qq hash
                   7716: of the certificate issuer name.
                   7717: .It Fl issuer_hash_old
                   7718: Outputs the
                   7719: .Qq hash
                   7720: of the certificate issuer name using the older algorithm
                   7721: as used by
                   7722: .Nm OpenSSL
                   7723: versions before 1.0.0.
                   7724: .It Fl modulus
                   7725: This option prints out the value of the modulus of the public key
                   7726: contained in the certificate.
                   7727: .It Fl nameopt Ar option
                   7728: Option which determines how the subject or issuer names are displayed.
                   7729: The
                   7730: .Ar option
                   7731: argument can be a single option or multiple options separated by commas.
                   7732: Alternatively, the
                   7733: .Fl nameopt
                   7734: switch may be used more than once to set multiple options.
                   7735: See the
                   7736: .Sx X509 NAME OPTIONS
                   7737: section for more information.
                   7738: .It Fl noout
                   7739: This option prevents output of the encoded version of the request.
                   7740: .It Fl ocsp_uri
                   7741: Outputs the OCSP responder addresses, if any.
                   7742: .It Fl ocspid
                   7743: Print OCSP hash values for the subject name and public key.
                   7744: .It Fl pubkey
                   7745: Output the public key.
                   7746: .It Fl serial
                   7747: Outputs the certificate serial number.
                   7748: .It Fl startdate
                   7749: Prints out the start date of the certificate; that is, the
                   7750: .Em notBefore
                   7751: date.
                   7752: .It Fl subject
                   7753: Outputs the subject name.
                   7754: .It Fl subject_hash
                   7755: Outputs the
                   7756: .Qq hash
                   7757: of the certificate subject name.
                   7758: This is used in
                   7759: .Nm OpenSSL
                   7760: to form an index to allow certificates in a directory to be looked up
                   7761: by subject name.
                   7762: .It Fl subject_hash_old
                   7763: Outputs the
                   7764: .Qq hash
                   7765: of the certificate subject name using the older algorithm
                   7766: as used by
                   7767: .Nm OpenSSL
                   7768: versions before 1.0.0.
                   7769: .It Fl text
                   7770: Prints out the certificate in text form.
                   7771: Full details are output including the public key, signature algorithms,
                   7772: issuer and subject names, serial number, any extensions present,
                   7773: and any trust settings.
                   7774: .El
                   7775: .Sh X509 TRUST SETTINGS
                   7776: Please note these options are currently experimental and may well change.
                   7777: .Pp
                   7778: A
                   7779: .Em trusted certificate
                   7780: is an ordinary certificate which has several
                   7781: additional pieces of information attached to it such as the permitted
                   7782: and prohibited uses of the certificate and an
                   7783: .Qq alias .
                   7784: .Pp
                   7785: Normally, when a certificate is being verified at least one certificate
                   7786: must be
                   7787: .Qq trusted .
                   7788: By default, a trusted certificate must be stored
                   7789: locally and must be a root CA: any certificate chain ending in this CA
                   7790: is then usable for any purpose.
                   7791: .Pp
                   7792: Trust settings currently are only used with a root CA.
                   7793: They allow a finer control over the purposes the root CA can be used for.
                   7794: For example, a CA may be trusted for an SSL client but not for
                   7795: SSL server use.
                   7796: .Pp
                   7797: See the description of the
                   7798: .Nm verify
                   7799: utility for more information on the meaning of trust settings.
                   7800: .Pp
                   7801: Future versions of
                   7802: .Nm OpenSSL
                   7803: will recognize trust settings on any certificate: not just root CAs.
                   7804: .Bl -tag -width "XXXX"
                   7805: .It Fl addreject Ar arg
                   7806: Adds a prohibited use.
                   7807: It accepts the same values as the
                   7808: .Fl addtrust
                   7809: option.
                   7810: .It Fl addtrust Ar arg
                   7811: Adds a trusted certificate use.
                   7812: Any object name can be used here, but currently only
                   7813: .Ar clientAuth
                   7814: .Pq SSL client use ,
                   7815: .Ar serverAuth
                   7816: .Pq SSL server use ,
                   7817: and
                   7818: .Ar emailProtection
                   7819: .Pq S/MIME email
                   7820: are used.
                   7821: Other
                   7822: .Nm OpenSSL
                   7823: applications may define additional uses.
                   7824: .It Fl alias
                   7825: Outputs the certificate alias, if any.
                   7826: .It Fl clrreject
                   7827: Clears all the prohibited or rejected uses of the certificate.
                   7828: .It Fl clrtrust
                   7829: Clears all the permitted or trusted uses of the certificate.
                   7830: .It Fl purpose
                   7831: This option performs tests on the certificate extensions and outputs
                   7832: the results.
                   7833: For a more complete description, see the
                   7834: .Sx X.509 CERTIFICATE EXTENSIONS
                   7835: section.
                   7836: .It Fl setalias Ar arg
                   7837: Sets the alias of the certificate.
                   7838: This will allow the certificate to be referred to using a nickname,
                   7839: for example
                   7840: .Qq Steve's Certificate .
                   7841: .It Fl trustout
                   7842: This causes
                   7843: .Nm x509
                   7844: to output a
                   7845: .Em trusted certificate .
                   7846: An ordinary or trusted certificate can be input, but by default an ordinary
                   7847: certificate is output and any trust settings are discarded.
                   7848: With the
                   7849: .Fl trustout
                   7850: option a trusted certificate is output.
                   7851: A trusted certificate is automatically output if any trust settings
                   7852: are modified.
                   7853: .El
                   7854: .Sh X509 SIGNING OPTIONS
                   7855: The
                   7856: .Nm x509
                   7857: utility can be used to sign certificates and requests: it
                   7858: can thus behave like a
                   7859: .Qq mini CA .
                   7860: .Bl -tag -width "XXXX"
                   7861: .It Fl CA Ar file
                   7862: Specifies the CA certificate to be used for signing.
                   7863: When this option is present,
                   7864: .Nm x509
                   7865: behaves like a
                   7866: .Qq mini CA .
                   7867: The input file is signed by the CA using this option;
                   7868: that is, its issuer name is set to the subject name of the CA and it is
                   7869: digitally signed using the CA's private key.
                   7870: .Pp
                   7871: This option is normally combined with the
                   7872: .Fl req
                   7873: option.
                   7874: Without the
                   7875: .Fl req
                   7876: option, the input is a certificate which must be self-signed.
                   7877: .It Fl CAcreateserial
                   7878: With this option the CA serial number file is created if it does not exist:
                   7879: it will contain the serial number
                   7880: .Sq 02
                   7881: and the certificate being signed will have
                   7882: .Sq 1
                   7883: as its serial number.
                   7884: Normally, if the
                   7885: .Fl CA
                   7886: option is specified and the serial number file does not exist, it is an error.
                   7887: .It Fl CAform Ar DER | PEM
                   7888: The format of the CA certificate file.
                   7889: The default is
                   7890: .Ar PEM .
                   7891: .It Fl CAkey Ar file
                   7892: Sets the CA private key to sign a certificate with.
                   7893: If this option is not specified, it is assumed that the CA private key
                   7894: is present in the CA certificate file.
                   7895: .It Fl CAkeyform Ar DER | PEM
                   7896: The format of the CA private key.
                   7897: The default is
                   7898: .Ar PEM .
                   7899: .It Fl CAserial Ar file
                   7900: Sets the CA serial number file to use.
                   7901: .Pp
                   7902: When the
                   7903: .Fl CA
                   7904: option is used to sign a certificate,
                   7905: it uses a serial number specified in a file.
                   7906: This file consists of one line containing an even number of hex digits
                   7907: with the serial number to use.
                   7908: After each use the serial number is incremented and written out
                   7909: to the file again.
                   7910: .Pp
                   7911: The default filename consists of the CA certificate file base name with
                   7912: .Pa .srl
                   7913: appended.
                   7914: For example, if the CA certificate file is called
                   7915: .Pa mycacert.pem ,
                   7916: it expects to find a serial number file called
                   7917: .Pa mycacert.srl .
                   7918: .It Fl checkend Ar arg
                   7919: Check whether the certificate expires in the next
                   7920: .Ar arg
                   7921: seconds.
                   7922: If so, exit with return value 1;
                   7923: otherwise exit with return value 0.
                   7924: .It Fl clrext
                   7925: Delete any extensions from a certificate.
                   7926: This option is used when a certificate is being created from another
                   7927: certificate (for example with the
                   7928: .Fl signkey
                   7929: or the
                   7930: .Fl CA
                   7931: options).
                   7932: Normally, all extensions are retained.
                   7933: .It Fl days Ar arg
                   7934: Specifies the number of days to make a certificate valid for.
                   7935: The default is 30 days.
                   7936: .It Fl extensions Ar section
                   7937: The section to add certificate extensions from.
                   7938: If this option is not specified, the extensions should either be
                   7939: contained in the unnamed
                   7940: .Pq default
                   7941: section or the default section should contain a variable called
                   7942: .Qq extensions
                   7943: which contains the section to use.
                   7944: .It Fl extfile Ar file
                   7945: File containing certificate extensions to use.
                   7946: If not specified, no extensions are added to the certificate.
                   7947: .It Fl keyform Ar DER | PEM
                   7948: Specifies the format
                   7949: .Pq DER or PEM
                   7950: of the private key file used in the
                   7951: .Fl signkey
                   7952: option.
                   7953: .It Fl req
                   7954: By default, a certificate is expected on input.
                   7955: With this option a certificate request is expected instead.
                   7956: .It Fl set_serial Ar n
                   7957: Specifies the serial number to use.
                   7958: This option can be used with either the
                   7959: .Fl signkey
                   7960: or
                   7961: .Fl CA
                   7962: options.
                   7963: If used in conjunction with the
                   7964: .Fl CA
                   7965: option, the serial number file (as specified by the
                   7966: .Fl CAserial
                   7967: or
                   7968: .Fl CAcreateserial
                   7969: options) is not used.
                   7970: .Pp
                   7971: The serial number can be decimal or hex (if preceded by
                   7972: .Sq 0x ) .
                   7973: Negative serial numbers can also be specified but their use is not recommended.
                   7974: .It Fl signkey Ar file
                   7975: This option causes the input file to be self-signed using the supplied
                   7976: private key.
                   7977: .Pp
                   7978: If the input file is a certificate, it sets the issuer name to the
                   7979: subject name
                   7980: .Pq i.e. makes it self-signed ,
                   7981: changes the public key to the supplied value,
                   7982: and changes the start and end dates.
                   7983: The start date is set to the current time and the end date is set to
                   7984: a value determined by the
                   7985: .Fl days
                   7986: option.
                   7987: Any certificate extensions are retained unless the
                   7988: .Fl clrext
                   7989: option is supplied.
                   7990: .Pp
                   7991: If the input is a certificate request, a self-signed certificate
                   7992: is created using the supplied private key using the subject name in
                   7993: the request.
                   7994: .It Fl x509toreq
                   7995: Converts a certificate into a certificate request.
                   7996: The
                   7997: .Fl signkey
                   7998: option is used to pass the required private key.
                   7999: .El
                   8000: .Sh X509 NAME OPTIONS
                   8001: The
                   8002: .Fl nameopt
                   8003: command line switch determines how the subject and issuer
                   8004: names are displayed.
                   8005: If no
                   8006: .Fl nameopt
                   8007: switch is present, the default
                   8008: .Qq oneline
                   8009: format is used which is compatible with previous versions of
                   8010: .Nm OpenSSL .
                   8011: Each option is described in detail below; all options can be preceded by a
                   8012: .Sq -
                   8013: to turn the option off.
                   8014: Only
                   8015: .Ar compat ,
                   8016: .Ar RFC2253 ,
                   8017: .Ar oneline ,
                   8018: and
                   8019: .Ar multiline
                   8020: will normally be used.
                   8021: .Bl -tag -width "XXXX"
                   8022: .It Ar align
                   8023: Align field values for a more readable output.
                   8024: Only usable with
                   8025: .Ar sep_multiline .
                   8026: .It Ar compat
                   8027: Use the old format.
                   8028: This is equivalent to specifying no name options at all.
                   8029: .It Ar dn_rev
                   8030: Reverse the fields of the DN.
                   8031: This is required by RFC 2253.
                   8032: As a side effect, this also reverses the order of multiple AVAs but this is
                   8033: permissible.
                   8034: .It Ar dump_all
                   8035: Dump all fields.
                   8036: This option, when used with
                   8037: .Ar dump_der ,
                   8038: allows the DER encoding of the structure to be unambiguously determined.
                   8039: .It Ar dump_der
                   8040: When this option is set, any fields that need to be hexdumped will
                   8041: be dumped using the DER encoding of the field.
                   8042: Otherwise just the content octets will be displayed.
                   8043: Both options use the RFC 2253 #XXXX... format.
                   8044: .It Ar dump_nostr
                   8045: Dump non-character string types
                   8046: .Pq for example OCTET STRING ;
                   8047: if this option is not set, non-character string types will be displayed
                   8048: as though each content octet represents a single character.
                   8049: .It Ar dump_unknown
                   8050: Dump any field whose OID is not recognised by
                   8051: .Nm OpenSSL .
                   8052: .It Ar esc_2253
                   8053: Escape the
                   8054: .Qq special
                   8055: characters required by RFC 2253 in a field that is
                   8056: .Dq \& ,+"\*(Lt\*(Gt; .
                   8057: Additionally,
                   8058: .Sq #
                   8059: is escaped at the beginning of a string
                   8060: and a space character at the beginning or end of a string.
                   8061: .It Ar esc_ctrl
                   8062: Escape control characters.
                   8063: That is, those with ASCII values less than 0x20
                   8064: .Pq space
                   8065: and the delete
                   8066: .Pq 0x7f
                   8067: character.
                   8068: They are escaped using the RFC 2253 \eXX notation (where XX are two hex
                   8069: digits representing the character value).
                   8070: .It Ar esc_msb
                   8071: Escape characters with the MSB set; that is, with ASCII values larger than
                   8072: 127.
                   8073: .It Ar multiline
                   8074: A multiline format.
                   8075: It is equivalent to
                   8076: .Ar esc_ctrl , esc_msb , sep_multiline ,
                   8077: .Ar space_eq , lname ,
                   8078: and
                   8079: .Ar align .
                   8080: .It Ar no_type
                   8081: This option does not attempt to interpret multibyte characters in any
                   8082: way.
                   8083: That is, their content octets are merely dumped as though one octet
                   8084: represents each character.
                   8085: This is useful for diagnostic purposes but will result in rather odd
                   8086: looking output.
                   8087: .It Ar nofname , sname , lname , oid
                   8088: These options alter how the field name is displayed.
                   8089: .Ar nofname
                   8090: does not display the field at all.
                   8091: .Ar sname
                   8092: uses the
                   8093: .Qq short name
                   8094: form (CN for
                   8095: .Ar commonName ,
                   8096: for example).
                   8097: .Ar lname
                   8098: uses the long form.
                   8099: .Ar oid
                   8100: represents the OID in numerical form and is useful for diagnostic purpose.
                   8101: .It Ar oneline
                   8102: A oneline format which is more readable than
                   8103: .Ar RFC2253 .
                   8104: It is equivalent to specifying the
                   8105: .Ar esc_2253 , esc_ctrl , esc_msb , utf8 ,
                   8106: .Ar dump_nostr , dump_der , use_quote , sep_comma_plus_spc ,
                   8107: .Ar space_eq ,
                   8108: and
                   8109: .Ar sname
                   8110: options.
                   8111: .It Ar RFC2253
                   8112: Displays names compatible with RFC 2253; equivalent to
                   8113: .Ar esc_2253 , esc_ctrl ,
                   8114: .Ar esc_msb , utf8 , dump_nostr , dump_unknown ,
                   8115: .Ar dump_der , sep_comma_plus , dn_rev ,
                   8116: and
                   8117: .Ar sname .
                   8118: .It Ar sep_comma_plus , sep_comma_plus_space , sep_semi_plus_space , sep_multiline
                   8119: These options determine the field separators.
                   8120: The first character is between RDNs and the second between multiple AVAs
                   8121: (multiple AVAs are very rare and their use is discouraged).
                   8122: The options ending in
                   8123: .Qq space
                   8124: additionally place a space after the separator to make it more readable.
                   8125: The
                   8126: .Ar sep_multiline
                   8127: uses a linefeed character for the RDN separator and a spaced
                   8128: .Sq +
                   8129: for the AVA separator.
                   8130: It also indents the fields by four characters.
                   8131: .It Ar show_type
                   8132: Show the type of the ASN1 character string.
                   8133: The type precedes the field contents.
                   8134: For example
                   8135: .Qq BMPSTRING: Hello World .
                   8136: .It Ar space_eq
                   8137: Places spaces round the
                   8138: .Sq =
                   8139: character which follows the field name.
                   8140: .It Ar use_quote
                   8141: Escapes some characters by surrounding the whole string with
                   8142: .Sq \&"
                   8143: characters.
                   8144: Without the option, all escaping is done with the
                   8145: .Sq \e
                   8146: character.
                   8147: .It Ar utf8
                   8148: Convert all strings to UTF8 format first.
                   8149: This is required by RFC 2253.
                   8150: If you are lucky enough to have a UTF8 compatible terminal,
                   8151: the use of this option (and
                   8152: .Em not
                   8153: setting
                   8154: .Ar esc_msb )
                   8155: may result in the correct display of multibyte
                   8156: .Pq international
                   8157: characters.
                   8158: If this option is not present, multibyte characters larger than 0xff
                   8159: will be represented using the format \eUXXXX for 16 bits and \eWXXXXXXXX
                   8160: for 32 bits.
                   8161: Also, if this option is off, any UTF8Strings will be converted to their
                   8162: character form first.
                   8163: .El
                   8164: .Sh X509 TEXT OPTIONS
                   8165: As well as customising the name output format, it is also possible to
                   8166: customise the actual fields printed using the
                   8167: .Fl certopt
                   8168: options when the
                   8169: .Fl text
                   8170: option is present.
                   8171: The default behaviour is to print all fields.
                   8172: .Bl -tag -width "XXXX"
                   8173: .It Ar ca_default
                   8174: The value used by the
                   8175: .Nm ca
                   8176: utility; equivalent to
                   8177: .Ar no_issuer , no_pubkey , no_header ,
                   8178: .Ar no_version , no_sigdump ,
                   8179: and
                   8180: .Ar no_signame .
                   8181: .It Ar compatible
                   8182: Use the old format.
                   8183: This is equivalent to specifying no output options at all.
                   8184: .It Ar ext_default
                   8185: Retain default extension behaviour: attempt to print out unsupported
                   8186: certificate extensions.
                   8187: .It Ar ext_dump
                   8188: Hex dump unsupported extensions.
                   8189: .It Ar ext_error
                   8190: Print an error message for unsupported certificate extensions.
                   8191: .It Ar ext_parse
                   8192: ASN1 parse unsupported extensions.
                   8193: .It Ar no_aux
                   8194: Don't print out certificate trust information.
                   8195: .It Ar no_extensions
                   8196: Don't print out any X509V3 extensions.
                   8197: .It Ar no_header
                   8198: Don't print header information: that is, the lines saying
                   8199: .Qq Certificate
                   8200: and
                   8201: .Qq Data .
                   8202: .It Ar no_issuer
                   8203: Don't print out the issuer name.
                   8204: .It Ar no_pubkey
                   8205: Don't print out the public key.
                   8206: .It Ar no_serial
                   8207: Don't print out the serial number.
                   8208: .It Ar no_sigdump
                   8209: Don't give a hexadecimal dump of the certificate signature.
                   8210: .It Ar no_signame
                   8211: Don't print out the signature algorithm used.
                   8212: .It Ar no_subject
                   8213: Don't print out the subject name.
                   8214: .It Ar no_validity
                   8215: Don't print the validity; that is, the
                   8216: .Em notBefore
                   8217: and
                   8218: .Em notAfter
                   8219: fields.
                   8220: .It Ar no_version
                   8221: Don't print out the version number.
                   8222: .El
                   8223: .Sh X509 EXAMPLES
                   8224: Display the contents of a certificate:
                   8225: .Pp
                   8226: .Dl $ openssl x509 -in cert.pem -noout -text
                   8227: .Pp
                   8228: Display the certificate serial number:
                   8229: .Pp
                   8230: .Dl $ openssl x509 -in cert.pem -noout -serial
                   8231: .Pp
                   8232: Display the certificate subject name:
                   8233: .Pp
                   8234: .Dl $ openssl x509 -in cert.pem -noout -subject
                   8235: .Pp
                   8236: Display the certificate subject name in RFC 2253 form:
                   8237: .Pp
                   8238: .Dl $ openssl x509 -in cert.pem -noout -subject -nameopt RFC2253
                   8239: .Pp
                   8240: Display the certificate subject name in oneline form on a terminal
                   8241: supporting UTF8:
                   8242: .Bd -literal -offset indent
                   8243: $ openssl x509 -in cert.pem -noout -subject \e
                   8244:        -nameopt oneline,-esc_msb
                   8245: .Ed
                   8246: .Pp
                   8247: Display the certificate MD5 fingerprint:
                   8248: .Pp
                   8249: .Dl $ openssl x509 -in cert.pem -noout -fingerprint
                   8250: .Pp
                   8251: Display the certificate SHA1 fingerprint:
                   8252: .Pp
                   8253: .Dl $ openssl x509 -sha1 -in cert.pem -noout -fingerprint
                   8254: .Pp
                   8255: Convert a certificate from PEM to DER format:
                   8256: .Pp
                   8257: .Dl "$ openssl x509 -in cert.pem -inform PEM -out cert.der -outform DER"
                   8258: .Pp
                   8259: Convert a certificate to a certificate request:
                   8260: .Bd -literal -offset indent
                   8261: $ openssl x509 -x509toreq -in cert.pem -out req.pem \e
                   8262:        -signkey key.pem
                   8263: .Ed
                   8264: .Pp
                   8265: Convert a certificate request into a self-signed certificate using
                   8266: extensions for a CA:
                   8267: .Bd -literal -offset indent
                   8268: $ openssl x509 -req -in careq.pem -extfile openssl.cnf -extensions \e
                   8269:        v3_ca -signkey key.pem -out cacert.pem
                   8270: .Ed
                   8271: .Pp
                   8272: Sign a certificate request using the CA certificate above and add user
                   8273: certificate extensions:
                   8274: .Bd -literal -offset indent
                   8275: $ openssl x509 -req -in req.pem -extfile openssl.cnf -extensions \e
                   8276:        v3_usr -CA cacert.pem -CAkey key.pem -CAcreateserial
                   8277: .Ed
                   8278: .Pp
                   8279: Set a certificate to be trusted for SSL
                   8280: client use and set its alias to
                   8281: .Qq Steve's Class 1 CA :
                   8282: .Bd -literal -offset indent
                   8283: $ openssl x509 -in cert.pem -addtrust clientAuth \e
                   8284:        -setalias "Steve's Class 1 CA" -out trust.pem
                   8285: .Ed
                   8286: .Sh X509 NOTES
                   8287: The PEM format uses the header and footer lines:
                   8288: .Bd -unfilled -offset indent
                   8289: -----BEGIN CERTIFICATE-----
                   8290: -----END CERTIFICATE-----
                   8291: .Ed
                   8292: .Pp
                   8293: It will also handle files containing:
                   8294: .Bd -unfilled -offset indent
                   8295: -----BEGIN X509 CERTIFICATE-----
                   8296: -----END X509 CERTIFICATE-----
                   8297: .Ed
                   8298: .Pp
                   8299: Trusted certificates have the lines:
                   8300: .Bd -unfilled -offset indent
                   8301: -----BEGIN TRUSTED CERTIFICATE-----
                   8302: -----END TRUSTED CERTIFICATE-----
                   8303: .Ed
                   8304: .Pp
                   8305: The conversion to UTF8 format used with the name options assumes that
                   8306: T61Strings use the ISO 8859-1 character set.
                   8307: This is wrong, but Netscape and MSIE do this, as do many certificates.
                   8308: So although this is incorrect
                   8309: it is more likely to display the majority of certificates correctly.
                   8310: .Pp
                   8311: The
                   8312: .Fl fingerprint
                   8313: option takes the digest of the DER-encoded certificate.
                   8314: This is commonly called a
                   8315: .Qq fingerprint .
                   8316: Because of the nature of message digests, the fingerprint of a certificate
                   8317: is unique to that certificate and two certificates with the same fingerprint
                   8318: can be considered to be the same.
                   8319: .Pp
                   8320: The Netscape fingerprint uses MD5, whereas MSIE uses SHA1.
                   8321: .Pp
                   8322: The
                   8323: .Fl email
                   8324: option searches the subject name and the subject alternative
                   8325: name extension.
                   8326: Only unique email addresses will be printed out: it will
                   8327: not print the same address more than once.
                   8328: .Sh X.509 CERTIFICATE EXTENSIONS
                   8329: The
                   8330: .Fl purpose
                   8331: option checks the certificate extensions and determines
                   8332: what the certificate can be used for.
                   8333: The actual checks done are rather
                   8334: complex and include various hacks and workarounds to handle broken
                   8335: certificates and software.
                   8336: .Pp
                   8337: The same code is used when verifying untrusted certificates in chains,
                   8338: so this section is useful if a chain is rejected by the verify code.
                   8339: .Pp
                   8340: The
                   8341: .Em basicConstraints
                   8342: extension CA flag is used to determine whether the
                   8343: certificate can be used as a CA.
                   8344: If the CA flag is true, it is a CA;
                   8345: if the CA flag is false, it is not a CA.
                   8346: .Em All
                   8347: CAs should have the CA flag set to true.
                   8348: .Pp
                   8349: If the
                   8350: .Em basicConstraints
                   8351: extension is absent, then the certificate is
                   8352: considered to be a
                   8353: .Qq possible CA ;
                   8354: other extensions are checked according to the intended use of the certificate.
                   8355: A warning is given in this case because the certificate should really not
                   8356: be regarded as a CA: however,
                   8357: it is allowed to be a CA to work around some broken software.
                   8358: .Pp
                   8359: If the certificate is a V1 certificate
                   8360: .Pq and thus has no extensions
                   8361: and it is self-signed, it is also assumed to be a CA but a warning is again
                   8362: given: this is to work around the problem of Verisign roots which are V1
                   8363: self-signed certificates.
                   8364: .Pp
                   8365: If the
                   8366: .Em keyUsage
                   8367: extension is present, then additional restraints are
                   8368: made on the uses of the certificate.
                   8369: A CA certificate
                   8370: .Em must
                   8371: have the
                   8372: .Em keyCertSign
                   8373: bit set if the
                   8374: .Em keyUsage
                   8375: extension is present.
                   8376: .Pp
                   8377: The extended key usage extension places additional restrictions on the
                   8378: certificate uses.
                   8379: If this extension is present
                   8380: .Pq whether critical or not ,
                   8381: the key can only be used for the purposes specified.
                   8382: .Pp
                   8383: A complete description of each test is given below.
                   8384: The comments about
                   8385: .Em basicConstraints
                   8386: and
                   8387: .Em keyUsage
                   8388: and V1 certificates above apply to
                   8389: .Em all
                   8390: CA certificates.
                   8391: .Bl -tag -width "XXXX"
                   8392: .It Ar SSL Client
                   8393: The extended key usage extension must be absent or include the
                   8394: .Qq web client authentication
                   8395: OID.
                   8396: .Ar keyUsage
                   8397: must be absent or it must have the
                   8398: .Em digitalSignature
                   8399: bit set.
                   8400: Netscape certificate type must be absent or it must have the SSL
                   8401: client bit set.
                   8402: .It Ar SSL Client CA
                   8403: The extended key usage extension must be absent or include the
                   8404: .Qq web client authentication
                   8405: OID.
                   8406: Netscape certificate type must be absent or it must have the SSL CA
                   8407: bit set: this is used as a work around if the
                   8408: .Em basicConstraints
                   8409: extension is absent.
                   8410: .It Ar SSL Server
                   8411: The extended key usage extension must be absent or include the
                   8412: .Qq web server authentication
                   8413: and/or one of the SGC OIDs.
                   8414: .Em keyUsage
                   8415: must be absent or it must have the
                   8416: .Em digitalSignature
                   8417: set, the
                   8418: .Em keyEncipherment
                   8419: set, or both bits set.
                   8420: Netscape certificate type must be absent or have the SSL server bit set.
                   8421: .It Ar SSL Server CA
                   8422: The extended key usage extension must be absent or include the
                   8423: .Qq web server authentication
                   8424: and/or one of the SGC OIDs.
                   8425: Netscape certificate type must be absent or the SSL CA
                   8426: bit must be set: this is used as a work around if the
                   8427: .Em basicConstraints
                   8428: extension is absent.
                   8429: .It Ar Netscape SSL Server
                   8430: For Netscape SSL clients to connect to an SSL server; it must have the
                   8431: .Em keyEncipherment
                   8432: bit set if the
                   8433: .Em keyUsage
                   8434: extension is present.
                   8435: This isn't always valid because some cipher suites use the key for
                   8436: digital signing.
                   8437: Otherwise it is the same as a normal SSL server.
                   8438: .It Ar Common S/MIME Client Tests
                   8439: The extended key usage extension must be absent or include the
                   8440: .Qq email protection
                   8441: OID.
                   8442: Netscape certificate type must be absent or should have the
                   8443: .Em S/MIME
                   8444: bit set.
                   8445: If the
                   8446: .Em S/MIME
                   8447: bit is not set in Netscape certificate type, then the SSL
                   8448: client bit is tolerated as an alternative but a warning is shown:
                   8449: this is because some Verisign certificates don't set the
                   8450: .Em S/MIME
                   8451: bit.
                   8452: .It Ar S/MIME Signing
                   8453: In addition to the common
                   8454: .Em S/MIME
                   8455: client tests, the
                   8456: .Em digitalSignature
                   8457: bit must be set if the
                   8458: .Em keyUsage
                   8459: extension is present.
                   8460: .It Ar S/MIME Encryption
                   8461: In addition to the common
                   8462: .Em S/MIME
                   8463: tests, the
                   8464: .Em keyEncipherment
                   8465: bit must be set if the
                   8466: .Em keyUsage
                   8467: extension is present.
                   8468: .It Ar S/MIME CA
                   8469: The extended key usage extension must be absent or include the
                   8470: .Qq email protection
                   8471: OID.
                   8472: Netscape certificate type must be absent or must have the
                   8473: .Em S/MIME CA
                   8474: bit set: this is used as a work around if the
                   8475: .Em basicConstraints
                   8476: extension is absent.
                   8477: .It Ar CRL Signing
                   8478: The
                   8479: .Em keyUsage
                   8480: extension must be absent or it must have the
                   8481: .Em CRL
                   8482: signing bit set.
                   8483: .It Ar CRL Signing CA
                   8484: The normal CA tests apply.
                   8485: Except in this case the
                   8486: .Em basicConstraints
                   8487: extension must be present.
                   8488: .El
                   8489: .Sh X509 BUGS
                   8490: Extensions in certificates are not transferred to certificate requests and
                   8491: vice versa.
                   8492: .Pp
                   8493: It is possible to produce invalid certificates or requests by specifying the
                   8494: wrong private key or using inconsistent options in some cases: these should
                   8495: be checked.
                   8496: .Pp
                   8497: There should be options to explicitly set such things as start and end dates,
                   8498: rather than an offset from the current time.
                   8499: .Pp
                   8500: The code to implement the verify behaviour described in the
                   8501: .Sx X509 TRUST SETTINGS
                   8502: is currently being developed.
                   8503: It thus describes the intended behaviour rather than the current behaviour.
                   8504: It is hoped that it will represent reality in
                   8505: .Nm OpenSSL
                   8506: 0.9.5 and later.
                   8507: .Sh X509 HISTORY
                   8508: Before
                   8509: .Nm OpenSSL
                   8510: 0.9.8,
                   8511: the default digest for RSA keys was MD5.
                   8512: .Pp
                   8513: The hash algorithm used in the
                   8514: .Fl subject_hash
                   8515: and
                   8516: .Fl issuer_hash
                   8517: options before
                   8518: .Nm OpenSSL
                   8519: 1.0.0 was based on the deprecated MD5 algorithm and the encoding
                   8520: of the distinguished name.
                   8521: In
                   8522: .Nm OpenSSL
                   8523: 1.0.0 and later it is based on a canonical version of the DN using SHA1.
                   8524: This means that any directories using the old form
                   8525: must have their links rebuilt using
                   8526: .Ar c_rehash
                   8527: or similar.
1.38      jmc      8528: .Sh COMMON NOTATION
                   8529: Several commands share a common syntax,
                   8530: as detailed below.
                   8531: .Pp
                   8532: Password arguments, typically specified using
1.33      jmc      8533: .Fl passin
                   8534: and
                   8535: .Fl passout
1.38      jmc      8536: for input and output passwords,
                   8537: allow passwords to be obtained from a variety of sources.
                   8538: Both of these options take a single argument, described below.
1.33      jmc      8539: If no password argument is given and a password is required,
                   8540: then the user is prompted to enter one:
                   8541: this will typically be read from the current terminal with echoing turned off.
1.38      jmc      8542: .Bl -tag -width "pass:password" -offset indent
                   8543: .It Cm pass : Ns Ar password
1.33      jmc      8544: The actual password is
                   8545: .Ar password .
1.38      jmc      8546: Since the password is visible to utilities,
1.33      jmc      8547: this form should only be used where security is not important.
1.38      jmc      8548: .It Cm env : Ns Ar var
1.33      jmc      8549: Obtain the password from the environment variable
                   8550: .Ar var .
1.38      jmc      8551: Since the environment of other processes is visible,
                   8552: this option should be used with caution.
                   8553: .It Cm file : Ns Ar path
1.33      jmc      8554: The first line of
                   8555: .Ar path
                   8556: is the password.
                   8557: If the same
                   8558: .Ar path
                   8559: argument is supplied to
                   8560: .Fl passin
                   8561: and
                   8562: .Fl passout ,
                   8563: then the first line will be used for the input password and the next line
                   8564: for the output password.
                   8565: .Ar path
                   8566: need not refer to a regular file:
                   8567: it could, for example, refer to a device or named pipe.
1.38      jmc      8568: .It Cm fd : Ns Ar number
1.33      jmc      8569: Read the password from the file descriptor
                   8570: .Ar number .
1.38      jmc      8571: This can be used to send the data via a pipe, for example.
                   8572: .It Cm stdin
1.33      jmc      8573: Read the password from standard input.
1.35      jmc      8574: .El
1.38      jmc      8575: .Pp
                   8576: File formats,
                   8577: typically specified using
                   8578: .Fl inform
                   8579: and
                   8580: .Fl outform ,
                   8581: indicate the type of file being read from
                   8582: or the file format to write.
                   8583: The argument is case insensitive.
                   8584: .Pp
                   8585: .Bl -tag -width Ds -offset indent -compact
                   8586: .It Cm der
                   8587: Distinguished Encoding Rules (DER)
                   8588: is a binary format.
                   8589: .It Cm pem
                   8590: Privacy Enhanced Mail (PEM)
                   8591: is base64-encoded.
                   8592: .It Cm txt
                   8593: Plain ASCII text.
                   8594: .El
1.35      jmc      8595: .Sh ENVIRONMENT
                   8596: The following environment variables affect the execution of
                   8597: .Nm openssl :
1.38      jmc      8598: .Bl -tag -width "/etc/ssl/openssl.cnf"
1.35      jmc      8599: .It Ev OPENSSL_CONF
                   8600: The location of the master configuration file.
1.33      jmc      8601: .El
1.1       jsing    8602: .\"
                   8603: .\" FILES
                   8604: .\"
                   8605: .Sh FILES
                   8606: .Bl -tag -width "/etc/ssl/openssl.cnf" -compact
1.17      sobrado  8607: .It Pa /etc/ssl/
1.1       jsing    8608: Default config directory for
                   8609: .Nm openssl .
1.17      sobrado  8610: .It Pa /etc/ssl/lib/
1.1       jsing    8611: Unused.
1.17      sobrado  8612: .It Pa /etc/ssl/private/
1.1       jsing    8613: Default private key directory.
1.17      sobrado  8614: .It Pa /etc/ssl/openssl.cnf
1.1       jsing    8615: Default configuration file for
                   8616: .Nm openssl .
1.17      sobrado  8617: .It Pa /etc/ssl/x509v3.cnf
1.1       jsing    8618: Default configuration file for
                   8619: .Nm x509
                   8620: certificates.
                   8621: .El
                   8622: .\"
                   8623: .\" SEE ALSO
                   8624: .\"
                   8625: .Sh SEE ALSO
1.26      jmc      8626: .Xr nc 1 ,
1.1       jsing    8627: .Xr ssl 8 ,
                   8628: .Xr starttls 8
                   8629: .Sh STANDARDS
                   8630: .Rs
                   8631: .%D February 1995
                   8632: .%Q Netscape Communications Corp.
                   8633: .%T The SSL Protocol
                   8634: .Re
                   8635: .Pp
                   8636: .Rs
                   8637: .%D November 1996
                   8638: .%Q Netscape Communications Corp.
                   8639: .%T The SSL 3.0 Protocol
                   8640: .Re
                   8641: .Pp
                   8642: .Rs
                   8643: .%A T. Dierks
                   8644: .%A C. Allen
                   8645: .%D January 1999
                   8646: .%R RFC 2246
                   8647: .%T The TLS Protocol Version 1.0
                   8648: .Re
                   8649: .Pp
                   8650: .Rs
                   8651: .%A M. Wahl
                   8652: .%A S. Killie
                   8653: .%A T. Howes
                   8654: .%D December 1997
                   8655: .%R RFC 2253
                   8656: .%T Lightweight Directory Access Protocol (v3): UTF-8 String Representation of Distinguished Names
                   8657: .Re
                   8658: .Pp
                   8659: .Rs
                   8660: .%A B. Kaliski
                   8661: .%D March 1998
                   8662: .%R RFC 2315
                   8663: .%T PKCS #7: Cryptographic Message Syntax Version 1.5
                   8664: .Re
                   8665: .Pp
                   8666: .Rs
                   8667: .%A R. Housley
                   8668: .%A W. Ford
                   8669: .%A W. Polk
                   8670: .%A D. Solo
                   8671: .%D January 1999
                   8672: .%R RFC 2459
                   8673: .%T Internet X.509 Public Key Infrastructure Certificate and CRL Profile
                   8674: .Re
                   8675: .Pp
                   8676: .Rs
                   8677: .%A M. Myers
                   8678: .%A R. Ankney
                   8679: .%A A. Malpani
                   8680: .%A S. Galperin
                   8681: .%A C. Adams
                   8682: .%D June 1999
                   8683: .%R RFC 2560
                   8684: .%T X.509 Internet Public Key Infrastructure Online Certificate Status Protocol \(en OCSP
                   8685: .Re
                   8686: .Pp
                   8687: .Rs
                   8688: .%A R. Housley
                   8689: .%D June 1999
                   8690: .%R RFC 2630
                   8691: .%T Cryptographic Message Syntax
                   8692: .Re
                   8693: .Pp
                   8694: .Rs
                   8695: .%A P. Chown
                   8696: .%D June 2002
                   8697: .%R RFC 3268
1.24      jmc      8698: .%T Advanced Encryption Standard (AES) Ciphersuites for Transport Layer Security (TLS)
1.1       jsing    8699: .Re