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