1SMIME(1)                            OpenSSL                           SMIME(1)
2
3
4

NAME

6       smime - S/MIME utility
7

SYNOPSIS

9       openssl smime [-encrypt] [-decrypt] [-sign] [-resign] [-verify]
10       [-pk7out] [-[cipher]] [-in file] [-certfile file] [-signer file]
11       [-recip  file] [-inform SMIME|PEM|DER] [-passin arg] [-inkey file]
12       [-out file] [-outform SMIME|PEM|DER] [-content file] [-to addr] [-from
13       ad] [-subject s] [-text] [-indef] [-noindef] [-stream] [-rand file(s)]
14       [-md digest] [cert.pem]...
15

DESCRIPTION

17       The smime command handles S/MIME mail. It can encrypt, decrypt, sign
18       and verify S/MIME messages.
19

COMMAND OPTIONS

21       There are six operation options that set the type of operation to be
22       performed.  The meaning of the other options varies according to the
23       operation type.
24
25       -encrypt
26           encrypt mail for the given recipient certificates. Input file is
27           the message to be encrypted. The output file is the encrypted mail
28           in MIME format.
29
30       -decrypt
31           decrypt mail using the supplied certificate and private key.
32           Expects an encrypted mail message in MIME format for the input
33           file. The decrypted mail is written to the output file.
34
35       -sign
36           sign mail using the supplied certificate and private key. Input
37           file is the message to be signed. The signed message in MIME format
38           is written to the output file.
39
40       -verify
41           verify signed mail. Expects a signed mail message on input and
42           outputs the signed data. Both clear text and opaque signing is
43           supported.
44
45       -pk7out
46           takes an input message and writes out a PEM encoded PKCS#7
47           structure.
48
49       -resign
50           resign a message: take an existing message and one or more new
51           signers.
52
53       -in filename
54           the input message to be encrypted or signed or the MIME message to
55           be decrypted or verified.
56
57       -inform SMIME|PEM|DER
58           this specifies the input format for the PKCS#7 structure. The
59           default is SMIME which reads an S/MIME format message. PEM and DER
60           format change this to expect PEM and DER format PKCS#7 structures
61           instead. This currently only affects the input format of the PKCS#7
62           structure, if no PKCS#7 structure is being input (for example with
63           -encrypt or -sign) this option has no effect.
64
65       -out filename
66           the message text that has been decrypted or verified or the output
67           MIME format message that has been signed or verified.
68
69       -outform SMIME|PEM|DER
70           this specifies the output format for the PKCS#7 structure. The
71           default is SMIME which write an S/MIME format message. PEM and DER
72           format change this to write PEM and DER format PKCS#7 structures
73           instead. This currently only affects the output format of the
74           PKCS#7 structure, if no PKCS#7 structure is being output (for
75           example with -verify or -decrypt) this option has no effect.
76
77       -stream -indef -noindef
78           the -stream and -indef options are equivalent and enable streaming
79           I/O for encoding operations. This permits single pass processing of
80           data without the need to hold the entire contents in memory,
81           potentially supporting very large files. Streaming is automatically
82           set for S/MIME signing with detached data if the output format is
83           SMIME it is currently off by default for all other operations.
84
85       -noindef
86           disable streaming I/O where it would produce and indefinite length
87           constructed encoding. This option currently has no effect. In
88           future streaming will be enabled by default on all relevant
89           operations and this option will disable it.
90
91       -content filename
92           This specifies a file containing the detached content, this is only
93           useful with the -verify command. This is only usable if the PKCS#7
94           structure is using the detached signature form where the content is
95           not included. This option will override any content if the input
96           format is S/MIME and it uses the multipart/signed MIME content
97           type.
98
99       -text
100           this option adds plain text (text/plain) MIME headers to the
101           supplied message if encrypting or signing. If decrypting or
102           verifying it strips off text headers: if the decrypted or verified
103           message is not of MIME type text/plain then an error occurs.
104
105       -CAfile file
106           a file containing trusted CA certificates, only used with -verify.
107
108       -CApath dir
109           a directory containing trusted CA certificates, only used with
110           -verify. This directory must be a standard certificate directory:
111           that is a hash of each subject name (using x509 -hash) should be
112           linked to each certificate.
113
114       -md digest
115           digest algorithm to use when signing or resigning. If not present
116           then the default digest algorithm for the signing key will be used
117           (usually SHA1).
118
119       -[cipher]
120           the encryption algorithm to use. For example DES  (56 bits) - -des,
121           triple DES (168 bits) - -des3, EVP_get_cipherbyname() function) can
122           also be used preceded by a dash, for example -aes_128_cbc. See enc
123           for list of ciphers supported by your version of OpenSSL.
124
125           If not specified 40 bit RC2 is used. Only used with -encrypt.
126
127       -nointern
128           when verifying a message normally certificates (if any) included in
129           the message are searched for the signing certificate. With this
130           option only the certificates specified in the -certfile option are
131           used.  The supplied certificates can still be used as untrusted CAs
132           however.
133
134       -noverify
135           do not verify the signers certificate of a signed message.
136
137       -nochain
138           do not do chain verification of signers certificates: that is don't
139           use the certificates in the signed message as untrusted CAs.
140
141       -nosigs
142           don't try to verify the signatures on the message.
143
144       -nocerts
145           when signing a message the signer's certificate is normally
146           included with this option it is excluded. This will reduce the size
147           of the signed message but the verifier must have a copy of the
148           signers certificate available locally (passed using the -certfile
149           option for example).
150
151       -noattr
152           normally when a message is signed a set of attributes are included
153           which include the signing time and supported symmetric algorithms.
154           With this option they are not included.
155
156       -binary
157           normally the input message is converted to "canonical" format which
158           is effectively using CR and LF as end of line: as required by the
159           S/MIME specification. When this option is present no translation
160           occurs. This is useful when handling binary data which may not be
161           in MIME format.
162
163       -nodetach
164           when signing a message use opaque signing: this form is more
165           resistant to translation by mail relays but it cannot be read by
166           mail agents that do not support S/MIME.  Without this option
167           cleartext signing with the MIME type multipart/signed is used.
168
169       -certfile file
170           allows additional certificates to be specified. When signing these
171           will be included with the message. When verifying these will be
172           searched for the signers certificates. The certificates should be
173           in PEM format.
174
175       -signer file
176           a signing certificate when signing or resigning a message, this
177           option can be used multiple times if more than one signer is
178           required. If a message is being verified then the signers
179           certificates will be written to this file if the verification was
180           successful.
181
182       -recip file
183           the recipients certificate when decrypting a message. This
184           certificate must match one of the recipients of the message or an
185           error occurs.
186
187       -inkey file
188           the private key to use when signing or decrypting. This must match
189           the corresponding certificate. If this option is not specified then
190           the private key must be included in the certificate file specified
191           with the -recip or -signer file. When signing this option can be
192           used multiple times to specify successive keys.
193
194       -passin arg
195           the private key password source. For more information about the
196           format of arg see the PASS PHRASE ARGUMENTS section in openssl(1).
197
198       -rand file(s)
199           a file or files containing random data used to seed the random
200           number generator, or an EGD socket (see RAND_egd(3)).  Multiple
201           files can be specified separated by a OS-dependent character.  The
202           separator is ; for MS-Windows, , for OpenVMS, and : for all others.
203
204       cert.pem...
205           one or more certificates of message recipients: used when
206           encrypting a message.
207
208       -to, -from, -subject
209           the relevant mail headers. These are included outside the signed
210           portion of a message so they may be included manually. If signing
211           then many S/MIME mail clients check the signers certificate's email
212           address matches that specified in the From: address.
213
214       -purpose, -ignore_critical, -issuer_checks, -crl_check, -crl_check_all,
215       -policy_check, -extended_crl, -x509_strict, -policy -check_ss_sig
216           Set various options of certificate chain verification. See verify
217           manual page for details.
218

