1*1dcdf01fSchristos=pod 2*1dcdf01fSchristos 3*1dcdf01fSchristos=head1 NAME 4*1dcdf01fSchristos 5*1dcdf01fSchristosopenssl-smime, 6*1dcdf01fSchristossmime - S/MIME utility 7*1dcdf01fSchristos 8*1dcdf01fSchristos=head1 SYNOPSIS 9*1dcdf01fSchristos 10*1dcdf01fSchristosB<openssl> B<smime> 11*1dcdf01fSchristos[B<-help>] 12*1dcdf01fSchristos[B<-encrypt>] 13*1dcdf01fSchristos[B<-decrypt>] 14*1dcdf01fSchristos[B<-sign>] 15*1dcdf01fSchristos[B<-resign>] 16*1dcdf01fSchristos[B<-verify>] 17*1dcdf01fSchristos[B<-pk7out>] 18*1dcdf01fSchristos[B<-binary>] 19*1dcdf01fSchristos[B<-crlfeol>] 20*1dcdf01fSchristos[B<-I<cipher>>] 21*1dcdf01fSchristos[B<-in file>] 22*1dcdf01fSchristos[B<-CAfile file>] 23*1dcdf01fSchristos[B<-CApath dir>] 24*1dcdf01fSchristos[B<-no-CAfile>] 25*1dcdf01fSchristos[B<-no-CApath>] 26*1dcdf01fSchristos[B<-attime timestamp>] 27*1dcdf01fSchristos[B<-check_ss_sig>] 28*1dcdf01fSchristos[B<-crl_check>] 29*1dcdf01fSchristos[B<-crl_check_all>] 30*1dcdf01fSchristos[B<-explicit_policy>] 31*1dcdf01fSchristos[B<-extended_crl>] 32*1dcdf01fSchristos[B<-ignore_critical>] 33*1dcdf01fSchristos[B<-inhibit_any>] 34*1dcdf01fSchristos[B<-inhibit_map>] 35*1dcdf01fSchristos[B<-partial_chain>] 36*1dcdf01fSchristos[B<-policy arg>] 37*1dcdf01fSchristos[B<-policy_check>] 38*1dcdf01fSchristos[B<-policy_print>] 39*1dcdf01fSchristos[B<-purpose purpose>] 40*1dcdf01fSchristos[B<-suiteB_128>] 41*1dcdf01fSchristos[B<-suiteB_128_only>] 42*1dcdf01fSchristos[B<-suiteB_192>] 43*1dcdf01fSchristos[B<-trusted_first>] 44*1dcdf01fSchristos[B<-no_alt_chains>] 45*1dcdf01fSchristos[B<-use_deltas>] 46*1dcdf01fSchristos[B<-auth_level num>] 47*1dcdf01fSchristos[B<-verify_depth num>] 48*1dcdf01fSchristos[B<-verify_email email>] 49*1dcdf01fSchristos[B<-verify_hostname hostname>] 50*1dcdf01fSchristos[B<-verify_ip ip>] 51*1dcdf01fSchristos[B<-verify_name name>] 52*1dcdf01fSchristos[B<-x509_strict>] 53*1dcdf01fSchristos[B<-certfile file>] 54*1dcdf01fSchristos[B<-signer file>] 55*1dcdf01fSchristos[B<-recip file>] 56*1dcdf01fSchristos[B<-inform SMIME|PEM|DER>] 57*1dcdf01fSchristos[B<-passin arg>] 58*1dcdf01fSchristos[B<-inkey file_or_id>] 59*1dcdf01fSchristos[B<-out file>] 60*1dcdf01fSchristos[B<-outform SMIME|PEM|DER>] 61*1dcdf01fSchristos[B<-content file>] 62*1dcdf01fSchristos[B<-to addr>] 63*1dcdf01fSchristos[B<-from ad>] 64*1dcdf01fSchristos[B<-subject s>] 65*1dcdf01fSchristos[B<-text>] 66*1dcdf01fSchristos[B<-indef>] 67*1dcdf01fSchristos[B<-noindef>] 68*1dcdf01fSchristos[B<-stream>] 69*1dcdf01fSchristos[B<-rand file...>] 70*1dcdf01fSchristos[B<-writerand file>] 71*1dcdf01fSchristos[B<-md digest>] 72*1dcdf01fSchristos[cert.pem]... 73*1dcdf01fSchristos 74*1dcdf01fSchristos=head1 DESCRIPTION 75*1dcdf01fSchristos 76*1dcdf01fSchristosThe B<smime> command handles S/MIME mail. It can encrypt, decrypt, sign and 77*1dcdf01fSchristosverify S/MIME messages. 78*1dcdf01fSchristos 79*1dcdf01fSchristos=head1 OPTIONS 80*1dcdf01fSchristos 81*1dcdf01fSchristosThere are six operation options that set the type of operation to be performed. 82*1dcdf01fSchristosThe meaning of the other options varies according to the operation type. 83*1dcdf01fSchristos 84*1dcdf01fSchristos=over 4 85*1dcdf01fSchristos 86*1dcdf01fSchristos=item B<-help> 87*1dcdf01fSchristos 88*1dcdf01fSchristosPrint out a usage message. 89*1dcdf01fSchristos 90*1dcdf01fSchristos=item B<-encrypt> 91*1dcdf01fSchristos 92*1dcdf01fSchristosEncrypt mail for the given recipient certificates. Input file is the message 93*1dcdf01fSchristosto be encrypted. The output file is the encrypted mail in MIME format. 94*1dcdf01fSchristos 95*1dcdf01fSchristosNote that no revocation check is done for the recipient cert, so if that 96*1dcdf01fSchristoskey has been compromised, others may be able to decrypt the text. 97*1dcdf01fSchristos 98*1dcdf01fSchristos=item B<-decrypt> 99*1dcdf01fSchristos 100*1dcdf01fSchristosDecrypt mail using the supplied certificate and private key. Expects an 101*1dcdf01fSchristosencrypted mail message in MIME format for the input file. The decrypted mail 102*1dcdf01fSchristosis written to the output file. 103*1dcdf01fSchristos 104*1dcdf01fSchristos=item B<-sign> 105*1dcdf01fSchristos 106*1dcdf01fSchristosSign mail using the supplied certificate and private key. Input file is 107*1dcdf01fSchristosthe message to be signed. The signed message in MIME format is written 108*1dcdf01fSchristosto the output file. 109*1dcdf01fSchristos 110*1dcdf01fSchristos=item B<-verify> 111*1dcdf01fSchristos 112*1dcdf01fSchristosVerify signed mail. Expects a signed mail message on input and outputs 113*1dcdf01fSchristosthe signed data. Both clear text and opaque signing is supported. 114*1dcdf01fSchristos 115*1dcdf01fSchristos=item B<-pk7out> 116*1dcdf01fSchristos 117*1dcdf01fSchristosTakes an input message and writes out a PEM encoded PKCS#7 structure. 118*1dcdf01fSchristos 119*1dcdf01fSchristos=item B<-resign> 120*1dcdf01fSchristos 121*1dcdf01fSchristosResign a message: take an existing message and one or more new signers. 122*1dcdf01fSchristos 123*1dcdf01fSchristos=item B<-in filename> 124*1dcdf01fSchristos 125*1dcdf01fSchristosThe input message to be encrypted or signed or the MIME message to 126*1dcdf01fSchristosbe decrypted or verified. 127*1dcdf01fSchristos 128*1dcdf01fSchristos=item B<-inform SMIME|PEM|DER> 129*1dcdf01fSchristos 130*1dcdf01fSchristosThis specifies the input format for the PKCS#7 structure. The default 131*1dcdf01fSchristosis B<SMIME> which reads an S/MIME format message. B<PEM> and B<DER> 132*1dcdf01fSchristosformat change this to expect PEM and DER format PKCS#7 structures 133*1dcdf01fSchristosinstead. This currently only affects the input format of the PKCS#7 134*1dcdf01fSchristosstructure, if no PKCS#7 structure is being input (for example with 135*1dcdf01fSchristosB<-encrypt> or B<-sign>) this option has no effect. 136*1dcdf01fSchristos 137*1dcdf01fSchristos=item B<-out filename> 138*1dcdf01fSchristos 139*1dcdf01fSchristosThe message text that has been decrypted or verified or the output MIME 140*1dcdf01fSchristosformat message that has been signed or verified. 141*1dcdf01fSchristos 142*1dcdf01fSchristos=item B<-outform SMIME|PEM|DER> 143*1dcdf01fSchristos 144*1dcdf01fSchristosThis specifies the output format for the PKCS#7 structure. The default 145*1dcdf01fSchristosis B<SMIME> which write an S/MIME format message. B<PEM> and B<DER> 146*1dcdf01fSchristosformat change this to write PEM and DER format PKCS#7 structures 147*1dcdf01fSchristosinstead. This currently only affects the output format of the PKCS#7 148*1dcdf01fSchristosstructure, if no PKCS#7 structure is being output (for example with 149*1dcdf01fSchristosB<-verify> or B<-decrypt>) this option has no effect. 150*1dcdf01fSchristos 151*1dcdf01fSchristos=item B<-stream -indef -noindef> 152*1dcdf01fSchristos 153*1dcdf01fSchristosThe B<-stream> and B<-indef> options are equivalent and enable streaming I/O 154*1dcdf01fSchristosfor encoding operations. This permits single pass processing of data without 155*1dcdf01fSchristosthe need to hold the entire contents in memory, potentially supporting very 156*1dcdf01fSchristoslarge files. Streaming is automatically set for S/MIME signing with detached 157*1dcdf01fSchristosdata if the output format is B<SMIME> it is currently off by default for all 158*1dcdf01fSchristosother operations. 159*1dcdf01fSchristos 160*1dcdf01fSchristos=item B<-noindef> 161*1dcdf01fSchristos 162*1dcdf01fSchristosDisable streaming I/O where it would produce and indefinite length constructed 163*1dcdf01fSchristosencoding. This option currently has no effect. In future streaming will be 164*1dcdf01fSchristosenabled by default on all relevant operations and this option will disable it. 165*1dcdf01fSchristos 166*1dcdf01fSchristos=item B<-content filename> 167*1dcdf01fSchristos 168*1dcdf01fSchristosThis specifies a file containing the detached content, this is only 169*1dcdf01fSchristosuseful with the B<-verify> command. This is only usable if the PKCS#7 170*1dcdf01fSchristosstructure is using the detached signature form where the content is 171*1dcdf01fSchristosnot included. This option will override any content if the input format 172*1dcdf01fSchristosis S/MIME and it uses the multipart/signed MIME content type. 173*1dcdf01fSchristos 174*1dcdf01fSchristos=item B<-text> 175*1dcdf01fSchristos 176*1dcdf01fSchristosThis option adds plain text (text/plain) MIME headers to the supplied 177*1dcdf01fSchristosmessage if encrypting or signing. If decrypting or verifying it strips 178*1dcdf01fSchristosoff text headers: if the decrypted or verified message is not of MIME 179*1dcdf01fSchristostype text/plain then an error occurs. 180*1dcdf01fSchristos 181*1dcdf01fSchristos=item B<-CAfile file> 182*1dcdf01fSchristos 183*1dcdf01fSchristosA file containing trusted CA certificates, only used with B<-verify>. 184*1dcdf01fSchristos 185*1dcdf01fSchristos=item B<-CApath dir> 186*1dcdf01fSchristos 187*1dcdf01fSchristosA directory containing trusted CA certificates, only used with 188*1dcdf01fSchristosB<-verify>. This directory must be a standard certificate directory: that 189*1dcdf01fSchristosis a hash of each subject name (using B<x509 -hash>) should be linked 190*1dcdf01fSchristosto each certificate. 191*1dcdf01fSchristos 192*1dcdf01fSchristos=item B<-no-CAfile> 193*1dcdf01fSchristos 194*1dcdf01fSchristosDo not load the trusted CA certificates from the default file location. 195*1dcdf01fSchristos 196*1dcdf01fSchristos=item B<-no-CApath> 197*1dcdf01fSchristos 198*1dcdf01fSchristosDo not load the trusted CA certificates from the default directory location. 199*1dcdf01fSchristos 200*1dcdf01fSchristos=item B<-md digest> 201*1dcdf01fSchristos 202*1dcdf01fSchristosDigest algorithm to use when signing or resigning. If not present then the 203*1dcdf01fSchristosdefault digest algorithm for the signing key will be used (usually SHA1). 204*1dcdf01fSchristos 205*1dcdf01fSchristos=item B<-I<cipher>> 206*1dcdf01fSchristos 207*1dcdf01fSchristosThe encryption algorithm to use. For example DES (56 bits) - B<-des>, 208*1dcdf01fSchristostriple DES (168 bits) - B<-des3>, 209*1dcdf01fSchristosEVP_get_cipherbyname() function) can also be used preceded by a dash, for 210*1dcdf01fSchristosexample B<-aes-128-cbc>. See L<B<enc>|enc(1)> for list of ciphers 211*1dcdf01fSchristossupported by your version of OpenSSL. 212*1dcdf01fSchristos 213*1dcdf01fSchristosIf not specified triple DES is used. Only used with B<-encrypt>. 214*1dcdf01fSchristos 215*1dcdf01fSchristos=item B<-nointern> 216*1dcdf01fSchristos 217*1dcdf01fSchristosWhen verifying a message normally certificates (if any) included in 218*1dcdf01fSchristosthe message are searched for the signing certificate. With this option 219*1dcdf01fSchristosonly the certificates specified in the B<-certfile> option are used. 220*1dcdf01fSchristosThe supplied certificates can still be used as untrusted CAs however. 221*1dcdf01fSchristos 222*1dcdf01fSchristos=item B<-noverify> 223*1dcdf01fSchristos 224*1dcdf01fSchristosDo not verify the signers certificate of a signed message. 225*1dcdf01fSchristos 226*1dcdf01fSchristos=item B<-nochain> 227*1dcdf01fSchristos 228*1dcdf01fSchristosDo not do chain verification of signers certificates: that is don't 229*1dcdf01fSchristosuse the certificates in the signed message as untrusted CAs. 230*1dcdf01fSchristos 231*1dcdf01fSchristos=item B<-nosigs> 232*1dcdf01fSchristos 233*1dcdf01fSchristosDon't try to verify the signatures on the message. 234*1dcdf01fSchristos 235*1dcdf01fSchristos=item B<-nocerts> 236*1dcdf01fSchristos 237*1dcdf01fSchristosWhen signing a message the signer's certificate is normally included 238*1dcdf01fSchristoswith this option it is excluded. This will reduce the size of the 239*1dcdf01fSchristossigned message but the verifier must have a copy of the signers certificate 240*1dcdf01fSchristosavailable locally (passed using the B<-certfile> option for example). 241*1dcdf01fSchristos 242*1dcdf01fSchristos=item B<-noattr> 243*1dcdf01fSchristos 244*1dcdf01fSchristosNormally when a message is signed a set of attributes are included which 245*1dcdf01fSchristosinclude the signing time and supported symmetric algorithms. With this 246*1dcdf01fSchristosoption they are not included. 247*1dcdf01fSchristos 248*1dcdf01fSchristos=item B<-binary> 249*1dcdf01fSchristos 250*1dcdf01fSchristosNormally the input message is converted to "canonical" format which is 251*1dcdf01fSchristoseffectively using CR and LF as end of line: as required by the S/MIME 252*1dcdf01fSchristosspecification. When this option is present no translation occurs. This 253*1dcdf01fSchristosis useful when handling binary data which may not be in MIME format. 254*1dcdf01fSchristos 255*1dcdf01fSchristos=item B<-crlfeol> 256*1dcdf01fSchristos 257*1dcdf01fSchristosNormally the output file uses a single B<LF> as end of line. When this 258*1dcdf01fSchristosoption is present B<CRLF> is used instead. 259*1dcdf01fSchristos 260*1dcdf01fSchristos=item B<-nodetach> 261*1dcdf01fSchristos 262*1dcdf01fSchristosWhen signing a message use opaque signing: this form is more resistant 263*1dcdf01fSchristosto translation by mail relays but it cannot be read by mail agents that 264*1dcdf01fSchristosdo not support S/MIME. Without this option cleartext signing with 265*1dcdf01fSchristosthe MIME type multipart/signed is used. 266*1dcdf01fSchristos 267*1dcdf01fSchristos=item B<-certfile file> 268*1dcdf01fSchristos 269*1dcdf01fSchristosAllows additional certificates to be specified. When signing these will 270*1dcdf01fSchristosbe included with the message. When verifying these will be searched for 271*1dcdf01fSchristosthe signers certificates. The certificates should be in PEM format. 272*1dcdf01fSchristos 273*1dcdf01fSchristos=item B<-signer file> 274*1dcdf01fSchristos 275*1dcdf01fSchristosA signing certificate when signing or resigning a message, this option can be 276*1dcdf01fSchristosused multiple times if more than one signer is required. If a message is being 277*1dcdf01fSchristosverified then the signers certificates will be written to this file if the 278*1dcdf01fSchristosverification was successful. 279*1dcdf01fSchristos 280*1dcdf01fSchristos=item B<-recip file> 281*1dcdf01fSchristos 282*1dcdf01fSchristosThe recipients certificate when decrypting a message. This certificate 283*1dcdf01fSchristosmust match one of the recipients of the message or an error occurs. 284*1dcdf01fSchristos 285*1dcdf01fSchristos=item B<-inkey file_or_id> 286*1dcdf01fSchristos 287*1dcdf01fSchristosThe private key to use when signing or decrypting. This must match the 288*1dcdf01fSchristoscorresponding certificate. If this option is not specified then the 289*1dcdf01fSchristosprivate key must be included in the certificate file specified with 290*1dcdf01fSchristosthe B<-recip> or B<-signer> file. When signing this option can be used 291*1dcdf01fSchristosmultiple times to specify successive keys. 292*1dcdf01fSchristosIf no engine is used, the argument is taken as a file; if an engine is 293*1dcdf01fSchristosspecified, the argument is given to the engine as a key identifier. 294*1dcdf01fSchristos 295*1dcdf01fSchristos=item B<-passin arg> 296*1dcdf01fSchristos 297*1dcdf01fSchristosThe private key password source. For more information about the format of B<arg> 298*1dcdf01fSchristossee L<openssl(1)/Pass Phrase Options>. 299*1dcdf01fSchristos 300*1dcdf01fSchristos=item B<-rand file...> 301*1dcdf01fSchristos 302*1dcdf01fSchristosA file or files containing random data used to seed the random number 303*1dcdf01fSchristosgenerator. 304*1dcdf01fSchristosMultiple files can be specified separated by an OS-dependent character. 305*1dcdf01fSchristosThe separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for 306*1dcdf01fSchristosall others. 307*1dcdf01fSchristos 308*1dcdf01fSchristos=item [B<-writerand file>] 309*1dcdf01fSchristos 310*1dcdf01fSchristosWrites random data to the specified I<file> upon exit. 311*1dcdf01fSchristosThis can be used with a subsequent B<-rand> flag. 312*1dcdf01fSchristos 313*1dcdf01fSchristos=item B<cert.pem...> 314*1dcdf01fSchristos 315*1dcdf01fSchristosOne or more certificates of message recipients: used when encrypting 316*1dcdf01fSchristosa message. 317*1dcdf01fSchristos 318*1dcdf01fSchristos=item B<-to, -from, -subject> 319*1dcdf01fSchristos 320*1dcdf01fSchristosThe relevant mail headers. These are included outside the signed 321*1dcdf01fSchristosportion of a message so they may be included manually. If signing 322*1dcdf01fSchristosthen many S/MIME mail clients check the signers certificate's email 323*1dcdf01fSchristosaddress matches that specified in the From: address. 324*1dcdf01fSchristos 325*1dcdf01fSchristos=item B<-attime>, B<-check_ss_sig>, B<-crl_check>, B<-crl_check_all>, 326*1dcdf01fSchristosB<-explicit_policy>, B<-extended_crl>, B<-ignore_critical>, B<-inhibit_any>, 327*1dcdf01fSchristosB<-inhibit_map>, B<-no_alt_chains>, B<-partial_chain>, B<-policy>, 328*1dcdf01fSchristosB<-policy_check>, B<-policy_print>, B<-purpose>, B<-suiteB_128>, 329*1dcdf01fSchristosB<-suiteB_128_only>, B<-suiteB_192>, B<-trusted_first>, B<-use_deltas>, 330*1dcdf01fSchristosB<-auth_level>, B<-verify_depth>, B<-verify_email>, B<-verify_hostname>, 331*1dcdf01fSchristosB<-verify_ip>, B<-verify_name>, B<-x509_strict> 332*1dcdf01fSchristos 333*1dcdf01fSchristosSet various options of certificate chain verification. See 334*1dcdf01fSchristosL<verify(1)> manual page for details. 335*1dcdf01fSchristos 336*1dcdf01fSchristos=back 337*1dcdf01fSchristos 338*1dcdf01fSchristos=head1 NOTES 339*1dcdf01fSchristos 340*1dcdf01fSchristosThe MIME message must be sent without any blank lines between the 341*1dcdf01fSchristosheaders and the output. Some mail programs will automatically add 342*1dcdf01fSchristosa blank line. Piping the mail directly to sendmail is one way to 343*1dcdf01fSchristosachieve the correct format. 344*1dcdf01fSchristos 345*1dcdf01fSchristosThe supplied message to be signed or encrypted must include the 346*1dcdf01fSchristosnecessary MIME headers or many S/MIME clients won't display it 347*1dcdf01fSchristosproperly (if at all). You can use the B<-text> option to automatically 348*1dcdf01fSchristosadd plain text headers. 349*1dcdf01fSchristos 350*1dcdf01fSchristosA "signed and encrypted" message is one where a signed message is 351*1dcdf01fSchristosthen encrypted. This can be produced by encrypting an already signed 352*1dcdf01fSchristosmessage: see the examples section. 353*1dcdf01fSchristos 354*1dcdf01fSchristosThis version of the program only allows one signer per message but it 355*1dcdf01fSchristoswill verify multiple signers on received messages. Some S/MIME clients 356*1dcdf01fSchristoschoke if a message contains multiple signers. It is possible to sign 357*1dcdf01fSchristosmessages "in parallel" by signing an already signed message. 358*1dcdf01fSchristos 359*1dcdf01fSchristosThe options B<-encrypt> and B<-decrypt> reflect common usage in S/MIME 360*1dcdf01fSchristosclients. Strictly speaking these process PKCS#7 enveloped data: PKCS#7 361*1dcdf01fSchristosencrypted data is used for other purposes. 362*1dcdf01fSchristos 363*1dcdf01fSchristosThe B<-resign> option uses an existing message digest when adding a new 364*1dcdf01fSchristossigner. This means that attributes must be present in at least one existing 365*1dcdf01fSchristossigner using the same message digest or this operation will fail. 366*1dcdf01fSchristos 367*1dcdf01fSchristosThe B<-stream> and B<-indef> options enable streaming I/O support. 368*1dcdf01fSchristosAs a result the encoding is BER using indefinite length constructed encoding 369*1dcdf01fSchristosand no longer DER. Streaming is supported for the B<-encrypt> operation and the 370*1dcdf01fSchristosB<-sign> operation if the content is not detached. 371*1dcdf01fSchristos 372*1dcdf01fSchristosStreaming is always used for the B<-sign> operation with detached data but 373*1dcdf01fSchristossince the content is no longer part of the PKCS#7 structure the encoding 374*1dcdf01fSchristosremains DER. 375*1dcdf01fSchristos 376*1dcdf01fSchristos=head1 EXIT CODES 377*1dcdf01fSchristos 378*1dcdf01fSchristos=over 4 379*1dcdf01fSchristos 380*1dcdf01fSchristos=item Z<>0 381*1dcdf01fSchristos 382*1dcdf01fSchristosThe operation was completely successfully. 383*1dcdf01fSchristos 384*1dcdf01fSchristos=item Z<>1 385*1dcdf01fSchristos 386*1dcdf01fSchristosAn error occurred parsing the command options. 387*1dcdf01fSchristos 388*1dcdf01fSchristos=item Z<>2 389*1dcdf01fSchristos 390*1dcdf01fSchristosOne of the input files could not be read. 391*1dcdf01fSchristos 392*1dcdf01fSchristos=item Z<>3 393*1dcdf01fSchristos 394*1dcdf01fSchristosAn error occurred creating the PKCS#7 file or when reading the MIME 395*1dcdf01fSchristosmessage. 396*1dcdf01fSchristos 397*1dcdf01fSchristos=item Z<>4 398*1dcdf01fSchristos 399*1dcdf01fSchristosAn error occurred decrypting or verifying the message. 400*1dcdf01fSchristos 401*1dcdf01fSchristos=item Z<>5 402*1dcdf01fSchristos 403*1dcdf01fSchristosThe message was verified correctly but an error occurred writing out 404*1dcdf01fSchristosthe signers certificates. 405*1dcdf01fSchristos 406*1dcdf01fSchristos=back 407*1dcdf01fSchristos 408*1dcdf01fSchristos=head1 EXAMPLES 409*1dcdf01fSchristos 410*1dcdf01fSchristosCreate a cleartext signed message: 411*1dcdf01fSchristos 412*1dcdf01fSchristos openssl smime -sign -in message.txt -text -out mail.msg \ 413*1dcdf01fSchristos -signer mycert.pem 414*1dcdf01fSchristos 415*1dcdf01fSchristosCreate an opaque signed message: 416*1dcdf01fSchristos 417*1dcdf01fSchristos openssl smime -sign -in message.txt -text -out mail.msg -nodetach \ 418*1dcdf01fSchristos -signer mycert.pem 419*1dcdf01fSchristos 420*1dcdf01fSchristosCreate a signed message, include some additional certificates and 421*1dcdf01fSchristosread the private key from another file: 422*1dcdf01fSchristos 423*1dcdf01fSchristos openssl smime -sign -in in.txt -text -out mail.msg \ 424*1dcdf01fSchristos -signer mycert.pem -inkey mykey.pem -certfile mycerts.pem 425*1dcdf01fSchristos 426*1dcdf01fSchristosCreate a signed message with two signers: 427*1dcdf01fSchristos 428*1dcdf01fSchristos openssl smime -sign -in message.txt -text -out mail.msg \ 429*1dcdf01fSchristos -signer mycert.pem -signer othercert.pem 430*1dcdf01fSchristos 431*1dcdf01fSchristosSend a signed message under Unix directly to sendmail, including headers: 432*1dcdf01fSchristos 433*1dcdf01fSchristos openssl smime -sign -in in.txt -text -signer mycert.pem \ 434*1dcdf01fSchristos -from steve@openssl.org -to someone@somewhere \ 435*1dcdf01fSchristos -subject "Signed message" | sendmail someone@somewhere 436*1dcdf01fSchristos 437*1dcdf01fSchristosVerify a message and extract the signer's certificate if successful: 438*1dcdf01fSchristos 439*1dcdf01fSchristos openssl smime -verify -in mail.msg -signer user.pem -out signedtext.txt 440*1dcdf01fSchristos 441*1dcdf01fSchristosSend encrypted mail using triple DES: 442*1dcdf01fSchristos 443*1dcdf01fSchristos openssl smime -encrypt -in in.txt -from steve@openssl.org \ 444*1dcdf01fSchristos -to someone@somewhere -subject "Encrypted message" \ 445*1dcdf01fSchristos -des3 user.pem -out mail.msg 446*1dcdf01fSchristos 447*1dcdf01fSchristosSign and encrypt mail: 448*1dcdf01fSchristos 449*1dcdf01fSchristos openssl smime -sign -in ml.txt -signer my.pem -text \ 450*1dcdf01fSchristos | openssl smime -encrypt -out mail.msg \ 451*1dcdf01fSchristos -from steve@openssl.org -to someone@somewhere \ 452*1dcdf01fSchristos -subject "Signed and Encrypted message" -des3 user.pem 453*1dcdf01fSchristos 454*1dcdf01fSchristosNote: the encryption command does not include the B<-text> option because the 455*1dcdf01fSchristosmessage being encrypted already has MIME headers. 456*1dcdf01fSchristos 457*1dcdf01fSchristosDecrypt mail: 458*1dcdf01fSchristos 459*1dcdf01fSchristos openssl smime -decrypt -in mail.msg -recip mycert.pem -inkey key.pem 460*1dcdf01fSchristos 461*1dcdf01fSchristosThe output from Netscape form signing is a PKCS#7 structure with the 462*1dcdf01fSchristosdetached signature format. You can use this program to verify the 463*1dcdf01fSchristossignature by line wrapping the base64 encoded structure and surrounding 464*1dcdf01fSchristosit with: 465*1dcdf01fSchristos 466*1dcdf01fSchristos -----BEGIN PKCS7----- 467*1dcdf01fSchristos -----END PKCS7----- 468*1dcdf01fSchristos 469*1dcdf01fSchristosand using the command: 470*1dcdf01fSchristos 471*1dcdf01fSchristos openssl smime -verify -inform PEM -in signature.pem -content content.txt 472*1dcdf01fSchristos 473*1dcdf01fSchristosAlternatively you can base64 decode the signature and use: 474*1dcdf01fSchristos 475*1dcdf01fSchristos openssl smime -verify -inform DER -in signature.der -content content.txt 476*1dcdf01fSchristos 477*1dcdf01fSchristosCreate an encrypted message using 128 bit Camellia: 478*1dcdf01fSchristos 479*1dcdf01fSchristos openssl smime -encrypt -in plain.txt -camellia128 -out mail.msg cert.pem 480*1dcdf01fSchristos 481*1dcdf01fSchristosAdd a signer to an existing message: 482*1dcdf01fSchristos 483*1dcdf01fSchristos openssl smime -resign -in mail.msg -signer newsign.pem -out mail2.msg 484*1dcdf01fSchristos 485*1dcdf01fSchristos=head1 BUGS 486*1dcdf01fSchristos 487*1dcdf01fSchristosThe MIME parser isn't very clever: it seems to handle most messages that I've 488*1dcdf01fSchristosthrown at it but it may choke on others. 489*1dcdf01fSchristos 490*1dcdf01fSchristosThe code currently will only write out the signer's certificate to a file: if 491*1dcdf01fSchristosthe signer has a separate encryption certificate this must be manually 492*1dcdf01fSchristosextracted. There should be some heuristic that determines the correct 493*1dcdf01fSchristosencryption certificate. 494*1dcdf01fSchristos 495*1dcdf01fSchristosIdeally a database should be maintained of a certificates for each email 496*1dcdf01fSchristosaddress. 497*1dcdf01fSchristos 498*1dcdf01fSchristosThe code doesn't currently take note of the permitted symmetric encryption 499*1dcdf01fSchristosalgorithms as supplied in the SMIMECapabilities signed attribute. This means the 500*1dcdf01fSchristosuser has to manually include the correct encryption algorithm. It should store 501*1dcdf01fSchristosthe list of permitted ciphers in a database and only use those. 502*1dcdf01fSchristos 503*1dcdf01fSchristosNo revocation checking is done on the signer's certificate. 504*1dcdf01fSchristos 505*1dcdf01fSchristosThe current code can only handle S/MIME v2 messages, the more complex S/MIME v3 506*1dcdf01fSchristosstructures may cause parsing errors. 507*1dcdf01fSchristos 508*1dcdf01fSchristos=head1 HISTORY 509*1dcdf01fSchristos 510*1dcdf01fSchristosThe use of multiple B<-signer> options and the B<-resign> command were first 511*1dcdf01fSchristosadded in OpenSSL 1.0.0 512*1dcdf01fSchristos 513*1dcdf01fSchristosThe -no_alt_chains option was added in OpenSSL 1.1.0. 514*1dcdf01fSchristos 515*1dcdf01fSchristos=head1 COPYRIGHT 516*1dcdf01fSchristos 517*1dcdf01fSchristosCopyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved. 518*1dcdf01fSchristos 519*1dcdf01fSchristosLicensed under the OpenSSL license (the "License"). You may not use 520*1dcdf01fSchristosthis file except in compliance with the License. You can obtain a copy 521*1dcdf01fSchristosin the file LICENSE in the source distribution or at 522*1dcdf01fSchristosL<https://www.openssl.org/source/license.html>. 523*1dcdf01fSchristos 524*1dcdf01fSchristos=cut 525