Initial import from FreeBSD RELENG_4:
[dragonfly.git] / secure / usr.bin / openssl / man / smime.1
1 .\" Automatically generated by Pod::Man version 1.15
2 .\" Wed Feb 19 16:49:37 2003
3 .\"
4 .\" Standard preamble:
5 .\" ======================================================================
6 .de Sh \" Subsection heading
7 .br
8 .if t .Sp
9 .ne 5
10 .PP
11 \fB\\$1\fR
12 .PP
13 ..
14 .de Sp \" Vertical space (when we can't use .PP)
15 .if t .sp .5v
16 .if n .sp
17 ..
18 .de Ip \" List item
19 .br
20 .ie \\n(.$>=3 .ne \\$3
21 .el .ne 3
22 .IP "\\$1" \\$2
23 ..
24 .de Vb \" Begin verbatim text
25 .ft CW
26 .nf
27 .ne \\$1
28 ..
29 .de Ve \" End verbatim text
30 .ft R
31
32 .fi
33 ..
34 .\" Set up some character translations and predefined strings.  \*(-- will
35 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
36 .\" double quote, and \*(R" will give a right double quote.  | will give a
37 .\" real vertical bar.  \*(C+ will give a nicer C++.  Capital omega is used
38 .\" to do unbreakable dashes and therefore won't be available.  \*(C` and
39 .\" \*(C' expand to `' in nroff, nothing in troff, for use with C<>
40 .tr \(*W-|\(bv\*(Tr
41 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
42 .ie n \{\
43 .    ds -- \(*W-
44 .    ds PI pi
45 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
46 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
47 .    ds L" ""
48 .    ds R" ""
49 .    ds C` ""
50 .    ds C' ""
51 'br\}
52 .el\{\
53 .    ds -- \|\(em\|
54 .    ds PI \(*p
55 .    ds L" ``
56 .    ds R" ''
57 'br\}
58 .\"
59 .\" If the F register is turned on, we'll generate index entries on stderr
60 .\" for titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and
61 .\" index entries marked with X<> in POD.  Of course, you'll have to process
62 .\" the output yourself in some meaningful fashion.
63 .if \nF \{\
64 .    de IX
65 .    tm Index:\\$1\t\\n%\t"\\$2"
66 ..
67 .    nr % 0
68 .    rr F
69 .\}
70 .\"
71 .\" For nroff, turn off justification.  Always turn off hyphenation; it
72 .\" makes way too many mistakes in technical documents.
73 .hy 0
74 .if n .na
75 .\"
76 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
77 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
78 .bd B 3
79 .    \" fudge factors for nroff and troff
80 .if n \{\
81 .    ds #H 0
82 .    ds #V .8m
83 .    ds #F .3m
84 .    ds #[ \f1
85 .    ds #] \fP
86 .\}
87 .if t \{\
88 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
89 .    ds #V .6m
90 .    ds #F 0
91 .    ds #[ \&
92 .    ds #] \&
93 .\}
94 .    \" simple accents for nroff and troff
95 .if n \{\
96 .    ds ' \&
97 .    ds ` \&
98 .    ds ^ \&
99 .    ds , \&
100 .    ds ~ ~
101 .    ds /
102 .\}
103 .if t \{\
104 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
105 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
106 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
107 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
108 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
109 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
110 .\}
111 .    \" troff and (daisy-wheel) nroff accents
112 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
113 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
114 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
115 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
116 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
117 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
118 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
119 .ds ae a\h'-(\w'a'u*4/10)'e
120 .ds Ae A\h'-(\w'A'u*4/10)'E
121 .    \" corrections for vroff
122 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
123 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
124 .    \" for low resolution devices (crt and lpr)
125 .if \n(.H>23 .if \n(.V>19 \
126 \{\
127 .    ds : e
128 .    ds 8 ss
129 .    ds o a
130 .    ds d- d\h'-1'\(ga
131 .    ds D- D\h'-1'\(hy
132 .    ds th \o'bp'
133 .    ds Th \o'LP'
134 .    ds ae ae
135 .    ds Ae AE
136 .\}
137 .rm #[ #] #H #V #F C
138 .\" ======================================================================
139 .\"
140 .IX Title "SMIME 1"
141 .TH SMIME 1 "0.9.7a" "2003-02-19" "OpenSSL"
142 .UC
143 .SH "NAME"
144 smime \- S/MIME utility
145 .SH "SYNOPSIS"
146 .IX Header "SYNOPSIS"
147 \&\fBopenssl\fR \fBsmime\fR
148 [\fB\-encrypt\fR]
149 [\fB\-decrypt\fR]
150 [\fB\-sign\fR]
151 [\fB\-verify\fR]
152 [\fB\-pk7out\fR]
153 [\fB\-des\fR]
154 [\fB\-des3\fR]
155 [\fB\-rc2\-40\fR]
156 [\fB\-rc2\-64\fR]
157 [\fB\-rc2\-128\fR]
158 [\fB\-in file\fR]
159 [\fB\-certfile file\fR]
160 [\fB\-signer file\fR]
161 [\fB\-recip  file\fR]
162 [\fB\-inform SMIME|PEM|DER\fR]
163 [\fB\-passin arg\fR]
164 [\fB\-inkey file\fR]
165 [\fB\-out file\fR]
166 [\fB\-outform SMIME|PEM|DER\fR]
167 [\fB\-content file\fR]
168 [\fB\-to addr\fR]
169 [\fB\-from ad\fR]
170 [\fB\-subject s\fR]
171 [\fB\-text\fR]
172 [\fB\-rand \f(BIfile\fB\|(s)\fR]
173 [cert.pem]...
174 .SH "DESCRIPTION"
175 .IX Header "DESCRIPTION"
176 The \fBsmime\fR command handles S/MIME mail. It can encrypt, decrypt, sign and
177 verify S/MIME messages.
178 .SH "COMMAND OPTIONS"
179 .IX Header "COMMAND OPTIONS"
180 There are five operation options that set the type of operation to be performed.
181 The meaning of the other options varies according to the operation type.
182 .Ip "\fB\-encrypt\fR" 4
183 .IX Item "-encrypt"
184 encrypt mail for the given recipient certificates. Input file is the message
185 to be encrypted. The output file is the encrypted mail in \s-1MIME\s0 format.
186 .Ip "\fB\-decrypt\fR" 4
187 .IX Item "-decrypt"
188 decrypt mail using the supplied certificate and private key. Expects an
189 encrypted mail message in \s-1MIME\s0 format for the input file. The decrypted mail
190 is written to the output file.
191 .Ip "\fB\-sign\fR" 4
192 .IX Item "-sign"
193 sign mail using the supplied certificate and private key. Input file is
194 the message to be signed. The signed message in \s-1MIME\s0 format is written
195 to the output file.
196 .Ip "\fB\-verify\fR" 4
197 .IX Item "-verify"
198 verify signed mail. Expects a signed mail message on input and outputs
199 the signed data. Both clear text and opaque signing is supported.
200 .Ip "\fB\-pk7out\fR" 4
201 .IX Item "-pk7out"
202 takes an input message and writes out a \s-1PEM\s0 encoded PKCS#7 structure.
203 .Ip "\fB\-in filename\fR" 4
204 .IX Item "-in filename"
205 the input message to be encrypted or signed or the \s-1MIME\s0 message to
206 be decrypted or verified.
207 .Ip "\fB\-inform SMIME|PEM|DER\fR" 4
208 .IX Item "-inform SMIME|PEM|DER"
209 this specifies the input format for the PKCS#7 structure. The default
210 is \fB\s-1SMIME\s0\fR which reads an S/MIME format message. \fB\s-1PEM\s0\fR and \fB\s-1DER\s0\fR
211 format change this to expect \s-1PEM\s0 and \s-1DER\s0 format PKCS#7 structures
212 instead. This currently only affects the input format of the PKCS#7
213 structure, if no PKCS#7 structure is being input (for example with
214 \&\fB\-encrypt\fR or \fB\-sign\fR) this option has no effect.
215 .Ip "\fB\-out filename\fR" 4
216 .IX Item "-out filename"
217 the message text that has been decrypted or verified or the output \s-1MIME\s0
218 format message that has been signed or verified.
219 .Ip "\fB\-outform SMIME|PEM|DER\fR" 4
220 .IX Item "-outform SMIME|PEM|DER"
221 this specifies the output format for the PKCS#7 structure. The default
222 is \fB\s-1SMIME\s0\fR which write an S/MIME format message. \fB\s-1PEM\s0\fR and \fB\s-1DER\s0\fR
223 format change this to write \s-1PEM\s0 and \s-1DER\s0 format PKCS#7 structures
224 instead. This currently only affects the output format of the PKCS#7
225 structure, if no PKCS#7 structure is being output (for example with
226 \&\fB\-verify\fR or \fB\-decrypt\fR) this option has no effect.
227 .Ip "\fB\-content filename\fR" 4
228 .IX Item "-content filename"
229 This specifies a file containing the detached content, this is only
230 useful with the \fB\-verify\fR command. This is only usable if the PKCS#7
231 structure is using the detached signature form where the content is
232 not included. This option will override any content if the input format
233 is S/MIME and it uses the multipart/signed \s-1MIME\s0 content type.
234 .Ip "\fB\-text\fR" 4
235 .IX Item "-text"
236 this option adds plain text (text/plain) \s-1MIME\s0 headers to the supplied
237 message if encrypting or signing. If decrypting or verifying it strips
238 off text headers: if the decrypted or verified message is not of \s-1MIME\s0 
239 type text/plain then an error occurs.
240 .Ip "\fB\-CAfile file\fR" 4
241 .IX Item "-CAfile file"
242 a file containing trusted \s-1CA\s0 certificates, only used with \fB\-verify\fR.
243 .Ip "\fB\-CApath dir\fR" 4
244 .IX Item "-CApath dir"
245 a directory containing trusted \s-1CA\s0 certificates, only used with
246 \&\fB\-verify\fR. This directory must be a standard certificate directory: that
247 is a hash of each subject name (using \fBx509 \-hash\fR) should be linked
248 to each certificate.
249 .Ip "\fB\-des \-des3 \-rc2\-40 \-rc2\-64 \-rc2\-128\fR" 4
250 .IX Item "-des -des3 -rc2-40 -rc2-64 -rc2-128"
251 the encryption algorithm to use. \s-1DES\s0 (56 bits), triple \s-1DES\s0 (168 bits)
252 or 40, 64 or 128 bit \s-1RC2\s0 respectively if not specified 40 bit \s-1RC2\s0 is
253 used. Only used with \fB\-encrypt\fR.
254 .Ip "\fB\-nointern\fR" 4
255 .IX Item "-nointern"
256 when verifying a message normally certificates (if any) included in
257 the message are searched for the signing certificate. With this option
258 only the certificates specified in the \fB\-certfile\fR option are used.
259 The supplied certificates can still be used as untrusted CAs however.
260 .Ip "\fB\-noverify\fR" 4
261 .IX Item "-noverify"
262 do not verify the signers certificate of a signed message.
263 .Ip "\fB\-nochain\fR" 4
264 .IX Item "-nochain"
265 do not do chain verification of signers certificates: that is don't
266 use the certificates in the signed message as untrusted CAs.
267 .Ip "\fB\-nosigs\fR" 4
268 .IX Item "-nosigs"
269 don't try to verify the signatures on the message.
270 .Ip "\fB\-nocerts\fR" 4
271 .IX Item "-nocerts"
272 when signing a message the signer's certificate is normally included
273 with this option it is excluded. This will reduce the size of the
274 signed message but the verifier must have a copy of the signers certificate
275 available locally (passed using the \fB\-certfile\fR option for example).
276 .Ip "\fB\-noattr\fR" 4
277 .IX Item "-noattr"
278 normally when a message is signed a set of attributes are included which
279 include the signing time and supported symmetric algorithms. With this
280 option they are not included.
281 .Ip "\fB\-binary\fR" 4
282 .IX Item "-binary"
283 normally the input message is converted to \*(L"canonical\*(R" format which is
284 effectively using \s-1CR\s0 and \s-1LF\s0 as end of line: as required by the S/MIME
285 specification. When this option is present no translation occurs. This
286 is useful when handling binary data which may not be in \s-1MIME\s0 format.
287 .Ip "\fB\-nodetach\fR" 4
288 .IX Item "-nodetach"
289 when signing a message use opaque signing: this form is more resistant
290 to translation by mail relays but it cannot be read by mail agents that
291 do not support S/MIME.  Without this option cleartext signing with
292 the \s-1MIME\s0 type multipart/signed is used.
293 .Ip "\fB\-certfile file\fR" 4
294 .IX Item "-certfile file"
295 allows additional certificates to be specified. When signing these will
296 be included with the message. When verifying these will be searched for
297 the signers certificates. The certificates should be in \s-1PEM\s0 format.
298 .Ip "\fB\-signer file\fR" 4
299 .IX Item "-signer file"
300 the signers certificate when signing a message. If a message is
301 being verified then the signers certificates will be written to this
302 file if the verification was successful.
303 .Ip "\fB\-recip file\fR" 4
304 .IX Item "-recip file"
305 the recipients certificate when decrypting a message. This certificate
306 must match one of the recipients of the message or an error occurs.
307 .Ip "\fB\-inkey file\fR" 4
308 .IX Item "-inkey file"
309 the private key to use when signing or decrypting. This must match the
310 corresponding certificate. If this option is not specified then the
311 private key must be included in the certificate file specified with
312 the \fB\-recip\fR or \fB\-signer\fR file.
313 .Ip "\fB\-passin arg\fR" 4
314 .IX Item "-passin arg"
315 the private key password source. For more information about the format of \fBarg\fR
316 see the \fB\s-1PASS\s0 \s-1PHRASE\s0 \s-1ARGUMENTS\s0\fR section in openssl(1).
317 .Ip "\fB\-rand \f(BIfile\fB\|(s)\fR" 4
318 .IX Item "-rand file"
319 a file or files containing random data used to seed the random number
320 generator, or an \s-1EGD\s0 socket (see RAND_egd(3)).
321 Multiple files can be specified separated by a OS-dependent character.
322 The separator is \fB;\fR for MS-Windows, \fB,\fR for OpenVMS, and \fB:\fR for
323 all others.
324 .Ip "\fBcert.pem...\fR" 4
325 .IX Item "cert.pem..."
326 one or more certificates of message recipients: used when encrypting
327 a message. 
328 .Ip "\fB\-to, \-from, \-subject\fR" 4
329 .IX Item "-to, -from, -subject"
330 the relevant mail headers. These are included outside the signed
331 portion of a message so they may be included manually. If signing
332 then many S/MIME mail clients check the signers certificate's email
333 address matches that specified in the From: address.
334 .SH "NOTES"
335 .IX Header "NOTES"
336 The \s-1MIME\s0 message must be sent without any blank lines between the
337 headers and the output. Some mail programs will automatically add
338 a blank line. Piping the mail directly to sendmail is one way to
339 achieve the correct format.
340 .PP
341 The supplied message to be signed or encrypted must include the
342 necessary \s-1MIME\s0 headers or many S/MIME clients wont display it
343 properly (if at all). You can use the \fB\-text\fR option to automatically
344 add plain text headers.
345 .PP
346 A \*(L"signed and encrypted\*(R" message is one where a signed message is
347 then encrypted. This can be produced by encrypting an already signed
348 message: see the examples section.
349 .PP
350 This version of the program only allows one signer per message but it
351 will verify multiple signers on received messages. Some S/MIME clients
352 choke if a message contains multiple signers. It is possible to sign
353 messages \*(L"in parallel\*(R" by signing an already signed message.
354 .PP
355 The options \fB\-encrypt\fR and \fB\-decrypt\fR reflect common usage in S/MIME
356 clients. Strictly speaking these process PKCS#7 enveloped data: PKCS#7
357 encrypted data is used for other purposes.
358 .SH "EXIT CODES"
359 .IX Header "EXIT CODES"
360 .Ip "0" 4
361 the operation was completely successfully.
362 .Ip "1" 4
363 .IX Item "1"
364 an error occurred parsing the command options.
365 .Ip "2" 4
366 .IX Item "2"
367 one of the input files could not be read.
368 .Ip "3" 4
369 .IX Item "3"
370 an error occurred creating the PKCS#7 file or when reading the \s-1MIME\s0
371 message.
372 .Ip "4" 4
373 .IX Item "4"
374 an error occurred decrypting or verifying the message.
375 .Ip "5" 4
376 .IX Item "5"
377 the message was verified correctly but an error occurred writing out
378 the signers certificates.
379 .SH "EXAMPLES"
380 .IX Header "EXAMPLES"
381 Create a cleartext signed message:
382 .PP
383 .Vb 2
384 \& openssl smime -sign -in message.txt -text -out mail.msg \e
385 \&        -signer mycert.pem
386 .Ve
387 Create and opaque signed message
388 .PP
389 .Vb 2
390 \& openssl smime -sign -in message.txt -text -out mail.msg -nodetach \e
391 \&        -signer mycert.pem
392 .Ve
393 Create a signed message, include some additional certificates and
394 read the private key from another file:
395 .PP
396 .Vb 2
397 \& openssl smime -sign -in in.txt -text -out mail.msg \e
398 \&        -signer mycert.pem -inkey mykey.pem -certfile mycerts.pem
399 .Ve
400 Send a signed message under Unix directly to sendmail, including headers:
401 .PP
402 .Vb 3
403 \& openssl smime -sign -in in.txt -text -signer mycert.pem \e
404 \&        -from steve@openssl.org -to someone@somewhere \e
405 \&        -subject "Signed message" | sendmail someone@somewhere
406 .Ve
407 Verify a message and extract the signer's certificate if successful:
408 .PP
409 .Vb 1
410 \& openssl smime -verify -in mail.msg -signer user.pem -out signedtext.txt
411 .Ve
412 Send encrypted mail using triple \s-1DES:\s0
413 .PP
414 .Vb 3
415 \& openssl smime -encrypt -in in.txt -from steve@openssl.org \e
416 \&        -to someone@somewhere -subject "Encrypted message" \e
417 \&        -des3 user.pem -out mail.msg
418 .Ve
419 Sign and encrypt mail:
420 .PP
421 .Vb 4
422 \& openssl smime -sign -in ml.txt -signer my.pem -text \e
423 \&        | openssl smime -encrypt -out mail.msg \e
424 \&        -from steve@openssl.org -to someone@somewhere \e
425 \&        -subject "Signed and Encrypted message" -des3 user.pem
426 .Ve
427 Note: the encryption command does not include the \fB\-text\fR option because the message
428 being encrypted already has \s-1MIME\s0 headers.
429 .PP
430 Decrypt mail:
431 .PP
432 .Vb 1
433 \& openssl smime -decrypt -in mail.msg -recip mycert.pem -inkey key.pem
434 .Ve
435 The output from Netscape form signing is a PKCS#7 structure with the
436 detached signature format. You can use this program to verify the
437 signature by line wrapping the base64 encoded structure and surrounding
438 it with:
439 .PP
440 .Vb 2
441 \& -----BEGIN PKCS7-----
442 \& -----END PKCS7-----
443 .Ve
444 and using the command, 
445 .PP
446 .Vb 1
447 \& openssl smime -verify -inform PEM -in signature.pem -content content.txt
448 .Ve
449 alternatively you can base64 decode the signature and use
450 .PP
451 .Vb 1
452 \& openssl smime -verify -inform DER -in signature.der -content content.txt
453 .Ve
454 .SH "BUGS"
455 .IX Header "BUGS"
456 The \s-1MIME\s0 parser isn't very clever: it seems to handle most messages that I've thrown
457 at it but it may choke on others.
458 .PP
459 The code currently will only write out the signer's certificate to a file: if the
460 signer has a separate encryption certificate this must be manually extracted. There
461 should be some heuristic that determines the correct encryption certificate.
462 .PP
463 Ideally a database should be maintained of a certificates for each email address.
464 .PP
465 The code doesn't currently take note of the permitted symmetric encryption
466 algorithms as supplied in the SMIMECapabilities signed attribute. this means the
467 user has to manually include the correct encryption algorithm. It should store
468 the list of permitted ciphers in a database and only use those.
469 .PP
470 No revocation checking is done on the signer's certificate.
471 .PP
472 The current code can only handle S/MIME v2 messages, the more complex S/MIME v3
473 structures may cause parsing errors.