NOTES

220       The MIME message must be sent without any blank lines between the
221       headers and the output. Some mail programs will automatically add a
222       blank line. Piping the mail directly to sendmail is one way to achieve
223       the correct format.
224
225       The supplied message to be signed or encrypted must include the
226       necessary MIME headers or many S/MIME clients wont display it properly
227       (if at all). You can use the -text option to automatically add plain
228       text headers.
229
230       A "signed and encrypted" message is one where a signed message is then
231       encrypted. This can be produced by encrypting an already signed
232       message: see the examples section.
233
234       This version of the program only allows one signer per message but it
235       will verify multiple signers on received messages. Some S/MIME clients
236       choke if a message contains multiple signers. It is possible to sign
237       messages "in parallel" by signing an already signed message.
238
239       The options -encrypt and -decrypt reflect common usage in S/MIME
240       clients. Strictly speaking these process PKCS#7 enveloped data: PKCS#7
241       encrypted data is used for other purposes.
242
243       The -resign option uses an existing message digest when adding a new
244       signer. This means that attributes must be present in at least one
245       existing signer using the same message digest or this operation will
246       fail.
247
248       The -stream and -indef options enable experimental streaming I/O
249       support.  As a result the encoding is BER using indefinite length
250       constructed encoding and no longer DER. Streaming is supported for the
251       -encrypt operation and the -sign operation if the content is not
252       detached.
253
254       Streaming is always used for the -sign operation with detached data but
255       since the content is no longer part of the PKCS#7 structure the
256       encoding remains DER.
257

