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