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