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