EXIT CODES

259       0   the operation was completely successfully.
260
261       1   an error occurred parsing the command options.
262
263       2   one of the input files could not be read.
264
265       3   an error occurred creating the PKCS#7 file or when reading the MIME
266           message.
267
268       4   an error occurred decrypting or verifying the message.
269
270       5   the message was verified correctly but an error occurred writing
271           out the signers certificates.
272

EXAMPLES

274       Create a cleartext signed message:
275
276        openssl smime -sign -in message.txt -text -out mail.msg \
277               -signer mycert.pem
278
279       Create an opaque signed message:
280
281        openssl smime -sign -in message.txt -text -out mail.msg -nodetach \
282               -signer mycert.pem
283
284       Create a signed message, include some additional certificates and read
285       the private key from another file:
286
287        openssl smime -sign -in in.txt -text -out mail.msg \
288               -signer mycert.pem -inkey mykey.pem -certfile mycerts.pem
289
290       Create a signed message with two signers:
291
292        openssl smime -sign -in message.txt -text -out mail.msg \
293               -signer mycert.pem -signer othercert.pem
294
295       Send a signed message under Unix directly to sendmail, including
296       headers:
297
298        openssl smime -sign -in in.txt -text -signer mycert.pem \
299               -from steve@openssl.org -to someone@somewhere \
300               -subject "Signed message" | sendmail someone@somewhere
301
302       Verify a message and extract the signer's certificate if successful:
303
304        openssl smime -verify -in mail.msg -signer user.pem -out signedtext.txt
305
306       Send encrypted mail using triple DES:
307
308        openssl smime -encrypt -in in.txt -from steve@openssl.org \
309               -to someone@somewhere -subject "Encrypted message" \
310               -des3 user.pem -out mail.msg
311
312       Sign and encrypt mail:
313
314        openssl smime -sign -in ml.txt -signer my.pem -text \
315               | openssl smime -encrypt -out mail.msg \
316               -from steve@openssl.org -to someone@somewhere \
317               -subject "Signed and Encrypted message" -des3 user.pem
318
319       Note: the encryption command does not include the -text option because
320       the message being encrypted already has MIME headers.
321
322       Decrypt mail:
323
324        openssl smime -decrypt -in mail.msg -recip mycert.pem -inkey key.pem
325
326       The output from Netscape form signing is a PKCS#7 structure with the
327       detached signature format. You can use this program to verify the
328       signature by line wrapping the base64 encoded structure and surrounding
329       it with:
330
331        -----BEGIN PKCS7-----
332        -----END PKCS7-----
333
334       and using the command:
335
336        openssl smime -verify -inform PEM -in signature.pem -content content.txt
337
338       Alternatively you can base64 decode the signature and use:
339
340        openssl smime -verify -inform DER -in signature.der -content content.txt
341
342       Create an encrypted message using 128 bit Camellia:
343
344        openssl smime -encrypt -in plain.txt -camellia128 -out mail.msg cert.pem
345
346       Add a signer to an existing message:
347
348        openssl smime -resign -in mail.msg -signer newsign.pem -out mail2.msg
349

BUGS

351       The MIME parser isn't very clever: it seems to handle most messages
352       that I've thrown at it but it may choke on others.
353
354       The code currently will only write out the signer's certificate to a
355       file: if the signer has a separate encryption certificate this must be
356       manually extracted. There should be some heuristic that determines the
357       correct encryption certificate.
358
359       Ideally a database should be maintained of a certificates for each
360       email address.
361
362       The code doesn't currently take note of the permitted symmetric
363       encryption algorithms as supplied in the SMIMECapabilities signed
364       attribute. This means the user has to manually include the correct
365       encryption algorithm. It should store the list of permitted ciphers in
366       a database and only use those.
367
368       No revocation checking is done on the signer's certificate.
369
370       The current code can only handle S/MIME v2 messages, the more complex
371       S/MIME v3 structures may cause parsing errors.
372

HISTORY

374       The use of multiple -signer options and the -resign command were first
375       added in OpenSSL 1.0.0
376
377
378
3791.0.0e                            2010-10-04                          SMIME(1)
Impressum