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