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

NAME

6       smime - S/MIME utility
7

SYNOPSIS

9       openssl smime [-encrypt] [-decrypt] [-sign] [-verify] [-pk7out] [-des]
10       [-des3] [-rc2-40] [-rc2-64] [-rc2-128] [-aes128] [-aes192] [-aes256]
11       [-in file] [-certfile file] [-signer file] [-recip  file] [-inform
12       SMIME⎪PEM⎪DER] [-passin arg] [-inkey file] [-out file] [-outform
13       SMIME⎪PEM⎪DER] [-content file] [-to addr] [-from ad] [-subject s]
14       [-text] [-rand file(s)] [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 five 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 out‐
42           puts the signed data. Both clear text and opaque signing is sup‐
43           ported.
44
45       -pk7out
46           takes an input message and writes out a PEM encoded PKCS#7 struc‐
47           ture.
48
49       -in filename
50           the input message to be encrypted or signed or the MIME message to
51           be decrypted or verified.
52
53       -inform SMIME⎪PEM⎪DER
54           this specifies the input format for the PKCS#7 structure. The
55           default is SMIME which reads an S/MIME format message. PEM and DER
56           format change this to expect PEM and DER format PKCS#7 structures
57           instead. This currently only affects the input format of the PKCS#7
58           structure, if no PKCS#7 structure is being input (for example with
59           -encrypt or -sign) this option has no effect.
60
61       -out filename
62           the message text that has been decrypted or verified or the output
63           MIME format message that has been signed or verified.
64
65       -outform SMIME⎪PEM⎪DER
66           this specifies the output format for the PKCS#7 structure. The
67           default is SMIME which write an S/MIME format message. PEM and DER
68           format change this to write PEM and DER format PKCS#7 structures
69           instead. This currently only affects the output format of the
70           PKCS#7 structure, if no PKCS#7 structure is being output (for exam‐
71           ple with -verify or -decrypt) this option has no effect.
72
73       -content filename
74           This specifies a file containing the detached content, this is only
75           useful with the -verify command. This is only usable if the PKCS#7
76           structure is using the detached signature form where the content is
77           not included. This option will override any content if the input
78           format is S/MIME and it uses the multipart/signed MIME content
79           type.
80
81       -text
82           this option adds plain text (text/plain) MIME headers to the sup‐
83           plied message if encrypting or signing. If decrypting or verifying
84           it strips off text headers: if the decrypted or verified message is
85           not of MIME type text/plain then an error occurs.
86
87       -CAfile file
88           a file containing trusted CA certificates, only used with -verify.
89
90       -CApath dir
91           a directory containing trusted CA certificates, only used with
92           -verify. This directory must be a standard certificate directory:
93           that is a hash of each subject name (using x509 -hash) should be
94           linked to each certificate.
95
96       -des -des3 -rc2-40 -rc2-64 -rc2-128 -aes128 -aes192 -aes256
97           the encryption algorithm to use. DES (56 bits), triple DES (168
98           bits), 40, 64 or 128 bit RC2 or 128, 192 or 256 bit AES respec‐
99           tively.  If not specified 40 bit RC2 is used. Only used with
100           -encrypt.
101
102       -nointern
103           when verifying a message normally certificates (if any) included in
104           the message are searched for the signing certificate. With this
105           option only the certificates specified in the -certfile option are
106           used.  The supplied certificates can still be used as untrusted CAs
107           however.
108
109       -noverify
110           do not verify the signers certificate of a signed message.
111
112       -nochain
113           do not do chain verification of signers certificates: that is don't
114           use the certificates in the signed message as untrusted CAs.
115
116       -nosigs
117           don't try to verify the signatures on the message.
118
119       -nocerts
120           when signing a message the signer's certificate is normally
121           included with this option it is excluded. This will reduce the size
122           of the signed message but the verifier must have a copy of the
123           signers certificate available locally (passed using the -certfile
124           option for example).
125
126       -noattr
127           normally when a message is signed a set of attributes are included
128           which include the signing time and supported symmetric algorithms.
129           With this option they are not included.
130
131       -binary
132           normally the input message is converted to "canonical" format which
133           is effectively using CR and LF as end of line: as required by the
134           S/MIME specification. When this option is present no translation
135           occurs. This is useful when handling binary data which may not be
136           in MIME format.
137
138       -nodetach
139           when signing a message use opaque signing: this form is more resis‐
140           tant to translation by mail relays but it cannot be read by mail
141           agents that do not support S/MIME.  Without this option cleartext
142           signing with the MIME type multipart/signed is used.
143
144       -certfile file
145           allows additional certificates to be specified. When signing these
146           will be included with the message. When verifying these will be
147           searched for the signers certificates. The certificates should be
148           in PEM format.
149
150       -signer file
151           the signers certificate when signing a message. If a message is
152           being verified then the signers certificates will be written to
153           this file if the verification was successful.
154
155       -recip file
156           the recipients certificate when decrypting a message. This certifi‐
157           cate must match one of the recipients of the message or an error
158           occurs.
159
160       -inkey file
161           the private key to use when signing or decrypting. This must match
162           the corresponding certificate. If this option is not specified then
163           the private key must be included in the certificate file specified
164           with the -recip or -signer file.
165
166       -passin arg
167           the private key password source. For more information about the
168           format of arg see the PASS PHRASE ARGUMENTS section in openssl(1).
169
170       -rand file(s)
171           a file or files containing random data used to seed the random num‐
172           ber generator, or an EGD socket (see RAND_egd(3)).  Multiple files
173           can be specified separated by a OS-dependent character.  The sepa‐
174           rator is ; for MS-Windows, , for OpenVMS, and : for all others.
175
176       cert.pem...
177           one or more certificates of message recipients: used when encrypt‐
178           ing a message.
179
180       -to, -from, -subject
181           the relevant mail headers. These are included outside the signed
182           portion of a message so they may be included manually. If signing
183           then many S/MIME mail clients check the signers certificate's email
184           address matches that specified in the From: address.
185

