1 .\" $NetBSD: openssl_smime.1,v 1.14 2015/06/12 17:01:15 christos Exp $
3 .\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28)
6 .\" ========================================================================
7 .de Sp \" Vertical space (when we can't use .PP)
11 .de Vb \" Begin verbatim text
16 .de Ve \" End verbatim text
20 .\" Set up some character translations and predefined strings. \*(-- will
21 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
22 .\" double quote, and \*(R" will give a right double quote. \*(C+ will
23 .\" give a nicer C++. Capital omega is used to do unbreakable dashes and
24 .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
25 .\" nothing in troff, for use with C<>.
27 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
31 . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
32 . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
47 .\" Escape single quotes in literal strings from groff's Unicode transform.
51 .\" If the F register is turned on, we'll generate index entries on stderr for
52 .\" titles (.TH), headers (.SH), subsections (.SS), 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.
56 .\" Avoid warning from groff about undefined register 'F'.
60 .if \n(.g .if rF .nr rF 1
61 .if (\n(rF:(\n(.g==0)) \{
64 . tm Index:\\$1\t\\n%\t"\\$2"
74 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
75 .\" Fear. Run. Save yourself. No user-serviceable parts.
76 . \" fudge factors for nroff and troff
85 . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
91 . \" simple accents for nroff and troff
101 . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
102 . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
103 . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
104 . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
105 . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
106 . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
108 . \" troff and (daisy-wheel) nroff accents
109 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
110 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
111 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
112 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
113 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
114 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
115 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
116 .ds ae a\h'-(\w'a'u*4/10)'e
117 .ds Ae A\h'-(\w'A'u*4/10)'E
118 . \" corrections for vroff
119 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
120 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
121 . \" for low resolution devices (crt and lpr)
122 .if \n(.H>23 .if \n(.V>19 \
135 .\" ========================================================================
138 .TH SMIME 1 "2015-06-12" "1.0.1n" "OpenSSL"
139 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
140 .\" way too many mistakes in technical documents.
144 smime \- S/MIME utility
148 .IX Header "SYNOPSIS"
149 \&\fBopenssl\fR \fBsmime\fR
158 [\fB\-no_alt_chains\fR]
159 [\fB\-certfile file\fR]
160 [\fB\-signer file\fR]
162 [\fB\-inform SMIME|PEM|DER\fR]
166 [\fB\-outform SMIME|PEM|DER\fR]
167 [\fB\-content file\fR]
175 [\fB\-rand file(s)\fR]
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 six 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
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
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.
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
200 .IP "\fB\-verify\fR" 4
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
206 takes an input message and writes out a \s-1PEM\s0 encoded PKCS#7 structure.
207 .IP "\fB\-resign\fR" 4
209 resign a message: take an existing message and one or more new signers.
210 .IP "\fB\-in filename\fR" 4
211 .IX Item "-in filename"
212 the input message to be encrypted or signed or the \s-1MIME\s0 message to
213 be decrypted or verified.
214 .IP "\fB\-inform SMIME|PEM|DER\fR" 4
215 .IX Item "-inform SMIME|PEM|DER"
216 this specifies the input format for the PKCS#7 structure. The default
217 is \fB\s-1SMIME\s0\fR which reads an S/MIME format message. \fB\s-1PEM\s0\fR and \fB\s-1DER\s0\fR
218 format change this to expect \s-1PEM\s0 and \s-1DER\s0 format PKCS#7 structures
219 instead. This currently only affects the input format of the PKCS#7
220 structure, if no PKCS#7 structure is being input (for example with
221 \&\fB\-encrypt\fR or \fB\-sign\fR) this option has no effect.
222 .IP "\fB\-out filename\fR" 4
223 .IX Item "-out filename"
224 the message text that has been decrypted or verified or the output \s-1MIME\s0
225 format message that has been signed or verified.
226 .IP "\fB\-outform SMIME|PEM|DER\fR" 4
227 .IX Item "-outform SMIME|PEM|DER"
228 this specifies the output format for the PKCS#7 structure. The default
229 is \fB\s-1SMIME\s0\fR which write an S/MIME format message. \fB\s-1PEM\s0\fR and \fB\s-1DER\s0\fR
230 format change this to write \s-1PEM\s0 and \s-1DER\s0 format PKCS#7 structures
231 instead. This currently only affects the output format of the PKCS#7
232 structure, if no PKCS#7 structure is being output (for example with
233 \&\fB\-verify\fR or \fB\-decrypt\fR) this option has no effect.
234 .IP "\fB\-stream \-indef \-noindef\fR" 4
235 .IX Item "-stream -indef -noindef"
236 the \fB\-stream\fR and \fB\-indef\fR options are equivalent and enable streaming I/O
237 for encoding operations. This permits single pass processing of data without
238 the need to hold the entire contents in memory, potentially supporting very
239 large files. Streaming is automatically set for S/MIME signing with detached
240 data if the output format is \fB\s-1SMIME\s0\fR it is currently off by default for all
242 .IP "\fB\-noindef\fR" 4
244 disable streaming I/O where it would produce and indefinite length constructed
245 encoding. This option currently has no effect. In future streaming will be
246 enabled by default on all relevant operations and this option will disable it.
247 .IP "\fB\-content filename\fR" 4
248 .IX Item "-content filename"
249 This specifies a file containing the detached content, this is only
250 useful with the \fB\-verify\fR command. This is only usable if the PKCS#7
251 structure is using the detached signature form where the content is
252 not included. This option will override any content if the input format
253 is S/MIME and it uses the multipart/signed \s-1MIME\s0 content type.
256 this option adds plain text (text/plain) \s-1MIME\s0 headers to the supplied
257 message if encrypting or signing. If decrypting or verifying it strips
258 off text headers: if the decrypted or verified message is not of \s-1MIME \s0
259 type text/plain then an error occurs.
260 .IP "\fB\-CAfile file\fR" 4
261 .IX Item "-CAfile file"
262 a file containing trusted \s-1CA\s0 certificates, only used with \fB\-verify\fR.
263 .IP "\fB\-CApath dir\fR" 4
264 .IX Item "-CApath dir"
265 a directory containing trusted \s-1CA\s0 certificates, only used with
266 \&\fB\-verify\fR. This directory must be a standard certificate directory: that
267 is a hash of each subject name (using \fBx509 \-hash\fR) should be linked
269 .IP "\fB\-md digest\fR" 4
270 .IX Item "-md digest"
271 digest algorithm to use when signing or resigning. If not present then the
272 default digest algorithm for the signing key will be used (usually \s-1SHA1\s0).
273 .IP "\fB\-[cipher]\fR" 4
275 the encryption algorithm to use. For example \s-1DES \s0(56 bits) \- \fB\-des\fR,
276 triple \s-1DES \s0(168 bits) \- \fB\-des3\fR,
277 \&\fIEVP_get_cipherbyname()\fR function) can also be used preceded by a dash, for
278 example \fB\-aes_128_cbc\fR. See \fBenc\fR for list of ciphers
279 supported by your version of OpenSSL.
281 If not specified triple \s-1DES\s0 is used. Only used with \fB\-encrypt\fR.
282 .IP "\fB\-nointern\fR" 4
284 when verifying a message normally certificates (if any) included in
285 the message are searched for the signing certificate. With this option
286 only the certificates specified in the \fB\-certfile\fR option are used.
287 The supplied certificates can still be used as untrusted CAs however.
288 .IP "\fB\-noverify\fR" 4
290 do not verify the signers certificate of a signed message.
291 .IP "\fB\-nochain\fR" 4
293 do not do chain verification of signers certificates: that is don't
294 use the certificates in the signed message as untrusted CAs.
295 .IP "\fB\-nosigs\fR" 4
297 don't try to verify the signatures on the message.
298 .IP "\fB\-nocerts\fR" 4
300 when signing a message the signer's certificate is normally included
301 with this option it is excluded. This will reduce the size of the
302 signed message but the verifier must have a copy of the signers certificate
303 available locally (passed using the \fB\-certfile\fR option for example).
304 .IP "\fB\-noattr\fR" 4
306 normally when a message is signed a set of attributes are included which
307 include the signing time and supported symmetric algorithms. With this
308 option they are not included.
309 .IP "\fB\-binary\fR" 4
311 normally the input message is converted to \*(L"canonical\*(R" format which is
312 effectively using \s-1CR\s0 and \s-1LF\s0 as end of line: as required by the S/MIME
313 specification. When this option is present no translation occurs. This
314 is useful when handling binary data which may not be in \s-1MIME\s0 format.
315 .IP "\fB\-nodetach\fR" 4
317 when signing a message use opaque signing: this form is more resistant
318 to translation by mail relays but it cannot be read by mail agents that
319 do not support S/MIME. Without this option cleartext signing with
320 the \s-1MIME\s0 type multipart/signed is used.
321 .IP "\fB\-certfile file\fR" 4
322 .IX Item "-certfile file"
323 allows additional certificates to be specified. When signing these will
324 be included with the message. When verifying these will be searched for
325 the signers certificates. The certificates should be in \s-1PEM\s0 format.
326 .IP "\fB\-signer file\fR" 4
327 .IX Item "-signer file"
328 a signing certificate when signing or resigning a message, this option can be
329 used multiple times if more than one signer is required. If a message is being
330 verified then the signers certificates will be written to this file if the
331 verification was successful.
332 .IP "\fB\-recip file\fR" 4
333 .IX Item "-recip file"
334 the recipients certificate when decrypting a message. This certificate
335 must match one of the recipients of the message or an error occurs.
336 .IP "\fB\-inkey file\fR" 4
337 .IX Item "-inkey file"
338 the private key to use when signing or decrypting. This must match the
339 corresponding certificate. If this option is not specified then the
340 private key must be included in the certificate file specified with
341 the \fB\-recip\fR or \fB\-signer\fR file. When signing this option can be used
342 multiple times to specify successive keys.
343 .IP "\fB\-passin arg\fR" 4
344 .IX Item "-passin arg"
345 the private key password source. For more information about the format of \fBarg\fR
346 see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1).
347 .IP "\fB\-rand file(s)\fR" 4
348 .IX Item "-rand file(s)"
349 a file or files containing random data used to seed the random number
350 generator, or an \s-1EGD\s0 socket (see \fIRAND_egd\fR\|(3)).
351 Multiple files can be specified separated by a OS-dependent character.
352 The separator is \fB;\fR for MS-Windows, \fB,\fR for OpenVMS, and \fB:\fR for
354 .IP "\fBcert.pem...\fR" 4
355 .IX Item "cert.pem..."
356 one or more certificates of message recipients: used when encrypting
358 .IP "\fB\-to, \-from, \-subject\fR" 4
359 .IX Item "-to, -from, -subject"
360 the relevant mail headers. These are included outside the signed
361 portion of a message so they may be included manually. If signing
362 then many S/MIME mail clients check the signers certificate's email
363 address matches that specified in the From: address.
364 .IP "\fB\-purpose, \-ignore_critical, \-issuer_checks, \-crl_check, \-crl_check_all, \-policy_check, \-extended_crl, \-x509_strict, \-policy \-check_ss_sig \-no_alt_chains\fR" 4
365 .IX Item "-purpose, -ignore_critical, -issuer_checks, -crl_check, -crl_check_all, -policy_check, -extended_crl, -x509_strict, -policy -check_ss_sig -no_alt_chains"
366 Set various options of certificate chain verification. See
367 \&\fBverify\fR manual page for details.
370 The \s-1MIME\s0 message must be sent without any blank lines between the
371 headers and the output. Some mail programs will automatically add
372 a blank line. Piping the mail directly to sendmail is one way to
373 achieve the correct format.
375 The supplied message to be signed or encrypted must include the
376 necessary \s-1MIME\s0 headers or many S/MIME clients wont display it
377 properly (if at all). You can use the \fB\-text\fR option to automatically
378 add plain text headers.
380 A \*(L"signed and encrypted\*(R" message is one where a signed message is
381 then encrypted. This can be produced by encrypting an already signed
382 message: see the examples section.
384 This version of the program only allows one signer per message but it
385 will verify multiple signers on received messages. Some S/MIME clients
386 choke if a message contains multiple signers. It is possible to sign
387 messages \*(L"in parallel\*(R" by signing an already signed message.
389 The options \fB\-encrypt\fR and \fB\-decrypt\fR reflect common usage in S/MIME
390 clients. Strictly speaking these process PKCS#7 enveloped data: PKCS#7
391 encrypted data is used for other purposes.
393 The \fB\-resign\fR option uses an existing message digest when adding a new
394 signer. This means that attributes must be present in at least one existing
395 signer using the same message digest or this operation will fail.
397 The \fB\-stream\fR and \fB\-indef\fR options enable experimental streaming I/O support.
398 As a result the encoding is \s-1BER\s0 using indefinite length constructed encoding
399 and no longer \s-1DER.\s0 Streaming is supported for the \fB\-encrypt\fR operation and the
400 \&\fB\-sign\fR operation if the content is not detached.
402 Streaming is always used for the \fB\-sign\fR operation with detached data but
403 since the content is no longer part of the PKCS#7 structure the encoding
406 .IX Header "EXIT CODES"
408 the operation was completely successfully.
411 an error occurred parsing the command options.
414 one of the input files could not be read.
417 an error occurred creating the PKCS#7 file or when reading the \s-1MIME\s0
421 an error occurred decrypting or verifying the message.
424 the message was verified correctly but an error occurred writing out
425 the signers certificates.
427 .IX Header "EXAMPLES"
428 Create a cleartext signed message:
431 \& openssl smime \-sign \-in message.txt \-text \-out mail.msg \e
432 \& \-signer mycert.pem
435 Create an opaque signed message:
438 \& openssl smime \-sign \-in message.txt \-text \-out mail.msg \-nodetach \e
439 \& \-signer mycert.pem
442 Create a signed message, include some additional certificates and
443 read the private key from another file:
446 \& openssl smime \-sign \-in in.txt \-text \-out mail.msg \e
447 \& \-signer mycert.pem \-inkey mykey.pem \-certfile mycerts.pem
450 Create a signed message with two signers:
453 \& openssl smime \-sign \-in message.txt \-text \-out mail.msg \e
454 \& \-signer mycert.pem \-signer othercert.pem
457 Send a signed message under Unix directly to sendmail, including headers:
460 \& openssl smime \-sign \-in in.txt \-text \-signer mycert.pem \e
461 \& \-from steve@openssl.org \-to someone@somewhere \e
462 \& \-subject "Signed message" | sendmail someone@somewhere
465 Verify a message and extract the signer's certificate if successful:
468 \& openssl smime \-verify \-in mail.msg \-signer user.pem \-out signedtext.txt
471 Send encrypted mail using triple \s-1DES:\s0
474 \& openssl smime \-encrypt \-in in.txt \-from steve@openssl.org \e
475 \& \-to someone@somewhere \-subject "Encrypted message" \e
476 \& \-des3 user.pem \-out mail.msg
479 Sign and encrypt mail:
482 \& openssl smime \-sign \-in ml.txt \-signer my.pem \-text \e
483 \& | openssl smime \-encrypt \-out mail.msg \e
484 \& \-from steve@openssl.org \-to someone@somewhere \e
485 \& \-subject "Signed and Encrypted message" \-des3 user.pem
488 Note: the encryption command does not include the \fB\-text\fR option because the
489 message being encrypted already has \s-1MIME\s0 headers.
494 \& openssl smime \-decrypt \-in mail.msg \-recip mycert.pem \-inkey key.pem
497 The output from Netscape form signing is a PKCS#7 structure with the
498 detached signature format. You can use this program to verify the
499 signature by line wrapping the base64 encoded structure and surrounding
503 \& \-\-\-\-\-BEGIN PKCS7\-\-\-\-\-
504 \& \-\-\-\-\-END PKCS7\-\-\-\-\-
507 and using the command:
510 \& openssl smime \-verify \-inform PEM \-in signature.pem \-content content.txt
513 Alternatively you can base64 decode the signature and use:
516 \& openssl smime \-verify \-inform DER \-in signature.der \-content content.txt
519 Create an encrypted message using 128 bit Camellia:
522 \& openssl smime \-encrypt \-in plain.txt \-camellia128 \-out mail.msg cert.pem
525 Add a signer to an existing message:
528 \& openssl smime \-resign \-in mail.msg \-signer newsign.pem \-out mail2.msg
532 The \s-1MIME\s0 parser isn't very clever: it seems to handle most messages that I've
533 thrown at it but it may choke on others.
535 The code currently will only write out the signer's certificate to a file: if
536 the signer has a separate encryption certificate this must be manually
537 extracted. There should be some heuristic that determines the correct
538 encryption certificate.
540 Ideally a database should be maintained of a certificates for each email
543 The code doesn't currently take note of the permitted symmetric encryption
544 algorithms as supplied in the SMIMECapabilities signed attribute. This means the
545 user has to manually include the correct encryption algorithm. It should store
546 the list of permitted ciphers in a database and only use those.
548 No revocation checking is done on the signer's certificate.
550 The current code can only handle S/MIME v2 messages, the more complex S/MIME v3
551 structures may cause parsing errors.
554 The use of multiple \fB\-signer\fR options and the \fB\-resign\fR command were first
555 added in OpenSSL 1.0.0
557 The \-no_alt_chains options was first added to OpenSSL 1.0.1n and 1.0.2b.