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