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