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