xref: /freebsd/crypto/openssl/doc/man1/openssl-smime.pod.in (revision 0d0c8621fd181e507f0fb50ffcca606faf66a8c2)
1b077aed3SPierre Pronchery=pod
2b077aed3SPierre Pronchery{- OpenSSL::safe::output_do_not_edit_headers(); -}
3b077aed3SPierre Pronchery
4b077aed3SPierre Pronchery=head1 NAME
5b077aed3SPierre Pronchery
6b077aed3SPierre Proncheryopenssl-smime - S/MIME command
7b077aed3SPierre Pronchery
8b077aed3SPierre Pronchery=head1 SYNOPSIS
9b077aed3SPierre Pronchery
10b077aed3SPierre ProncheryB<openssl> B<smime>
11b077aed3SPierre Pronchery[B<-help>]
12b077aed3SPierre Pronchery[B<-encrypt>]
13b077aed3SPierre Pronchery[B<-decrypt>]
14b077aed3SPierre Pronchery[B<-sign>]
15b077aed3SPierre Pronchery[B<-resign>]
16b077aed3SPierre Pronchery[B<-verify>]
17b077aed3SPierre Pronchery[B<-pk7out>]
18b077aed3SPierre Pronchery[B<-binary>]
19b077aed3SPierre Pronchery[B<-crlfeol>]
20b077aed3SPierre Pronchery[B<-I<cipher>>]
21b077aed3SPierre Pronchery[B<-in> I<file>]
22b077aed3SPierre Pronchery[B<-certfile> I<file>]
23b077aed3SPierre Pronchery[B<-signer> I<file>]
24b077aed3SPierre Pronchery[B<-nointern>]
25b077aed3SPierre Pronchery[B<-noverify>]
26b077aed3SPierre Pronchery[B<-nochain>]
27b077aed3SPierre Pronchery[B<-nosigs>]
28b077aed3SPierre Pronchery[B<-nocerts>]
29b077aed3SPierre Pronchery[B<-noattr>]
30b077aed3SPierre Pronchery[B<-nodetach>]
31b077aed3SPierre Pronchery[B<-nosmimecap>]
32b077aed3SPierre Pronchery[B<-recip> I< file>]
33b077aed3SPierre Pronchery[B<-inform> B<DER>|B<PEM>|B<SMIME>]
34b077aed3SPierre Pronchery[B<-outform> B<DER>|B<PEM>|B<SMIME>]
35b077aed3SPierre Pronchery[B<-keyform> B<DER>|B<PEM>|B<P12>|B<ENGINE>]
36b077aed3SPierre Pronchery[B<-passin> I<arg>]
37b077aed3SPierre Pronchery[B<-inkey> I<filename>|I<uri>]
38b077aed3SPierre Pronchery[B<-out> I<file>]
39b077aed3SPierre Pronchery[B<-content> I<file>]
40b077aed3SPierre Pronchery[B<-to> I<addr>]
41b077aed3SPierre Pronchery[B<-from> I<ad>]
42b077aed3SPierre Pronchery[B<-subject> I<s>]
43b077aed3SPierre Pronchery[B<-text>]
44b077aed3SPierre Pronchery[B<-indef>]
45b077aed3SPierre Pronchery[B<-noindef>]
46b077aed3SPierre Pronchery[B<-stream>]
47b077aed3SPierre Pronchery[B<-md> I<digest>]
48b077aed3SPierre Pronchery{- $OpenSSL::safe::opt_trust_synopsis -}
49b077aed3SPierre Pronchery{- $OpenSSL::safe::opt_engine_synopsis -}{- $OpenSSL::safe::opt_r_synopsis -}
50b077aed3SPierre Pronchery{- $OpenSSL::safe::opt_v_synopsis -}
51b077aed3SPierre Pronchery{- $OpenSSL::safe::opt_provider_synopsis -}
52b077aed3SPierre Pronchery{- $OpenSSL::safe::opt_config_synopsis -}
53b077aed3SPierre ProncheryI<recipcert> ...
54b077aed3SPierre Pronchery
55b077aed3SPierre Pronchery=head1 DESCRIPTION
56b077aed3SPierre Pronchery
57b077aed3SPierre ProncheryThis command handles S/MIME mail. It can encrypt, decrypt, sign
58b077aed3SPierre Proncheryand verify S/MIME messages.
59b077aed3SPierre Pronchery
60b077aed3SPierre Pronchery=head1 OPTIONS
61b077aed3SPierre Pronchery
62b077aed3SPierre ProncheryThere are six operation options that set the type of operation to be performed.
63b077aed3SPierre ProncheryThe meaning of the other options varies according to the operation type.
64b077aed3SPierre Pronchery
65b077aed3SPierre Pronchery=over 4
66b077aed3SPierre Pronchery
67b077aed3SPierre Pronchery=item B<-help>
68b077aed3SPierre Pronchery
69b077aed3SPierre ProncheryPrint out a usage message.
70b077aed3SPierre Pronchery
71b077aed3SPierre Pronchery=item B<-encrypt>
72b077aed3SPierre Pronchery
73b077aed3SPierre ProncheryEncrypt mail for the given recipient certificates. Input file is the message
74b077aed3SPierre Proncheryto be encrypted. The output file is the encrypted mail in MIME format.
75b077aed3SPierre Pronchery
76b077aed3SPierre ProncheryNote that no revocation check is done for the recipient cert, so if that
77b077aed3SPierre Proncherykey has been compromised, others may be able to decrypt the text.
78b077aed3SPierre Pronchery
79b077aed3SPierre Pronchery=item B<-decrypt>
80b077aed3SPierre Pronchery
81b077aed3SPierre ProncheryDecrypt mail using the supplied certificate and private key. Expects an
82b077aed3SPierre Proncheryencrypted mail message in MIME format for the input file. The decrypted mail
83b077aed3SPierre Proncheryis written to the output file.
84b077aed3SPierre Pronchery
85b077aed3SPierre Pronchery=item B<-sign>
86b077aed3SPierre Pronchery
87b077aed3SPierre ProncherySign mail using the supplied certificate and private key. Input file is
88b077aed3SPierre Proncherythe message to be signed. The signed message in MIME format is written
89b077aed3SPierre Proncheryto the output file.
90b077aed3SPierre Pronchery
91b077aed3SPierre Pronchery=item B<-verify>
92b077aed3SPierre Pronchery
93b077aed3SPierre ProncheryVerify signed mail. Expects a signed mail message on input and outputs
94b077aed3SPierre Proncherythe signed data. Both clear text and opaque signing is supported.
95b077aed3SPierre Pronchery
96b077aed3SPierre Pronchery=item B<-pk7out>
97b077aed3SPierre Pronchery
98b077aed3SPierre ProncheryTakes an input message and writes out a PEM encoded PKCS#7 structure.
99b077aed3SPierre Pronchery
100b077aed3SPierre Pronchery=item B<-resign>
101b077aed3SPierre Pronchery
102b077aed3SPierre ProncheryResign a message: take an existing message and one or more new signers.
103b077aed3SPierre Pronchery
104b077aed3SPierre Pronchery=item B<-in> I<filename>
105b077aed3SPierre Pronchery
106b077aed3SPierre ProncheryThe input message to be encrypted or signed or the MIME message to
107b077aed3SPierre Proncherybe decrypted or verified.
108b077aed3SPierre Pronchery
109b077aed3SPierre Pronchery=item B<-out> I<filename>
110b077aed3SPierre Pronchery
111b077aed3SPierre ProncheryThe message text that has been decrypted or verified or the output MIME
112b077aed3SPierre Proncheryformat message that has been signed or verified.
113b077aed3SPierre Pronchery
114b077aed3SPierre Pronchery=item B<-inform> B<DER>|B<PEM>|B<SMIME>
115b077aed3SPierre Pronchery
116b077aed3SPierre ProncheryThe input format of the PKCS#7 (S/MIME) structure (if one is being read);
117b077aed3SPierre Proncherythe default is B<SMIME>.
118b077aed3SPierre ProncherySee L<openssl-format-options(1)> for details.
119b077aed3SPierre Pronchery
120b077aed3SPierre Pronchery=item B<-outform> B<DER>|B<PEM>|B<SMIME>
121b077aed3SPierre Pronchery
122b077aed3SPierre ProncheryThe output format of the PKCS#7 (S/MIME) structure (if one is being written);
123b077aed3SPierre Proncherythe default is B<SMIME>.
124b077aed3SPierre ProncherySee L<openssl-format-options(1)> for details.
125b077aed3SPierre Pronchery
126b077aed3SPierre Pronchery=item B<-keyform> B<DER>|B<PEM>|B<P12>|B<ENGINE>
127b077aed3SPierre Pronchery
128b077aed3SPierre ProncheryThe key format; unspecified by default.
129b077aed3SPierre ProncherySee L<openssl-format-options(1)> for details.
130b077aed3SPierre Pronchery
131b077aed3SPierre Pronchery=item B<-stream>, B<-indef>, B<-noindef>
132b077aed3SPierre Pronchery
133b077aed3SPierre ProncheryThe B<-stream> and B<-indef> options are equivalent and enable streaming I/O
134b077aed3SPierre Proncheryfor encoding operations. This permits single pass processing of data without
135b077aed3SPierre Proncherythe need to hold the entire contents in memory, potentially supporting very
136b077aed3SPierre Proncherylarge files. Streaming is automatically set for S/MIME signing with detached
137b077aed3SPierre Proncherydata if the output format is B<SMIME> it is currently off by default for all
138b077aed3SPierre Proncheryother operations.
139b077aed3SPierre Pronchery
140b077aed3SPierre Pronchery=item B<-noindef>
141b077aed3SPierre Pronchery
142b077aed3SPierre ProncheryDisable streaming I/O where it would produce and indefinite length constructed
143b077aed3SPierre Proncheryencoding. This option currently has no effect. In future streaming will be
144b077aed3SPierre Proncheryenabled by default on all relevant operations and this option will disable it.
145b077aed3SPierre Pronchery
146b077aed3SPierre Pronchery=item B<-content> I<filename>
147b077aed3SPierre Pronchery
148b077aed3SPierre ProncheryThis specifies a file containing the detached content, this is only
149b077aed3SPierre Proncheryuseful with the B<-verify> command. This is only usable if the PKCS#7
150b077aed3SPierre Proncherystructure is using the detached signature form where the content is
151b077aed3SPierre Proncherynot included. This option will override any content if the input format
152b077aed3SPierre Proncheryis S/MIME and it uses the multipart/signed MIME content type.
153b077aed3SPierre Pronchery
154b077aed3SPierre Pronchery=item B<-text>
155b077aed3SPierre Pronchery
156b077aed3SPierre ProncheryThis option adds plain text (text/plain) MIME headers to the supplied
157b077aed3SPierre Proncherymessage if encrypting or signing. If decrypting or verifying it strips
158b077aed3SPierre Proncheryoff text headers: if the decrypted or verified message is not of MIME
159b077aed3SPierre Proncherytype text/plain then an error occurs.
160b077aed3SPierre Pronchery
161b077aed3SPierre Pronchery=item B<-md> I<digest>
162b077aed3SPierre Pronchery
163b077aed3SPierre ProncheryDigest algorithm to use when signing or resigning. If not present then the
164b077aed3SPierre Proncherydefault digest algorithm for the signing key will be used (usually SHA1).
165b077aed3SPierre Pronchery
166b077aed3SPierre Pronchery=item B<-I<cipher>>
167b077aed3SPierre Pronchery
168b077aed3SPierre ProncheryThe encryption algorithm to use. For example DES  (56 bits) - B<-des>,
169b077aed3SPierre Proncherytriple DES (168 bits) - B<-des3>,
170b077aed3SPierre ProncheryEVP_get_cipherbyname() function) can also be used preceded by a dash, for
171b077aed3SPierre Proncheryexample B<-aes-128-cbc>. See L<openssl-enc(1)> for list of ciphers
172b077aed3SPierre Proncherysupported by your version of OpenSSL.
173b077aed3SPierre Pronchery
174b077aed3SPierre ProncheryIf not specified triple DES is used. Only used with B<-encrypt>.
175b077aed3SPierre Pronchery
176b077aed3SPierre Pronchery=item B<-nointern>
177b077aed3SPierre Pronchery
178b077aed3SPierre ProncheryWhen verifying a message normally certificates (if any) included in
179b077aed3SPierre Proncherythe message are searched for the signing certificate. With this option
180b077aed3SPierre Proncheryonly the certificates specified in the B<-certfile> option are used.
181b077aed3SPierre ProncheryThe supplied certificates can still be used as untrusted CAs however.
182b077aed3SPierre Pronchery
183b077aed3SPierre Pronchery=item B<-noverify>
184b077aed3SPierre Pronchery
185b077aed3SPierre ProncheryDo not verify the signers certificate of a signed message.
186b077aed3SPierre Pronchery
187b077aed3SPierre Pronchery=item B<-nochain>
188b077aed3SPierre Pronchery
189b077aed3SPierre ProncheryDo not do chain verification of signers certificates; that is, do not
190b077aed3SPierre Proncheryuse the certificates in the signed message as untrusted CAs.
191b077aed3SPierre Pronchery
192b077aed3SPierre Pronchery=item B<-nosigs>
193b077aed3SPierre Pronchery
194b077aed3SPierre ProncheryDon't try to verify the signatures on the message.
195b077aed3SPierre Pronchery
196b077aed3SPierre Pronchery=item B<-nocerts>
197b077aed3SPierre Pronchery
19844096ebdSEnji CooperWhen signing a message, the signer's certificate is normally included.
19944096ebdSEnji CooperWith this option it is excluded. This will reduce the size of the
20044096ebdSEnji Coopersigned message, but the verifier must have a copy of the signers certificate
201b077aed3SPierre Proncheryavailable locally (passed using the B<-certfile> option for example).
202b077aed3SPierre Pronchery
203b077aed3SPierre Pronchery=item B<-noattr>
204b077aed3SPierre Pronchery
20544096ebdSEnji CooperNormally, when a message is signed, a set of attributes are included which
206b077aed3SPierre Proncheryinclude the signing time and supported symmetric algorithms. With this
207b077aed3SPierre Proncheryoption they are not included.
208b077aed3SPierre Pronchery
209b077aed3SPierre Pronchery=item B<-nodetach>
210b077aed3SPierre Pronchery
211b077aed3SPierre ProncheryWhen signing a message use opaque signing. This form is more resistant
212b077aed3SPierre Proncheryto translation by mail relays but it cannot be read by mail agents that
213b077aed3SPierre Proncherydo not support S/MIME.  Without this option cleartext signing with
214b077aed3SPierre Proncherythe MIME type multipart/signed is used.
215b077aed3SPierre Pronchery
216b077aed3SPierre Pronchery=item B<-nosmimecap>
217b077aed3SPierre Pronchery
218b077aed3SPierre ProncheryWhen signing a message, do not include the B<SMIMECapabilities> attribute.
219b077aed3SPierre Pronchery
220b077aed3SPierre Pronchery=item B<-binary>
221b077aed3SPierre Pronchery
222b077aed3SPierre ProncheryNormally the input message is converted to "canonical" format which is
223b077aed3SPierre Proncheryeffectively using CR and LF as end of line: as required by the S/MIME
224b077aed3SPierre Proncheryspecification. When this option is present no translation occurs. This
225b077aed3SPierre Proncheryis useful when handling binary data which may not be in MIME format.
226b077aed3SPierre Pronchery
227b077aed3SPierre Pronchery=item B<-crlfeol>
228b077aed3SPierre Pronchery
229b077aed3SPierre ProncheryNormally the output file uses a single B<LF> as end of line. When this
230b077aed3SPierre Proncheryoption is present B<CRLF> is used instead.
231b077aed3SPierre Pronchery
232b077aed3SPierre Pronchery=item B<-certfile> I<file>
233b077aed3SPierre Pronchery
234b077aed3SPierre ProncheryAllows additional certificates to be specified. When signing these will
235b077aed3SPierre Proncherybe included with the message. When verifying these will be searched for
236b077aed3SPierre Proncherythe signers certificates.
237b077aed3SPierre ProncheryThe input can be in PEM, DER, or PKCS#12 format.
238b077aed3SPierre Pronchery
239b077aed3SPierre Pronchery=item B<-signer> I<file>
240b077aed3SPierre Pronchery
241b077aed3SPierre ProncheryA signing certificate when signing or resigning a message, this option can be
242b077aed3SPierre Proncheryused multiple times if more than one signer is required. If a message is being
243b077aed3SPierre Proncheryverified then the signers certificates will be written to this file if the
244b077aed3SPierre Proncheryverification was successful.
245b077aed3SPierre Pronchery
246b077aed3SPierre Pronchery=item B<-recip> I<file>
247b077aed3SPierre Pronchery
248b077aed3SPierre ProncheryThe recipients certificate when decrypting a message. This certificate
249b077aed3SPierre Proncherymust match one of the recipients of the message or an error occurs.
250b077aed3SPierre Pronchery
251b077aed3SPierre Pronchery=item B<-inkey> I<filename>|I<uri>
252b077aed3SPierre Pronchery
253b077aed3SPierre ProncheryThe private key to use when signing or decrypting. This must match the
254b077aed3SPierre Proncherycorresponding certificate. If this option is not specified then the
255b077aed3SPierre Proncheryprivate key must be included in the certificate file specified with
256b077aed3SPierre Proncherythe B<-recip> or B<-signer> file. When signing this option can be used
257b077aed3SPierre Proncherymultiple times to specify successive keys.
258b077aed3SPierre Pronchery
259b077aed3SPierre Pronchery=item B<-passin> I<arg>
260b077aed3SPierre Pronchery
261b077aed3SPierre ProncheryThe private key password source. For more information about the format of I<arg>
262b077aed3SPierre Proncherysee L<openssl-passphrase-options(1)>.
263b077aed3SPierre Pronchery
264b077aed3SPierre Pronchery=item B<-to>, B<-from>, B<-subject>
265b077aed3SPierre Pronchery
266b077aed3SPierre ProncheryThe relevant mail headers. These are included outside the signed
267b077aed3SPierre Proncheryportion of a message so they may be included manually. If signing
268b077aed3SPierre Proncherythen many S/MIME mail clients check the signers certificate's email
269b077aed3SPierre Proncheryaddress matches that specified in the From: address.
270b077aed3SPierre Pronchery
271b077aed3SPierre Pronchery{- $OpenSSL::safe::opt_v_item -}
272b077aed3SPierre Pronchery
273b077aed3SPierre ProncheryAny verification errors cause the command to exit.
274b077aed3SPierre Pronchery
275b077aed3SPierre Pronchery{- $OpenSSL::safe::opt_trust_item -}
276b077aed3SPierre Pronchery
277b077aed3SPierre Pronchery{- $OpenSSL::safe::opt_engine_item -}
278b077aed3SPierre Pronchery
279b077aed3SPierre Pronchery{- $OpenSSL::safe::opt_r_item -}
280b077aed3SPierre Pronchery
281b077aed3SPierre Pronchery{- $OpenSSL::safe::opt_provider_item -}
282b077aed3SPierre Pronchery
283b077aed3SPierre Pronchery{- $OpenSSL::safe::opt_config_item -}
284b077aed3SPierre Pronchery
285b077aed3SPierre Pronchery=item I<recipcert> ...
286b077aed3SPierre Pronchery
287b077aed3SPierre ProncheryOne or more certificates of message recipients, used when encrypting
288b077aed3SPierre Proncherya message.
289b077aed3SPierre Pronchery
290b077aed3SPierre Pronchery=back
291b077aed3SPierre Pronchery
292b077aed3SPierre Pronchery=head1 NOTES
293b077aed3SPierre Pronchery
294b077aed3SPierre ProncheryThe MIME message must be sent without any blank lines between the
295b077aed3SPierre Proncheryheaders and the output. Some mail programs will automatically add
296b077aed3SPierre Proncherya blank line. Piping the mail directly to sendmail is one way to
297b077aed3SPierre Proncheryachieve the correct format.
298b077aed3SPierre Pronchery
299b077aed3SPierre ProncheryThe supplied message to be signed or encrypted must include the
300b077aed3SPierre Proncherynecessary MIME headers or many S/MIME clients won't display it
301b077aed3SPierre Proncheryproperly (if at all). You can use the B<-text> option to automatically
302b077aed3SPierre Proncheryadd plain text headers.
303b077aed3SPierre Pronchery
304b077aed3SPierre ProncheryA "signed and encrypted" message is one where a signed message is
305b077aed3SPierre Proncherythen encrypted. This can be produced by encrypting an already signed
306b077aed3SPierre Proncherymessage: see the examples section.
307b077aed3SPierre Pronchery
308b077aed3SPierre ProncheryThis version of the program only allows one signer per message but it
309b077aed3SPierre Proncherywill verify multiple signers on received messages. Some S/MIME clients
310b077aed3SPierre Proncherychoke if a message contains multiple signers. It is possible to sign
311b077aed3SPierre Proncherymessages "in parallel" by signing an already signed message.
312b077aed3SPierre Pronchery
313b077aed3SPierre ProncheryThe options B<-encrypt> and B<-decrypt> reflect common usage in S/MIME
314b077aed3SPierre Proncheryclients. Strictly speaking these process PKCS#7 enveloped data: PKCS#7
315b077aed3SPierre Proncheryencrypted data is used for other purposes.
316b077aed3SPierre Pronchery
317b077aed3SPierre ProncheryThe B<-resign> option uses an existing message digest when adding a new
318b077aed3SPierre Proncherysigner. This means that attributes must be present in at least one existing
319b077aed3SPierre Proncherysigner using the same message digest or this operation will fail.
320b077aed3SPierre Pronchery
321b077aed3SPierre ProncheryThe B<-stream> and B<-indef> options enable streaming I/O support.
322b077aed3SPierre ProncheryAs a result the encoding is BER using indefinite length constructed encoding
323b077aed3SPierre Proncheryand no longer DER. Streaming is supported for the B<-encrypt> operation and the
324b077aed3SPierre ProncheryB<-sign> operation if the content is not detached.
325b077aed3SPierre Pronchery
326b077aed3SPierre ProncheryStreaming is always used for the B<-sign> operation with detached data but
327b077aed3SPierre Proncherysince the content is no longer part of the PKCS#7 structure the encoding
328b077aed3SPierre Proncheryremains DER.
329b077aed3SPierre Pronchery
330b077aed3SPierre Pronchery=head1 EXIT CODES
331b077aed3SPierre Pronchery
332b077aed3SPierre Pronchery=over 4
333b077aed3SPierre Pronchery
334b077aed3SPierre Pronchery=item Z<>0
335b077aed3SPierre Pronchery
336b077aed3SPierre ProncheryThe operation was completely successfully.
337b077aed3SPierre Pronchery
338b077aed3SPierre Pronchery=item Z<>1
339b077aed3SPierre Pronchery
340b077aed3SPierre ProncheryAn error occurred parsing the command options.
341b077aed3SPierre Pronchery
342b077aed3SPierre Pronchery=item Z<>2
343b077aed3SPierre Pronchery
344b077aed3SPierre ProncheryOne of the input files could not be read.
345b077aed3SPierre Pronchery
346b077aed3SPierre Pronchery=item Z<>3
347b077aed3SPierre Pronchery
348b077aed3SPierre ProncheryAn error occurred creating the PKCS#7 file or when reading the MIME
349b077aed3SPierre Proncherymessage.
350b077aed3SPierre Pronchery
351b077aed3SPierre Pronchery=item Z<>4
352b077aed3SPierre Pronchery
353b077aed3SPierre ProncheryAn error occurred decrypting or verifying the message.
354b077aed3SPierre Pronchery
355b077aed3SPierre Pronchery=item Z<>5
356b077aed3SPierre Pronchery
357b077aed3SPierre ProncheryThe message was verified correctly but an error occurred writing out
358b077aed3SPierre Proncherythe signers certificates.
359b077aed3SPierre Pronchery
360b077aed3SPierre Pronchery=back
361b077aed3SPierre Pronchery
362b077aed3SPierre Pronchery=head1 EXAMPLES
363b077aed3SPierre Pronchery
364b077aed3SPierre ProncheryCreate a cleartext signed message:
365b077aed3SPierre Pronchery
366b077aed3SPierre Pronchery openssl smime -sign -in message.txt -text -out mail.msg \
367b077aed3SPierre Pronchery        -signer mycert.pem
368b077aed3SPierre Pronchery
369b077aed3SPierre ProncheryCreate an opaque signed message:
370b077aed3SPierre Pronchery
371b077aed3SPierre Pronchery openssl smime -sign -in message.txt -text -out mail.msg -nodetach \
372b077aed3SPierre Pronchery        -signer mycert.pem
373b077aed3SPierre Pronchery
374b077aed3SPierre ProncheryCreate a signed message, include some additional certificates and
375b077aed3SPierre Proncheryread the private key from another file:
376b077aed3SPierre Pronchery
377b077aed3SPierre Pronchery openssl smime -sign -in in.txt -text -out mail.msg \
378b077aed3SPierre Pronchery        -signer mycert.pem -inkey mykey.pem -certfile mycerts.pem
379b077aed3SPierre Pronchery
380b077aed3SPierre ProncheryCreate a signed message with two signers:
381b077aed3SPierre Pronchery
382b077aed3SPierre Pronchery openssl smime -sign -in message.txt -text -out mail.msg \
383b077aed3SPierre Pronchery        -signer mycert.pem -signer othercert.pem
384b077aed3SPierre Pronchery
385b077aed3SPierre ProncherySend a signed message under Unix directly to sendmail, including headers:
386b077aed3SPierre Pronchery
387b077aed3SPierre Pronchery openssl smime -sign -in in.txt -text -signer mycert.pem \
388b077aed3SPierre Pronchery        -from steve@openssl.org -to someone@somewhere \
389b077aed3SPierre Pronchery        -subject "Signed message" | sendmail someone@somewhere
390b077aed3SPierre Pronchery
391b077aed3SPierre ProncheryVerify a message and extract the signer's certificate if successful:
392b077aed3SPierre Pronchery
393b077aed3SPierre Pronchery openssl smime -verify -in mail.msg -signer user.pem -out signedtext.txt
394b077aed3SPierre Pronchery
395b077aed3SPierre ProncherySend encrypted mail using triple DES:
396b077aed3SPierre Pronchery
397*0d0c8621SEnji Cooper openssl smime -encrypt -in in.txt -out mail.msg -from steve@openssl.org \
398b077aed3SPierre Pronchery        -to someone@somewhere -subject "Encrypted message" \
399*0d0c8621SEnji Cooper        -des3 user.pem
400b077aed3SPierre Pronchery
401b077aed3SPierre ProncherySign and encrypt mail:
402b077aed3SPierre Pronchery
403b077aed3SPierre Pronchery openssl smime -sign -in ml.txt -signer my.pem -text \
404b077aed3SPierre Pronchery        | openssl smime -encrypt -out mail.msg \
405b077aed3SPierre Pronchery        -from steve@openssl.org -to someone@somewhere \
406b077aed3SPierre Pronchery        -subject "Signed and Encrypted message" -des3 user.pem
407b077aed3SPierre Pronchery
408b077aed3SPierre ProncheryNote: the encryption command does not include the B<-text> option because the
409b077aed3SPierre Proncherymessage being encrypted already has MIME headers.
410b077aed3SPierre Pronchery
411b077aed3SPierre ProncheryDecrypt mail:
412b077aed3SPierre Pronchery
413b077aed3SPierre Pronchery openssl smime -decrypt -in mail.msg -recip mycert.pem -inkey key.pem
414b077aed3SPierre Pronchery
415b077aed3SPierre ProncheryThe output from Netscape form signing is a PKCS#7 structure with the
416b077aed3SPierre Proncherydetached signature format. You can use this program to verify the
417b077aed3SPierre Proncherysignature by line wrapping the base64 encoded structure and surrounding
418b077aed3SPierre Proncheryit with:
419b077aed3SPierre Pronchery
420b077aed3SPierre Pronchery -----BEGIN PKCS7-----
421b077aed3SPierre Pronchery -----END PKCS7-----
422b077aed3SPierre Pronchery
423b077aed3SPierre Proncheryand using the command:
424b077aed3SPierre Pronchery
425b077aed3SPierre Pronchery openssl smime -verify -inform PEM -in signature.pem -content content.txt
426b077aed3SPierre Pronchery
427b077aed3SPierre ProncheryAlternatively you can base64 decode the signature and use:
428b077aed3SPierre Pronchery
429b077aed3SPierre Pronchery openssl smime -verify -inform DER -in signature.der -content content.txt
430b077aed3SPierre Pronchery
431b077aed3SPierre ProncheryCreate an encrypted message using 128 bit Camellia:
432b077aed3SPierre Pronchery
433b077aed3SPierre Pronchery openssl smime -encrypt -in plain.txt -camellia128 -out mail.msg cert.pem
434b077aed3SPierre Pronchery
435b077aed3SPierre ProncheryAdd a signer to an existing message:
436b077aed3SPierre Pronchery
437b077aed3SPierre Pronchery openssl smime -resign -in mail.msg -signer newsign.pem -out mail2.msg
438b077aed3SPierre Pronchery
439b077aed3SPierre Pronchery=head1 BUGS
440b077aed3SPierre Pronchery
441b077aed3SPierre ProncheryThe MIME parser isn't very clever: it seems to handle most messages that I've
442b077aed3SPierre Proncherythrown at it but it may choke on others.
443b077aed3SPierre Pronchery
444b077aed3SPierre ProncheryThe code currently will only write out the signer's certificate to a file: if
445b077aed3SPierre Proncherythe signer has a separate encryption certificate this must be manually
446b077aed3SPierre Proncheryextracted. There should be some heuristic that determines the correct
447b077aed3SPierre Proncheryencryption certificate.
448b077aed3SPierre Pronchery
449b077aed3SPierre ProncheryIdeally a database should be maintained of a certificates for each email
450b077aed3SPierre Proncheryaddress.
451b077aed3SPierre Pronchery
452b077aed3SPierre ProncheryThe code doesn't currently take note of the permitted symmetric encryption
453b077aed3SPierre Proncheryalgorithms as supplied in the SMIMECapabilities signed attribute. This means the
454b077aed3SPierre Proncheryuser has to manually include the correct encryption algorithm. It should store
455b077aed3SPierre Proncherythe list of permitted ciphers in a database and only use those.
456b077aed3SPierre Pronchery
457b077aed3SPierre ProncheryNo revocation checking is done on the signer's certificate.
458b077aed3SPierre Pronchery
459b077aed3SPierre ProncheryThe current code can only handle S/MIME v2 messages, the more complex S/MIME v3
460b077aed3SPierre Proncherystructures may cause parsing errors.
461b077aed3SPierre Pronchery
462b077aed3SPierre Pronchery=head1 SEE ALSO
463b077aed3SPierre Pronchery
464b077aed3SPierre ProncheryL<ossl_store-file(7)>
465b077aed3SPierre Pronchery
466b077aed3SPierre Pronchery=head1 HISTORY
467b077aed3SPierre Pronchery
468b077aed3SPierre ProncheryThe use of multiple B<-signer> options and the B<-resign> command were first
469b077aed3SPierre Proncheryadded in OpenSSL 1.0.0
470b077aed3SPierre Pronchery
471b077aed3SPierre ProncheryThe -no_alt_chains option was added in OpenSSL 1.1.0.
472b077aed3SPierre Pronchery
473b077aed3SPierre ProncheryThe B<-engine> option was deprecated in OpenSSL 3.0.
474b077aed3SPierre Pronchery
475b077aed3SPierre Pronchery=head1 COPYRIGHT
476b077aed3SPierre Pronchery
47744096ebdSEnji CooperCopyright 2000-2024 The OpenSSL Project Authors. All Rights Reserved.
478b077aed3SPierre Pronchery
479b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License").  You may not use
480b077aed3SPierre Proncherythis file except in compliance with the License.  You can obtain a copy
481b077aed3SPierre Proncheryin the file LICENSE in the source distribution or at
482b077aed3SPierre ProncheryL<https://www.openssl.org/source/license.html>.
483b077aed3SPierre Pronchery
484b077aed3SPierre Pronchery=cut
485