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] [-CAfile file] [-CApath dir]
11       [-trusted_first] [-certfile file] [-signer file] [-recip  file]
12       [-inform SMIME|PEM|DER] [-passin arg] [-inkey file] [-out file]
13       [-outform SMIME|PEM|DER] [-content file] [-to addr] [-from ad]
14       [-subject s] [-text] [-indef] [-noindef] [-stream] [-rand file(s)] [-md
15       digest] [cert.pem]...
16

DESCRIPTION

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

COMMAND OPTIONS

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

NOTES

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

EXIT CODES

266       0   the operation was completely successfully.
267
268       1   an error occurred parsing the command options.
269
270       2   one of the input files could not be read.
271
272       3   an error occurred creating the PKCS#7 file or when reading the MIME
273           message.
274
275       4   an error occurred decrypting or verifying the message.
276
277       5   the message was verified correctly but an error occurred writing
278           out the signers certificates.
279

EXAMPLES

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

BUGS

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

HISTORY

381       The use of multiple -signer options and the -resign command were first
382       added in OpenSSL 1.0.0
383
384
385
3861.0.1e                            2017-03-22                          SMIME(1)
Impressum