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

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