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

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