dhgen is gone.
[openssl.git] / doc / apps / smime.pod
1 =pod
2
3 =head1 NAME
4
5 smime - S/MIME utility
6
7 =head1 SYNOPSIS
8
9 B<openssl> B<smime>
10 [B<-encrypt>]
11 [B<-decrypt>]
12 [B<-sign>]
13 [B<-verify>]
14 [B<-pk7out>]
15 [B<-des>]
16 [B<-des3>]
17 [B<-rc2-40>]
18 [B<-rc2-64>]
19 [B<-rc2-128>]
20 [B<-in file>]
21 [B<-certfile file>]
22 [B<-signer file>]
23 [B<-recip  file>]
24 [B<-in file>]
25 [B<-inkey file>]
26 [B<-out file>]
27 [B<-to addr>]
28 [B<-from ad>]
29 [B<-subject s>]
30 [B<-text>]
31 [cert.pem]...
32
33 =head1 DESCRIPTION
34
35 The B<smime> command handles S/MIME mail. It can encrypt, decrypt, sign and
36 verify S/MIME messages.
37
38 =head1 COMMAND OPTIONS
39
40 There are five operation options that set the type of operation to be performed.
41 The meaning of the other options varies according to the operation type.
42
43 =over 4
44
45 =item B<-encrypt>
46
47 encrypt mail for the given recipient certificates. Input file is the message
48 to be encrypted. The output file is the encrypted mail in MIME format.
49
50 =item B<-decrypt>
51
52 decrypt mail using the supplied certificate and private key. Expects an
53 encrypted mail message in MIME format for the input file. The decrypted mail
54 is written to the output file.
55
56 =item B<-sign>
57
58 sign mail using the supplied certificate and private key. Input file is
59 the message to be signed. The signed message in MIME format is written
60 to the output file.
61
62 =item B<-verify>
63
64 verify signed mail. Expects a signed mail message on input and outputs
65 the signed data. Both clear text and opaque signing is supported.
66
67 =item B<-pk7out>
68
69 takes an input message and writes out a PEM encoded PKCS#7 structure.
70
71 =item B<-in filename>
72
73 the input message to be encrypted or signed or the MIME message to
74 be decrypted or verified.
75
76 =item B<-out filename>
77
78 the message text that has been decrypted or verified or the output MIME
79 format message that has been signed or verified.
80
81 =item B<-text>
82
83 this option adds plain text (text/plain) MIME headers to the supplied
84 message if encrypting or signing. If decrypting or verifying it strips
85 off text headers: if the decrypted or verified message is not of MIME 
86 type text/plain then an error occurs.
87
88 =item B<-CAfile file>
89
90 a file containing trusted CA certificates, only used with B<-verify>.
91
92 =item B<-CApath dir>
93
94 a directory containing trusted CA certificates, only used with
95 B<-verify>. This directory must be a standard certificate directory: that
96 is a hash of each subject name (using B<x509 -hash>) should be linked
97 to each certificate.
98
99 =item B<-des -des3 -rc2-40 -rc2-64 -rc2-128>
100
101 the encryption algorithm to use. DES (56 bits), triple DES (168 bits)
102 or 40, 64 or 128 bit RC2 respectively if not specified 40 bit RC2 is
103 used. Only used with B<-encrypt>.
104
105 =item B<-nointern>
106
107 when verifying a message normally certificates (if any) included in
108 the message are searched for the signing certificate. With this option
109 only the certificates specified in the B<-certfile> option are used.
110 The supplied certificates can still be used as untrusted CAs however.
111
112 =item B<-noverify>
113
114 do not verify the signers certificate of a signed message.
115
116 =item B<-nochain>
117
118 do not do chain verification of signers certificates: that is don't
119 use the certificates in the signed message as untrusted CAs.
120
121 =item B<-nosigs>
122
123 don't try to verify the signatures on the message.
124
125 =item B<-nocerts>
126
127 when signing a message the signer's certificate is normally included
128 with this option it is excluded. This will reduce the size of the
129 signed message but the verifier must have a copy of the signers certificate
130 available locally (passed using the B<-certfile> option for example).
131
132 =item B<-noattr>
133
134 normally when a message is signed a set of attributes are included which
135 include the signing time and supported symmetric algorithms. With this
136 option they are not included.
137
138 =item B<-binary>
139
140 normally the input message is converted to "canonical" format which is
141 effectively using CR and LF as end of line: as required by the S/MIME
142 specification. When this option is present no translation occurs. This
143 is useful when handling binary data which may not be in MIME format.
144
145 =item B<-nodetach>
146
147 when signing a message use opaque signing: this form is more resistant
148 to translation by mail relays but it cannot be read by mail agents that
149 do not support S/MIME.  Without this option cleartext signing with
150 the MIME type multipart/signed is used.
151
152 =item B<-certfile file>
153
154 allows additional certificates to be specified. When signing these will
155 be included with the message. When verifying these will be searched for
156 the signers certificates. The certificates should be in PEM format.
157
158 =item B<-signer file>
159
160 the signers certificate when signing a message. If a message is
161 being verified then the signers certificates will be written to this
162 file if the verification was successful.
163
164 =item B<-recip file>
165
166 the recipients certificate when decrypting a message. This certificate
167 must match one of the recipients of the message or an error occurs.
168
169 =item B<-inkey file>
170
171 the private key to use when signing or decrypting. This must match the
172 corresponding certificate. If this option is not specified then the
173 private key must be included in the certificate file specified with
174 the B<-recip> or B<-signer> file.
175
176 =item B<cert.pem...>
177
178 one or more certificates of message recipients: used when encrypting
179 a message. 
180
181 =item B<-to, -from, -subject>
182
183 the relevant mail headers. These are included outside the signed
184 portion of a message so they may be included manually. If signing
185 then many S/MIME mail clients check the signers certificate's email
186 address matches that specified in the From: address.
187
188 =back
189
190 =head1 NOTES
191
192 The MIME message must be sent without any blank lines between the
193 headers and the output. Some mail programs will automatically add
194 a blank line. Piping the mail directly to sendmail is one way to
195 achieve the correct format.
196
197 The supplied message to be signed or encrypted must include the
198 necessary MIME headers: or many S/MIME clients wont display it
199 properly (if at all). You can use the B<-text> option to automatically
200 add plain text headers.
201
202 A "signed and encrypted" message is one where a signed message is
203 then encrypted. This can be produced by encrypting an already signed
204 message: see the examples section.
205
206 This version of the program only allows one signer per message but it
207 will verify multiple signers on received messages. Some S/MIME clients
208 choke if a message contains multiple signers. It is possible to sign
209 messages "in parallel" by signing an already signed message.
210
211 The options B<-encrypt> and B<-decrypt> reflect common usage in S/MIME
212 clients. Strictly speaking these process PKCS#7 enveloped data: PKCS#7
213 encrypted data is used for other purposes.
214
215 =head1 EXIT CODES
216
217 =over 4
218
219 =item 0
220
221 the operation was completely successfully.
222
223 =item 1 
224
225 an error occurred parsing the command options.
226
227 =item 2
228
229 one of the input files could not be read.
230
231 =item 3
232
233 an error occurred creating the PKCS#7 file or when reading the MIME
234 message.
235
236 =item 4
237
238 an error occurred decrypting or verifying the message.
239
240 =item 5
241
242 the message was verified correctly but an error occurred writing out
243 the signers certificates.
244
245 =back
246
247 =head1 EXAMPLES
248
249 Create a cleartext signed message:
250
251  openssl smime -sign -in message.txt -text -out mail.msg \
252         -signer mycert.pem
253
254 Create and opaque signed message
255
256  openssl smime -sign -in message.txt -text -out mail.msg -nodetach \
257         -signer mycert.pem
258
259 Create a signed message, include some additional certificates and
260 read the private key from another file:
261
262  openssl smime -sign -in in.txt -text -out mail.msg \
263         -signer mycert.pem -inkey mykey.pem -certfile mycerts.pem
264
265 Send a signed message under Unix directly to sendmail, including headers:
266
267  openssl smime -sign -in in.txt -text -signer mycert.pem \
268         -from steve@openssl.org -to someone@somewhere \
269         -subject "Signed message" | sendmail someone@somewhere
270
271 Verify a message and extract the signer's certificate if successful:
272
273  openssl smime -verify -in mail.msg -signer user.pem -out signedtext.txt
274
275 Send encrypted mail using triple DES:
276
277  openssl smime -encrypt -in in.txt -from steve@openssl.org \
278         -to someone@somewhere -subject "Encrypted message" \
279         -des3 user.pem -out mail.msg
280
281 Sign and encrypt mail:
282
283  openssl smime -sign -in ml.txt -signer my.pem -text \
284         | openssl -encrypt -out mail.msg \
285         -from steve@openssl.org -to someone@somewhere \
286         -subject "Signed and Encrypted message" -des3 user.pem
287
288 Note: the encryption command does not include the B<-text> option because the message
289 being encrypted already has MIME headers.
290
291 Decrypt mail:
292
293  openssl smime -decrypt -in mail.msg -recip mycert.pem -inkey key.pem
294
295 =head1 BUGS
296
297 The MIME parser isn't very clever: it seems to handle most messages that I've thrown
298 at it but it may choke on others.
299
300 The code currently will only write out the signer's certificate to a file: if the
301 signer has a separate encryption certificate this must be manually extracted. There
302 should be some heuristic that determines the correct encryption certificate.
303
304 Ideally a database should be maintained of a certificates for each email address.
305
306 The code doesn't currently take note of the permitted symmetric encryption
307 algorithms as supplied in the SMIMECapabilities signed attribute. this means the
308 user has to manually include the correct encryption algorithm. It should store
309 the list of permitted ciphers in a database and only use those.
310
311 No revocation checking is done on the signer's certificate.
312
313 The current code can only handle S/MIME v2 messages, the more complex S/MIME v3
314 structures may cause parsing errors.
315
316 =cut