NOTES

187       The MIME message must be sent without any blank lines between the head‐
188       ers and the output. Some mail programs will automatically add a blank
189       line. Piping the mail directly to sendmail is one way to achieve the
190       correct format.
191
192       The supplied message to be signed or encrypted must include the neces‐
193       sary MIME headers or many S/MIME clients wont display it properly (if
194       at all). You can use the -text option to automatically add plain text
195       headers.
196
197       A "signed and encrypted" message is one where a signed message is then
198       encrypted. This can be produced by encrypting an already signed mes‐
199       sage: see the examples section.
200
201       This version of the program only allows one signer per message but it
202       will verify multiple signers on received messages. Some S/MIME clients
203       choke if a message contains multiple signers. It is possible to sign
204       messages "in parallel" by signing an already signed message.
205
206       The options -encrypt and -decrypt reflect common usage in S/MIME
207       clients. Strictly speaking these process PKCS#7 enveloped data: PKCS#7
208       encrypted data is used for other purposes.
209

EXIT CODES

211       0   the operation was completely successfully.
212
213       1   an error occurred parsing the command options.
214
215       2   one of the input files could not be read.
216
217       3   an error occurred creating the PKCS#7 file or when reading the MIME
218           message.
219
220       4   an error occurred decrypting or verifying the message.
221
222       5   the message was verified correctly but an error occurred writing
223           out the signers certificates.
224

EXAMPLES

226       Create a cleartext signed message:
227
228        openssl smime -sign -in message.txt -text -out mail.msg \
229               -signer mycert.pem
230
231       Create and opaque signed message
232
233        openssl smime -sign -in message.txt -text -out mail.msg -nodetach \
234               -signer mycert.pem
235
236       Create a signed message, include some additional certificates and read
237       the private key from another file:
238
239        openssl smime -sign -in in.txt -text -out mail.msg \
240               -signer mycert.pem -inkey mykey.pem -certfile mycerts.pem
241
242       Send a signed message under Unix directly to sendmail, including head‐
243       ers:
244
245        openssl smime -sign -in in.txt -text -signer mycert.pem \
246               -from steve@openssl.org -to someone@somewhere \
247               -subject "Signed message" ⎪ sendmail someone@somewhere
248
249       Verify a message and extract the signer's certificate if successful:
250
251        openssl smime -verify -in mail.msg -signer user.pem -out signedtext.txt
252
253       Send encrypted mail using triple DES:
254
255        openssl smime -encrypt -in in.txt -from steve@openssl.org \
256               -to someone@somewhere -subject "Encrypted message" \
257               -des3 user.pem -out mail.msg
258
259       Sign and encrypt mail:
260
261        openssl smime -sign -in ml.txt -signer my.pem -text \
262               ⎪ openssl smime -encrypt -out mail.msg \
263               -from steve@openssl.org -to someone@somewhere \
264               -subject "Signed and Encrypted message" -des3 user.pem
265
266       Note: the encryption command does not include the -text option because
267       the message being encrypted already has MIME headers.
268
269       Decrypt mail:
270
271        openssl smime -decrypt -in mail.msg -recip mycert.pem -inkey key.pem
272
273       The output from Netscape form signing is a PKCS#7 structure with the
274       detached signature format. You can use this program to verify the sig‐
275       nature by line wrapping the base64 encoded structure and surrounding it
276       with:
277
278        -----BEGIN PKCS7-----
279        -----END PKCS7-----
280
281       and using the command,
282
283        openssl smime -verify -inform PEM -in signature.pem -content content.txt
284
285       alternatively you can base64 decode the signature and use
286
287        openssl smime -verify -inform DER -in signature.der -content content.txt
288

BUGS

290       The MIME parser isn't very clever: it seems to handle most messages
291       that I've thrown at it but it may choke on others.
292
293       The code currently will only write out the signer's certificate to a
294       file: if the signer has a separate encryption certificate this must be
295       manually extracted. There should be some heuristic that determines the
296       correct encryption certificate.
297
298       Ideally a database should be maintained of a certificates for each
299       email address.
300
301       The code doesn't currently take note of the permitted symmetric encryp‐
302       tion algorithms as supplied in the SMIMECapabilities signed attribute.
303       this means the user has to manually include the correct encryption
304       algorithm. It should store the list of permitted ciphers in a database
305       and only use those.
306
307       No revocation checking is done on the signer's certificate.
308
309       The current code can only handle S/MIME v2 messages, the more complex
310       S/MIME v3 structures may cause parsing errors.
311
312
313
3140.9.8b                            2004-02-26                          SMIME(1)
Impressum