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