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