1ebfedea0SLionel Sambuc=pod 2ebfedea0SLionel Sambuc 3ebfedea0SLionel Sambuc=head1 NAME 4ebfedea0SLionel Sambuc 5ebfedea0SLionel Sambucsmime - S/MIME utility 6ebfedea0SLionel Sambuc 7ebfedea0SLionel Sambuc=head1 SYNOPSIS 8ebfedea0SLionel Sambuc 9ebfedea0SLionel SambucB<openssl> B<smime> 10ebfedea0SLionel Sambuc[B<-encrypt>] 11ebfedea0SLionel Sambuc[B<-decrypt>] 12ebfedea0SLionel Sambuc[B<-sign>] 13ebfedea0SLionel Sambuc[B<-resign>] 14ebfedea0SLionel Sambuc[B<-verify>] 15ebfedea0SLionel Sambuc[B<-pk7out>] 16ebfedea0SLionel Sambuc[B<-[cipher]>] 17ebfedea0SLionel Sambuc[B<-in file>] 18*0a6a1f1dSLionel Sambuc[B<-no_alt_chains>] 19ebfedea0SLionel Sambuc[B<-certfile file>] 20ebfedea0SLionel Sambuc[B<-signer file>] 21ebfedea0SLionel Sambuc[B<-recip file>] 22ebfedea0SLionel Sambuc[B<-inform SMIME|PEM|DER>] 23ebfedea0SLionel Sambuc[B<-passin arg>] 24ebfedea0SLionel Sambuc[B<-inkey file>] 25ebfedea0SLionel Sambuc[B<-out file>] 26ebfedea0SLionel Sambuc[B<-outform SMIME|PEM|DER>] 27ebfedea0SLionel Sambuc[B<-content file>] 28ebfedea0SLionel Sambuc[B<-to addr>] 29ebfedea0SLionel Sambuc[B<-from ad>] 30ebfedea0SLionel Sambuc[B<-subject s>] 31ebfedea0SLionel Sambuc[B<-text>] 32ebfedea0SLionel Sambuc[B<-indef>] 33ebfedea0SLionel Sambuc[B<-noindef>] 34ebfedea0SLionel Sambuc[B<-stream>] 35ebfedea0SLionel Sambuc[B<-rand file(s)>] 36ebfedea0SLionel Sambuc[B<-md digest>] 37ebfedea0SLionel Sambuc[cert.pem]... 38ebfedea0SLionel Sambuc 39ebfedea0SLionel Sambuc=head1 DESCRIPTION 40ebfedea0SLionel Sambuc 41ebfedea0SLionel SambucThe B<smime> command handles S/MIME mail. It can encrypt, decrypt, sign and 42ebfedea0SLionel Sambucverify S/MIME messages. 43ebfedea0SLionel Sambuc 44ebfedea0SLionel Sambuc=head1 COMMAND OPTIONS 45ebfedea0SLionel Sambuc 46ebfedea0SLionel SambucThere are six operation options that set the type of operation to be performed. 47ebfedea0SLionel SambucThe meaning of the other options varies according to the operation type. 48ebfedea0SLionel Sambuc 49ebfedea0SLionel Sambuc=over 4 50ebfedea0SLionel Sambuc 51ebfedea0SLionel Sambuc=item B<-encrypt> 52ebfedea0SLionel Sambuc 53ebfedea0SLionel Sambucencrypt mail for the given recipient certificates. Input file is the message 54ebfedea0SLionel Sambucto be encrypted. The output file is the encrypted mail in MIME format. 55ebfedea0SLionel Sambuc 56ebfedea0SLionel Sambuc=item B<-decrypt> 57ebfedea0SLionel Sambuc 58ebfedea0SLionel Sambucdecrypt mail using the supplied certificate and private key. Expects an 59ebfedea0SLionel Sambucencrypted mail message in MIME format for the input file. The decrypted mail 60ebfedea0SLionel Sambucis written to the output file. 61ebfedea0SLionel Sambuc 62ebfedea0SLionel Sambuc=item B<-sign> 63ebfedea0SLionel Sambuc 64ebfedea0SLionel Sambucsign mail using the supplied certificate and private key. Input file is 65ebfedea0SLionel Sambucthe message to be signed. The signed message in MIME format is written 66ebfedea0SLionel Sambucto the output file. 67ebfedea0SLionel Sambuc 68ebfedea0SLionel Sambuc=item B<-verify> 69ebfedea0SLionel Sambuc 70ebfedea0SLionel Sambucverify signed mail. Expects a signed mail message on input and outputs 71ebfedea0SLionel Sambucthe signed data. Both clear text and opaque signing is supported. 72ebfedea0SLionel Sambuc 73ebfedea0SLionel Sambuc=item B<-pk7out> 74ebfedea0SLionel Sambuc 75ebfedea0SLionel Sambuctakes an input message and writes out a PEM encoded PKCS#7 structure. 76ebfedea0SLionel Sambuc 77ebfedea0SLionel Sambuc=item B<-resign> 78ebfedea0SLionel Sambuc 79ebfedea0SLionel Sambucresign a message: take an existing message and one or more new signers. 80ebfedea0SLionel Sambuc 81ebfedea0SLionel Sambuc=item B<-in filename> 82ebfedea0SLionel Sambuc 83ebfedea0SLionel Sambucthe input message to be encrypted or signed or the MIME message to 84ebfedea0SLionel Sambucbe decrypted or verified. 85ebfedea0SLionel Sambuc 86ebfedea0SLionel Sambuc=item B<-inform SMIME|PEM|DER> 87ebfedea0SLionel Sambuc 88ebfedea0SLionel Sambucthis specifies the input format for the PKCS#7 structure. The default 89ebfedea0SLionel Sambucis B<SMIME> which reads an S/MIME format message. B<PEM> and B<DER> 90ebfedea0SLionel Sambucformat change this to expect PEM and DER format PKCS#7 structures 91ebfedea0SLionel Sambucinstead. This currently only affects the input format of the PKCS#7 92ebfedea0SLionel Sambucstructure, if no PKCS#7 structure is being input (for example with 93ebfedea0SLionel SambucB<-encrypt> or B<-sign>) this option has no effect. 94ebfedea0SLionel Sambuc 95ebfedea0SLionel Sambuc=item B<-out filename> 96ebfedea0SLionel Sambuc 97ebfedea0SLionel Sambucthe message text that has been decrypted or verified or the output MIME 98ebfedea0SLionel Sambucformat message that has been signed or verified. 99ebfedea0SLionel Sambuc 100ebfedea0SLionel Sambuc=item B<-outform SMIME|PEM|DER> 101ebfedea0SLionel Sambuc 102ebfedea0SLionel Sambucthis specifies the output format for the PKCS#7 structure. The default 103ebfedea0SLionel Sambucis B<SMIME> which write an S/MIME format message. B<PEM> and B<DER> 104ebfedea0SLionel Sambucformat change this to write PEM and DER format PKCS#7 structures 105ebfedea0SLionel Sambucinstead. This currently only affects the output format of the PKCS#7 106ebfedea0SLionel Sambucstructure, if no PKCS#7 structure is being output (for example with 107ebfedea0SLionel SambucB<-verify> or B<-decrypt>) this option has no effect. 108ebfedea0SLionel Sambuc 109ebfedea0SLionel Sambuc=item B<-stream -indef -noindef> 110ebfedea0SLionel Sambuc 111ebfedea0SLionel Sambucthe B<-stream> and B<-indef> options are equivalent and enable streaming I/O 112ebfedea0SLionel Sambucfor encoding operations. This permits single pass processing of data without 113ebfedea0SLionel Sambucthe need to hold the entire contents in memory, potentially supporting very 114ebfedea0SLionel Sambuclarge files. Streaming is automatically set for S/MIME signing with detached 115ebfedea0SLionel Sambucdata if the output format is B<SMIME> it is currently off by default for all 116ebfedea0SLionel Sambucother operations. 117ebfedea0SLionel Sambuc 118ebfedea0SLionel Sambuc=item B<-noindef> 119ebfedea0SLionel Sambuc 120ebfedea0SLionel Sambucdisable streaming I/O where it would produce and indefinite length constructed 121ebfedea0SLionel Sambucencoding. This option currently has no effect. In future streaming will be 122ebfedea0SLionel Sambucenabled by default on all relevant operations and this option will disable it. 123ebfedea0SLionel Sambuc 124ebfedea0SLionel Sambuc=item B<-content filename> 125ebfedea0SLionel Sambuc 126ebfedea0SLionel SambucThis specifies a file containing the detached content, this is only 127ebfedea0SLionel Sambucuseful with the B<-verify> command. This is only usable if the PKCS#7 128ebfedea0SLionel Sambucstructure is using the detached signature form where the content is 129ebfedea0SLionel Sambucnot included. This option will override any content if the input format 130ebfedea0SLionel Sambucis S/MIME and it uses the multipart/signed MIME content type. 131ebfedea0SLionel Sambuc 132ebfedea0SLionel Sambuc=item B<-text> 133ebfedea0SLionel Sambuc 134ebfedea0SLionel Sambucthis option adds plain text (text/plain) MIME headers to the supplied 135ebfedea0SLionel Sambucmessage if encrypting or signing. If decrypting or verifying it strips 136ebfedea0SLionel Sambucoff text headers: if the decrypted or verified message is not of MIME 137ebfedea0SLionel Sambuctype text/plain then an error occurs. 138ebfedea0SLionel Sambuc 139ebfedea0SLionel Sambuc=item B<-CAfile file> 140ebfedea0SLionel Sambuc 141ebfedea0SLionel Sambuca file containing trusted CA certificates, only used with B<-verify>. 142ebfedea0SLionel Sambuc 143ebfedea0SLionel Sambuc=item B<-CApath dir> 144ebfedea0SLionel Sambuc 145ebfedea0SLionel Sambuca directory containing trusted CA certificates, only used with 146ebfedea0SLionel SambucB<-verify>. This directory must be a standard certificate directory: that 147ebfedea0SLionel Sambucis a hash of each subject name (using B<x509 -hash>) should be linked 148ebfedea0SLionel Sambucto each certificate. 149ebfedea0SLionel Sambuc 150ebfedea0SLionel Sambuc=item B<-md digest> 151ebfedea0SLionel Sambuc 152ebfedea0SLionel Sambucdigest algorithm to use when signing or resigning. If not present then the 153ebfedea0SLionel Sambucdefault digest algorithm for the signing key will be used (usually SHA1). 154ebfedea0SLionel Sambuc 155ebfedea0SLionel Sambuc=item B<-[cipher]> 156ebfedea0SLionel Sambuc 157ebfedea0SLionel Sambucthe encryption algorithm to use. For example DES (56 bits) - B<-des>, 158ebfedea0SLionel Sambuctriple DES (168 bits) - B<-des3>, 159ebfedea0SLionel SambucEVP_get_cipherbyname() function) can also be used preceded by a dash, for 160ebfedea0SLionel Sambucexample B<-aes_128_cbc>. See L<B<enc>|enc(1)> for list of ciphers 161ebfedea0SLionel Sambucsupported by your version of OpenSSL. 162ebfedea0SLionel Sambuc 163*0a6a1f1dSLionel SambucIf not specified triple DES is used. Only used with B<-encrypt>. 164ebfedea0SLionel Sambuc 165ebfedea0SLionel Sambuc=item B<-nointern> 166ebfedea0SLionel Sambuc 167ebfedea0SLionel Sambucwhen verifying a message normally certificates (if any) included in 168ebfedea0SLionel Sambucthe message are searched for the signing certificate. With this option 169ebfedea0SLionel Sambuconly the certificates specified in the B<-certfile> option are used. 170ebfedea0SLionel SambucThe supplied certificates can still be used as untrusted CAs however. 171ebfedea0SLionel Sambuc 172ebfedea0SLionel Sambuc=item B<-noverify> 173ebfedea0SLionel Sambuc 174ebfedea0SLionel Sambucdo not verify the signers certificate of a signed message. 175ebfedea0SLionel Sambuc 176ebfedea0SLionel Sambuc=item B<-nochain> 177ebfedea0SLionel Sambuc 178ebfedea0SLionel Sambucdo not do chain verification of signers certificates: that is don't 179ebfedea0SLionel Sambucuse the certificates in the signed message as untrusted CAs. 180ebfedea0SLionel Sambuc 181ebfedea0SLionel Sambuc=item B<-nosigs> 182ebfedea0SLionel Sambuc 183ebfedea0SLionel Sambucdon't try to verify the signatures on the message. 184ebfedea0SLionel Sambuc 185ebfedea0SLionel Sambuc=item B<-nocerts> 186ebfedea0SLionel Sambuc 187ebfedea0SLionel Sambucwhen signing a message the signer's certificate is normally included 188ebfedea0SLionel Sambucwith this option it is excluded. This will reduce the size of the 189ebfedea0SLionel Sambucsigned message but the verifier must have a copy of the signers certificate 190ebfedea0SLionel Sambucavailable locally (passed using the B<-certfile> option for example). 191ebfedea0SLionel Sambuc 192ebfedea0SLionel Sambuc=item B<-noattr> 193ebfedea0SLionel Sambuc 194ebfedea0SLionel Sambucnormally when a message is signed a set of attributes are included which 195ebfedea0SLionel Sambucinclude the signing time and supported symmetric algorithms. With this 196ebfedea0SLionel Sambucoption they are not included. 197ebfedea0SLionel Sambuc 198ebfedea0SLionel Sambuc=item B<-binary> 199ebfedea0SLionel Sambuc 200ebfedea0SLionel Sambucnormally the input message is converted to "canonical" format which is 201ebfedea0SLionel Sambuceffectively using CR and LF as end of line: as required by the S/MIME 202ebfedea0SLionel Sambucspecification. When this option is present no translation occurs. This 203ebfedea0SLionel Sambucis useful when handling binary data which may not be in MIME format. 204ebfedea0SLionel Sambuc 205ebfedea0SLionel Sambuc=item B<-nodetach> 206ebfedea0SLionel Sambuc 207ebfedea0SLionel Sambucwhen signing a message use opaque signing: this form is more resistant 208ebfedea0SLionel Sambucto translation by mail relays but it cannot be read by mail agents that 209ebfedea0SLionel Sambucdo not support S/MIME. Without this option cleartext signing with 210ebfedea0SLionel Sambucthe MIME type multipart/signed is used. 211ebfedea0SLionel Sambuc 212ebfedea0SLionel Sambuc=item B<-certfile file> 213ebfedea0SLionel Sambuc 214ebfedea0SLionel Sambucallows additional certificates to be specified. When signing these will 215ebfedea0SLionel Sambucbe included with the message. When verifying these will be searched for 216ebfedea0SLionel Sambucthe signers certificates. The certificates should be in PEM format. 217ebfedea0SLionel Sambuc 218ebfedea0SLionel Sambuc=item B<-signer file> 219ebfedea0SLionel Sambuc 220ebfedea0SLionel Sambuca signing certificate when signing or resigning a message, this option can be 221ebfedea0SLionel Sambucused multiple times if more than one signer is required. If a message is being 222ebfedea0SLionel Sambucverified then the signers certificates will be written to this file if the 223ebfedea0SLionel Sambucverification was successful. 224ebfedea0SLionel Sambuc 225ebfedea0SLionel Sambuc=item B<-recip file> 226ebfedea0SLionel Sambuc 227ebfedea0SLionel Sambucthe recipients certificate when decrypting a message. This certificate 228ebfedea0SLionel Sambucmust match one of the recipients of the message or an error occurs. 229ebfedea0SLionel Sambuc 230ebfedea0SLionel Sambuc=item B<-inkey file> 231ebfedea0SLionel Sambuc 232ebfedea0SLionel Sambucthe private key to use when signing or decrypting. This must match the 233ebfedea0SLionel Sambuccorresponding certificate. If this option is not specified then the 234ebfedea0SLionel Sambucprivate key must be included in the certificate file specified with 235ebfedea0SLionel Sambucthe B<-recip> or B<-signer> file. When signing this option can be used 236ebfedea0SLionel Sambucmultiple times to specify successive keys. 237ebfedea0SLionel Sambuc 238ebfedea0SLionel Sambuc=item B<-passin arg> 239ebfedea0SLionel Sambuc 240ebfedea0SLionel Sambucthe private key password source. For more information about the format of B<arg> 241ebfedea0SLionel Sambucsee the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>. 242ebfedea0SLionel Sambuc 243ebfedea0SLionel Sambuc=item B<-rand file(s)> 244ebfedea0SLionel Sambuc 245ebfedea0SLionel Sambuca file or files containing random data used to seed the random number 246ebfedea0SLionel Sambucgenerator, or an EGD socket (see L<RAND_egd(3)|RAND_egd(3)>). 247ebfedea0SLionel SambucMultiple files can be specified separated by a OS-dependent character. 248ebfedea0SLionel SambucThe separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for 249ebfedea0SLionel Sambucall others. 250ebfedea0SLionel Sambuc 251ebfedea0SLionel Sambuc=item B<cert.pem...> 252ebfedea0SLionel Sambuc 253ebfedea0SLionel Sambucone or more certificates of message recipients: used when encrypting 254ebfedea0SLionel Sambuca message. 255ebfedea0SLionel Sambuc 256ebfedea0SLionel Sambuc=item B<-to, -from, -subject> 257ebfedea0SLionel Sambuc 258ebfedea0SLionel Sambucthe relevant mail headers. These are included outside the signed 259ebfedea0SLionel Sambucportion of a message so they may be included manually. If signing 260ebfedea0SLionel Sambucthen many S/MIME mail clients check the signers certificate's email 261ebfedea0SLionel Sambucaddress matches that specified in the From: address. 262ebfedea0SLionel Sambuc 263*0a6a1f1dSLionel Sambuc=item B<-purpose, -ignore_critical, -issuer_checks, -crl_check, -crl_check_all, -policy_check, -extended_crl, -x509_strict, -policy -check_ss_sig -no_alt_chains> 264ebfedea0SLionel Sambuc 265ebfedea0SLionel SambucSet various options of certificate chain verification. See 266ebfedea0SLionel SambucL<B<verify>|verify(1)> manual page for details. 267ebfedea0SLionel Sambuc 268ebfedea0SLionel Sambuc=back 269ebfedea0SLionel Sambuc 270ebfedea0SLionel Sambuc=head1 NOTES 271ebfedea0SLionel Sambuc 272ebfedea0SLionel SambucThe MIME message must be sent without any blank lines between the 273ebfedea0SLionel Sambucheaders and the output. Some mail programs will automatically add 274ebfedea0SLionel Sambuca blank line. Piping the mail directly to sendmail is one way to 275ebfedea0SLionel Sambucachieve the correct format. 276ebfedea0SLionel Sambuc 277ebfedea0SLionel SambucThe supplied message to be signed or encrypted must include the 278ebfedea0SLionel Sambucnecessary MIME headers or many S/MIME clients wont display it 279ebfedea0SLionel Sambucproperly (if at all). You can use the B<-text> option to automatically 280ebfedea0SLionel Sambucadd plain text headers. 281ebfedea0SLionel Sambuc 282ebfedea0SLionel SambucA "signed and encrypted" message is one where a signed message is 283ebfedea0SLionel Sambucthen encrypted. This can be produced by encrypting an already signed 284ebfedea0SLionel Sambucmessage: see the examples section. 285ebfedea0SLionel Sambuc 286ebfedea0SLionel SambucThis version of the program only allows one signer per message but it 287ebfedea0SLionel Sambucwill verify multiple signers on received messages. Some S/MIME clients 288ebfedea0SLionel Sambucchoke if a message contains multiple signers. It is possible to sign 289ebfedea0SLionel Sambucmessages "in parallel" by signing an already signed message. 290ebfedea0SLionel Sambuc 291ebfedea0SLionel SambucThe options B<-encrypt> and B<-decrypt> reflect common usage in S/MIME 292ebfedea0SLionel Sambucclients. Strictly speaking these process PKCS#7 enveloped data: PKCS#7 293ebfedea0SLionel Sambucencrypted data is used for other purposes. 294ebfedea0SLionel Sambuc 295ebfedea0SLionel SambucThe B<-resign> option uses an existing message digest when adding a new 296ebfedea0SLionel Sambucsigner. This means that attributes must be present in at least one existing 297ebfedea0SLionel Sambucsigner using the same message digest or this operation will fail. 298ebfedea0SLionel Sambuc 299ebfedea0SLionel SambucThe B<-stream> and B<-indef> options enable experimental streaming I/O support. 300ebfedea0SLionel SambucAs a result the encoding is BER using indefinite length constructed encoding 301ebfedea0SLionel Sambucand no longer DER. Streaming is supported for the B<-encrypt> operation and the 302ebfedea0SLionel SambucB<-sign> operation if the content is not detached. 303ebfedea0SLionel Sambuc 304ebfedea0SLionel SambucStreaming is always used for the B<-sign> operation with detached data but 305ebfedea0SLionel Sambucsince the content is no longer part of the PKCS#7 structure the encoding 306ebfedea0SLionel Sambucremains DER. 307ebfedea0SLionel Sambuc 308ebfedea0SLionel Sambuc=head1 EXIT CODES 309ebfedea0SLionel Sambuc 310ebfedea0SLionel Sambuc=over 4 311ebfedea0SLionel Sambuc 312*0a6a1f1dSLionel Sambuc=item Z<>0 313ebfedea0SLionel Sambuc 314ebfedea0SLionel Sambucthe operation was completely successfully. 315ebfedea0SLionel Sambuc 316*0a6a1f1dSLionel Sambuc=item Z<>1 317ebfedea0SLionel Sambuc 318ebfedea0SLionel Sambucan error occurred parsing the command options. 319ebfedea0SLionel Sambuc 320*0a6a1f1dSLionel Sambuc=item Z<>2 321ebfedea0SLionel Sambuc 322ebfedea0SLionel Sambucone of the input files could not be read. 323ebfedea0SLionel Sambuc 324*0a6a1f1dSLionel Sambuc=item Z<>3 325ebfedea0SLionel Sambuc 326ebfedea0SLionel Sambucan error occurred creating the PKCS#7 file or when reading the MIME 327ebfedea0SLionel Sambucmessage. 328ebfedea0SLionel Sambuc 329*0a6a1f1dSLionel Sambuc=item Z<>4 330ebfedea0SLionel Sambuc 331ebfedea0SLionel Sambucan error occurred decrypting or verifying the message. 332ebfedea0SLionel Sambuc 333*0a6a1f1dSLionel Sambuc=item Z<>5 334ebfedea0SLionel Sambuc 335ebfedea0SLionel Sambucthe message was verified correctly but an error occurred writing out 336ebfedea0SLionel Sambucthe signers certificates. 337ebfedea0SLionel Sambuc 338ebfedea0SLionel Sambuc=back 339ebfedea0SLionel Sambuc 340ebfedea0SLionel Sambuc=head1 EXAMPLES 341ebfedea0SLionel Sambuc 342ebfedea0SLionel SambucCreate a cleartext signed message: 343ebfedea0SLionel Sambuc 344ebfedea0SLionel Sambuc openssl smime -sign -in message.txt -text -out mail.msg \ 345ebfedea0SLionel Sambuc -signer mycert.pem 346ebfedea0SLionel Sambuc 347ebfedea0SLionel SambucCreate an opaque signed message: 348ebfedea0SLionel Sambuc 349ebfedea0SLionel Sambuc openssl smime -sign -in message.txt -text -out mail.msg -nodetach \ 350ebfedea0SLionel Sambuc -signer mycert.pem 351ebfedea0SLionel Sambuc 352ebfedea0SLionel SambucCreate a signed message, include some additional certificates and 353ebfedea0SLionel Sambucread the private key from another file: 354ebfedea0SLionel Sambuc 355ebfedea0SLionel Sambuc openssl smime -sign -in in.txt -text -out mail.msg \ 356ebfedea0SLionel Sambuc -signer mycert.pem -inkey mykey.pem -certfile mycerts.pem 357ebfedea0SLionel Sambuc 358ebfedea0SLionel SambucCreate a signed message with two signers: 359ebfedea0SLionel Sambuc 360ebfedea0SLionel Sambuc openssl smime -sign -in message.txt -text -out mail.msg \ 361ebfedea0SLionel Sambuc -signer mycert.pem -signer othercert.pem 362ebfedea0SLionel Sambuc 363ebfedea0SLionel SambucSend a signed message under Unix directly to sendmail, including headers: 364ebfedea0SLionel Sambuc 365ebfedea0SLionel Sambuc openssl smime -sign -in in.txt -text -signer mycert.pem \ 366ebfedea0SLionel Sambuc -from steve@openssl.org -to someone@somewhere \ 367ebfedea0SLionel Sambuc -subject "Signed message" | sendmail someone@somewhere 368ebfedea0SLionel Sambuc 369ebfedea0SLionel SambucVerify a message and extract the signer's certificate if successful: 370ebfedea0SLionel Sambuc 371ebfedea0SLionel Sambuc openssl smime -verify -in mail.msg -signer user.pem -out signedtext.txt 372ebfedea0SLionel Sambuc 373ebfedea0SLionel SambucSend encrypted mail using triple DES: 374ebfedea0SLionel Sambuc 375ebfedea0SLionel Sambuc openssl smime -encrypt -in in.txt -from steve@openssl.org \ 376ebfedea0SLionel Sambuc -to someone@somewhere -subject "Encrypted message" \ 377ebfedea0SLionel Sambuc -des3 user.pem -out mail.msg 378ebfedea0SLionel Sambuc 379ebfedea0SLionel SambucSign and encrypt mail: 380ebfedea0SLionel Sambuc 381ebfedea0SLionel Sambuc openssl smime -sign -in ml.txt -signer my.pem -text \ 382ebfedea0SLionel Sambuc | openssl smime -encrypt -out mail.msg \ 383ebfedea0SLionel Sambuc -from steve@openssl.org -to someone@somewhere \ 384ebfedea0SLionel Sambuc -subject "Signed and Encrypted message" -des3 user.pem 385ebfedea0SLionel Sambuc 386ebfedea0SLionel SambucNote: the encryption command does not include the B<-text> option because the 387ebfedea0SLionel Sambucmessage being encrypted already has MIME headers. 388ebfedea0SLionel Sambuc 389ebfedea0SLionel SambucDecrypt mail: 390ebfedea0SLionel Sambuc 391ebfedea0SLionel Sambuc openssl smime -decrypt -in mail.msg -recip mycert.pem -inkey key.pem 392ebfedea0SLionel Sambuc 393ebfedea0SLionel SambucThe output from Netscape form signing is a PKCS#7 structure with the 394ebfedea0SLionel Sambucdetached signature format. You can use this program to verify the 395ebfedea0SLionel Sambucsignature by line wrapping the base64 encoded structure and surrounding 396ebfedea0SLionel Sambucit with: 397ebfedea0SLionel Sambuc 398ebfedea0SLionel Sambuc -----BEGIN PKCS7----- 399ebfedea0SLionel Sambuc -----END PKCS7----- 400ebfedea0SLionel Sambuc 401ebfedea0SLionel Sambucand using the command: 402ebfedea0SLionel Sambuc 403ebfedea0SLionel Sambuc openssl smime -verify -inform PEM -in signature.pem -content content.txt 404ebfedea0SLionel Sambuc 405ebfedea0SLionel SambucAlternatively you can base64 decode the signature and use: 406ebfedea0SLionel Sambuc 407ebfedea0SLionel Sambuc openssl smime -verify -inform DER -in signature.der -content content.txt 408ebfedea0SLionel Sambuc 409ebfedea0SLionel SambucCreate an encrypted message using 128 bit Camellia: 410ebfedea0SLionel Sambuc 411ebfedea0SLionel Sambuc openssl smime -encrypt -in plain.txt -camellia128 -out mail.msg cert.pem 412ebfedea0SLionel Sambuc 413ebfedea0SLionel SambucAdd a signer to an existing message: 414ebfedea0SLionel Sambuc 415ebfedea0SLionel Sambuc openssl smime -resign -in mail.msg -signer newsign.pem -out mail2.msg 416ebfedea0SLionel Sambuc 417ebfedea0SLionel Sambuc=head1 BUGS 418ebfedea0SLionel Sambuc 419ebfedea0SLionel SambucThe MIME parser isn't very clever: it seems to handle most messages that I've 420ebfedea0SLionel Sambucthrown at it but it may choke on others. 421ebfedea0SLionel Sambuc 422ebfedea0SLionel SambucThe code currently will only write out the signer's certificate to a file: if 423ebfedea0SLionel Sambucthe signer has a separate encryption certificate this must be manually 424ebfedea0SLionel Sambucextracted. There should be some heuristic that determines the correct 425ebfedea0SLionel Sambucencryption certificate. 426ebfedea0SLionel Sambuc 427ebfedea0SLionel SambucIdeally a database should be maintained of a certificates for each email 428ebfedea0SLionel Sambucaddress. 429ebfedea0SLionel Sambuc 430ebfedea0SLionel SambucThe code doesn't currently take note of the permitted symmetric encryption 431ebfedea0SLionel Sambucalgorithms as supplied in the SMIMECapabilities signed attribute. This means the 432ebfedea0SLionel Sambucuser has to manually include the correct encryption algorithm. It should store 433ebfedea0SLionel Sambucthe list of permitted ciphers in a database and only use those. 434ebfedea0SLionel Sambuc 435ebfedea0SLionel SambucNo revocation checking is done on the signer's certificate. 436ebfedea0SLionel Sambuc 437ebfedea0SLionel SambucThe current code can only handle S/MIME v2 messages, the more complex S/MIME v3 438ebfedea0SLionel Sambucstructures may cause parsing errors. 439ebfedea0SLionel Sambuc 440ebfedea0SLionel Sambuc=head1 HISTORY 441ebfedea0SLionel Sambuc 442ebfedea0SLionel SambucThe use of multiple B<-signer> options and the B<-resign> command were first 443ebfedea0SLionel Sambucadded in OpenSSL 1.0.0 444ebfedea0SLionel Sambuc 445*0a6a1f1dSLionel SambucThe -no_alt_chains options was first added to OpenSSL 1.0.1n and 1.0.2b. 446ebfedea0SLionel Sambuc 447ebfedea0SLionel Sambuc=cut 448