openssl-cms.pod.in 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766
  1. =pod
  2. =begin comment
  3. {- join("\n", @autowarntext) -}
  4. =end comment
  5. =head1 NAME
  6. openssl-cms - CMS utility
  7. =head1 SYNOPSIS
  8. B<openssl> B<cms>
  9. [B<-help>]
  10. [B<-encrypt>]
  11. [B<-decrypt>]
  12. [B<-sign>]
  13. [B<-verify>]
  14. [B<-cmsout>]
  15. [B<-resign>]
  16. [B<-cades>]
  17. [B<-data_create>]
  18. [B<-data_out>]
  19. [B<-digest_create>]
  20. [B<-digest_verify>]
  21. [B<-compress>]
  22. [B<-uncompress>]
  23. [B<-EncryptedData_encrypt>]
  24. [B<-sign_receipt>]
  25. [B<-verify_receipt> I<receipt>]
  26. [B<-in> I<filename>]
  27. [B<-out> I<filename>]
  28. [B<-inform> B<DER>|B<PEM>|B<SMIME>]
  29. [B<-outform> B<DER>|B<PEM>|B<SMIME>]
  30. [B<-rctform> B<DER>|B<PEM>|B<SMIME>]
  31. [B<-keyform> B<DER>|B<PEM>|B<ENGINE>]
  32. [B<-stream>]
  33. [B<-indef>]
  34. [B<-noindef>]
  35. [B<-noindef>]
  36. [B<-content> I<filename>]
  37. [B<-text>]
  38. [B<-noout>]
  39. [B<-print>]
  40. [B<-attime> I<timestamp>]
  41. [B<-check_ss_sig>]
  42. [B<-crl_check>]
  43. [B<-crl_check_all>]
  44. [B<-explicit_policy>]
  45. [B<-extended_crl>]
  46. [B<-ignore_critical>]
  47. [B<-inhibit_any>]
  48. [B<-inhibit_map>]
  49. [B<-no_check_time>]
  50. [B<-partial_chain>]
  51. [B<-policy> I<arg>]
  52. [B<-policy_check>]
  53. [B<-policy_print>]
  54. [B<-purpose> I<purpose>]
  55. [B<-suiteB_128>]
  56. [B<-suiteB_128_only>]
  57. [B<-suiteB_192>]
  58. [B<-trusted_first>]
  59. [B<-no_alt_chains>]
  60. [B<-use_deltas>]
  61. [B<-auth_level> I<num>]
  62. [B<-verify_depth> I<num>]
  63. [B<-verify_email> I<email>]
  64. [B<-verify_hostname> I<hostname>]
  65. [B<-verify_ip> I<ip>]
  66. [B<-verify_name> I<name>]
  67. [B<-x509_strict>]
  68. [B<-md> I<digest>]
  69. [B<-I<cipher>>]
  70. [B<-nointern>]
  71. [B<-noverify>]
  72. [B<-nocerts>]
  73. [B<-noattr>]
  74. [B<-nosmimecap>]
  75. [B<-binary>]
  76. [B<-crlfeol>]
  77. [B<-asciicrlf>]
  78. [B<-nodetach>]
  79. [B<-certfile> I<file>]
  80. [B<-certsout> I<file>]
  81. [B<-signer> I<file>]
  82. [B<-recip> I<file>]
  83. [B<-keyid>]
  84. [B<-receipt_request_all>]
  85. [B<-receipt_request_first>]
  86. [B<-receipt_request_from> I<emailaddress>]
  87. [B<-receipt_request_to> I<emailaddress>]
  88. [B<-receipt_request_print>]
  89. [B<-secretkey> I<key>]
  90. [B<-secretkeyid> I<id>]
  91. [B<-econtent_type> I<type>]
  92. [B<-inkey> I<file>]
  93. [B<-keyopt> I<name>:I<parameter>]
  94. [B<-passin> I<arg>]
  95. [B<-to> I<addr>]
  96. [B<-from> I<addr>]
  97. [B<-subject> I<subj>]
  98. {- $OpenSSL::safe::opt_trust_synopsis -}
  99. {- $OpenSSL::safe::opt_r_synopsis -}
  100. [I<cert.pem> ...]
  101. =for openssl ifdef des-wrap engine
  102. =head1 DESCRIPTION
  103. This command handles S/MIME v3.1 mail. It can encrypt, decrypt,
  104. sign and verify, compress and uncompress S/MIME messages.
  105. =head1 OPTIONS
  106. There are fourteen operation options that set the type of operation to be
  107. performed. The meaning of the other options varies according to the operation
  108. type.
  109. =over 4
  110. =item B<-help>
  111. Print out a usage message.
  112. =item B<-encrypt>
  113. Encrypt mail for the given recipient certificates. Input file is the message
  114. to be encrypted. The output file is the encrypted mail in MIME format. The
  115. actual CMS type is <B>EnvelopedData<B>.
  116. Note that no revocation check is done for the recipient cert, so if that
  117. key has been compromised, others may be able to decrypt the text.
  118. =item B<-decrypt>
  119. Decrypt mail using the supplied certificate and private key. Expects an
  120. encrypted mail message in MIME format for the input file. The decrypted mail
  121. is written to the output file.
  122. =item B<-debug_decrypt>
  123. This option sets the B<CMS_DEBUG_DECRYPT> flag. This option should be used
  124. with caution: see the notes section below.
  125. =item B<-sign>
  126. Sign mail using the supplied certificate and private key. Input file is
  127. the message to be signed. The signed message in MIME format is written
  128. to the output file.
  129. =item B<-verify>
  130. Verify signed mail. Expects a signed mail message on input and outputs
  131. the signed data. Both clear text and opaque signing is supported.
  132. =item B<-cmsout>
  133. Takes an input message and writes out a PEM encoded CMS structure.
  134. =item B<-resign>
  135. Resign a message: take an existing message and one or more new signers.
  136. =item B<-cades>
  137. Add an ESS signing-certificate or ESS signing-certificate-v2 signed-attribute to the SignerInfo, in order to make
  138. the signature comply with the requirements for a CAdES Basic Electronic Signature (CAdES-BES). See the NOTES
  139. section for more details.
  140. =item B<-data_create>
  141. Create a CMS B<Data> type.
  142. =item B<-data_out>
  143. B<Data> type and output the content.
  144. =item B<-digest_create>
  145. Create a CMS B<DigestedData> type.
  146. =item B<-digest_verify>
  147. Verify a CMS B<DigestedData> type and output the content.
  148. =item B<-compress>
  149. Create a CMS B<CompressedData> type. OpenSSL must be compiled with B<zlib>
  150. support for this option to work, otherwise it will output an error.
  151. =item B<-uncompress>
  152. Uncompress a CMS B<CompressedData> type and output the content. OpenSSL must be
  153. compiled with B<zlib> support for this option to work, otherwise it will
  154. output an error.
  155. =item B<-EncryptedData_encrypt>
  156. Encrypt content using supplied symmetric key and algorithm using a CMS
  157. B<EncryptedData> type and output the content.
  158. =item B<-sign_receipt>
  159. Generate and output a signed receipt for the supplied message. The input
  160. message B<must> contain a signed receipt request. Functionality is otherwise
  161. similar to the B<-sign> operation.
  162. =item B<-verify_receipt> I<receipt>
  163. Verify a signed receipt in filename B<receipt>. The input message B<must>
  164. contain the original receipt request. Functionality is otherwise similar
  165. to the B<-verify> operation.
  166. =item B<-in> I<filename>
  167. The input message to be encrypted or signed or the message to be decrypted
  168. or verified.
  169. =item B<-out> I<filename>
  170. The message text that has been decrypted or verified or the output MIME
  171. format message that has been signed or verified.
  172. =item B<-inform> B<DER>|B<PEM>|B<SMIME>
  173. The input format of the CMS structure (if one is being read);
  174. the default is B<SMIME>.
  175. See L<openssl(1)/Format Options> for details.
  176. =item B<-outform> B<DER>|B<PEM>|B<SMIME>
  177. The output format of the CMS structure (if one is being written);
  178. the default is B<SMIME>.
  179. See L<openssl(1)/Format Options> for details.
  180. =item B<-keyform> B<DER>|B<PEM>|B<ENGINE>
  181. The format of the private key file; the default is B<PEM>.
  182. See L<openssl(1)/Format Options> for details.
  183. =item B<-rctform> B<DER>|B<PEM>|B<SMIME>
  184. The signed receipt format for use with the B<-receipt_verify>; the default
  185. is B<SMIME>.
  186. See L<openssl(1)/Format Options> for details.
  187. =item B<-stream>, B<-indef>, B<-noindef>
  188. The B<-stream> and B<-indef> options are equivalent and enable streaming I/O
  189. for encoding operations. This permits single pass processing of data without
  190. the need to hold the entire contents in memory, potentially supporting very
  191. large files. Streaming is automatically set for S/MIME signing with detached
  192. data if the output format is B<SMIME> it is currently off by default for all
  193. other operations.
  194. =item B<-noindef>
  195. Disable streaming I/O where it would produce and indefinite length constructed
  196. encoding. This option currently has no effect. In future streaming will be
  197. enabled by default on all relevant operations and this option will disable it.
  198. =item B<-content> I<filename>
  199. This specifies a file containing the detached content, this is only
  200. useful with the B<-verify> command. This is only usable if the CMS
  201. structure is using the detached signature form where the content is
  202. not included. This option will override any content if the input format
  203. is S/MIME and it uses the multipart/signed MIME content type.
  204. =item B<-text>
  205. This option adds plain text (text/plain) MIME headers to the supplied
  206. message if encrypting or signing. If decrypting or verifying it strips
  207. off text headers: if the decrypted or verified message is not of MIME
  208. type text/plain then an error occurs.
  209. =item B<-noout>
  210. For the B<-cmsout> operation do not output the parsed CMS structure. This
  211. is useful when combined with the B<-print> option or if the syntax of the CMS
  212. structure is being checked.
  213. =item B<-print>
  214. For the B<-cmsout> operation print out all fields of the CMS structure. This
  215. is mainly useful for testing purposes.
  216. =item B<-md> I<digest>
  217. Digest algorithm to use when signing or resigning. If not present then the
  218. default digest algorithm for the signing key will be used (usually SHA1).
  219. =item B<-I<cipher>>
  220. The encryption algorithm to use. For example triple DES (168 bits) - B<-des3>
  221. or 256 bit AES - B<-aes256>. Any standard algorithm name (as used by the
  222. EVP_get_cipherbyname() function) can also be used preceded by a dash, for
  223. example B<-aes-128-cbc>. See L<openssl-enc(1)> for a list of ciphers
  224. supported by your version of OpenSSL.
  225. If not specified triple DES is used. Only used with B<-encrypt> and
  226. B<-EncryptedData_create> commands.
  227. =item B<-nointern>
  228. When verifying a message normally certificates (if any) included in
  229. the message are searched for the signing certificate. With this option
  230. only the certificates specified in the B<-certfile> option are used.
  231. The supplied certificates can still be used as untrusted CAs however.
  232. =item B<-noverify>
  233. Do not verify the signers certificate of a signed message.
  234. =item B<-nocerts>
  235. When signing a message the signer's certificate is normally included
  236. with this option it is excluded. This will reduce the size of the
  237. signed message but the verifier must have a copy of the signers certificate
  238. available locally (passed using the B<-certfile> option for example).
  239. =item B<-noattr>
  240. Normally when a message is signed a set of attributes are included which
  241. include the signing time and supported symmetric algorithms. With this
  242. option they are not included.
  243. =item B<-nosmimecap>
  244. Exclude the list of supported algorithms from signed attributes, other options
  245. such as signing time and content type are still included.
  246. =item B<-binary>
  247. Normally the input message is converted to "canonical" format which is
  248. effectively using CR and LF as end of line: as required by the S/MIME
  249. specification. When this option is present no translation occurs. This
  250. is useful when handling binary data which may not be in MIME format.
  251. =item B<-crlfeol>
  252. Normally the output file uses a single B<LF> as end of line. When this
  253. option is present B<CRLF> is used instead.
  254. =item B<-asciicrlf>
  255. When signing use ASCII CRLF format canonicalisation. This strips trailing
  256. whitespace from all lines, deletes trailing blank lines at EOF and sets
  257. the encapsulated content type. This option is normally used with detached
  258. content and an output signature format of DER. This option is not normally
  259. needed when verifying as it is enabled automatically if the encapsulated
  260. content format is detected.
  261. =item B<-nodetach>
  262. When signing a message use opaque signing: this form is more resistant
  263. to translation by mail relays but it cannot be read by mail agents that
  264. do not support S/MIME. Without this option cleartext signing with
  265. the MIME type multipart/signed is used.
  266. =item B<-certfile> I<file>
  267. Allows additional certificates to be specified. When signing these will
  268. be included with the message. When verifying these will be searched for
  269. the signers certificates. The certificates should be in PEM format.
  270. =item B<-certsout> I<file>
  271. Any certificates contained in the message are written to I<file>.
  272. =item B<-signer> I<file>
  273. A signing certificate when signing or resigning a message, this option can be
  274. used multiple times if more than one signer is required. If a message is being
  275. verified then the signers certificates will be written to this file if the
  276. verification was successful.
  277. =item B<-recip> I<file>
  278. When decrypting a message this specifies the recipients certificate. The
  279. certificate must match one of the recipients of the message or an error
  280. occurs.
  281. When encrypting a message this option may be used multiple times to specify
  282. each recipient. This form B<must> be used if customised parameters are
  283. required (for example to specify RSA-OAEP).
  284. Only certificates carrying RSA, Diffie-Hellman or EC keys are supported by this
  285. option.
  286. =item B<-keyid>
  287. Use subject key identifier to identify certificates instead of issuer name and
  288. serial number. The supplied certificate B<must> include a subject key
  289. identifier extension. Supported by B<-sign> and B<-encrypt> options.
  290. =item B<-receipt_request_all>, B<-receipt_request_first>
  291. For B<-sign> option include a signed receipt request. Indicate requests should
  292. be provided by all recipient or first tier recipients (those mailed directly
  293. and not from a mailing list). Ignored it B<-receipt_request_from> is included.
  294. =item B<-receipt_request_from> I<emailaddress>
  295. For B<-sign> option include a signed receipt request. Add an explicit email
  296. address where receipts should be supplied.
  297. =item B<-receipt_request_to> I<emailaddress>
  298. Add an explicit email address where signed receipts should be sent to. This
  299. option B<must> but supplied if a signed receipt it requested.
  300. =item B<-receipt_request_print>
  301. For the B<-verify> operation print out the contents of any signed receipt
  302. requests.
  303. =item B<-secretkey> I<key>
  304. Specify symmetric key to use. The key must be supplied in hex format and be
  305. consistent with the algorithm used. Supported by the B<-EncryptedData_encrypt>
  306. B<-EncryptedData_decrypt>, B<-encrypt> and B<-decrypt> options. When used
  307. with B<-encrypt> or B<-decrypt> the supplied key is used to wrap or unwrap the
  308. content encryption key using an AES key in the B<KEKRecipientInfo> type.
  309. =item B<-secretkeyid> I<id>
  310. The key identifier for the supplied symmetric key for B<KEKRecipientInfo> type.
  311. This option B<must> be present if the B<-secretkey> option is used with
  312. B<-encrypt>. With B<-decrypt> operations the I<id> is used to locate the
  313. relevant key if it is not supplied then an attempt is used to decrypt any
  314. B<KEKRecipientInfo> structures.
  315. =item B<-econtent_type> I<type>
  316. Set the encapsulated content type to I<type> if not supplied the B<Data> type
  317. is used. The I<type> argument can be any valid OID name in either text or
  318. numerical format.
  319. =item B<-inkey> I<file>
  320. The private key to use when signing or decrypting. This must match the
  321. corresponding certificate. If this option is not specified then the
  322. private key must be included in the certificate file specified with
  323. the B<-recip> or B<-signer> file. When signing this option can be used
  324. multiple times to specify successive keys.
  325. =item B<-keyopt> I<name>:I<parameter>
  326. For signing and encryption this option can be used multiple times to
  327. set customised parameters for the preceding key or certificate. It can
  328. currently be used to set RSA-PSS for signing, RSA-OAEP for encryption
  329. or to modify default parameters for ECDH.
  330. =item B<-passin> I<arg>
  331. The private key password source. For more information about the format of B<arg>
  332. see L<openssl(1)/Pass Phrase Options>.
  333. =item B<-to>, B<-from>, B<-subject>
  334. The relevant mail headers. These are included outside the signed
  335. portion of a message so they may be included manually. If signing
  336. then many S/MIME mail clients check the signers certificate's email
  337. address matches that specified in the From: address.
  338. =item B<-attime>, B<-check_ss_sig>, B<-crl_check>, B<-crl_check_all>,
  339. B<-explicit_policy>, B<-extended_crl>, B<-ignore_critical>, B<-inhibit_any>,
  340. B<-inhibit_map>, B<-no_alt_chains>, B<-no_check_time>, B<-partial_chain>, B<-policy>,
  341. B<-policy_check>, B<-policy_print>, B<-purpose>, B<-suiteB_128>,
  342. B<-suiteB_128_only>, B<-suiteB_192>, B<-trusted_first>, B<-use_deltas>,
  343. B<-auth_level>, B<-verify_depth>, B<-verify_email>, B<-verify_hostname>,
  344. B<-verify_ip>, B<-verify_name>, B<-x509_strict>
  345. Set various certificate chain validation options. See the
  346. L<openssl-verify(1)> manual page for details.
  347. {- $OpenSSL::safe::opt_trust_item -}
  348. {- $OpenSSL::safe::opt_r_item -}
  349. =item I<cert.pem> ...
  350. One or more certificates of message recipients: used when encrypting
  351. a message.
  352. =back
  353. =head1 NOTES
  354. The MIME message must be sent without any blank lines between the
  355. headers and the output. Some mail programs will automatically add
  356. a blank line. Piping the mail directly to sendmail is one way to
  357. achieve the correct format.
  358. The supplied message to be signed or encrypted must include the
  359. necessary MIME headers or many S/MIME clients won't display it
  360. properly (if at all). You can use the B<-text> option to automatically
  361. add plain text headers.
  362. A "signed and encrypted" message is one where a signed message is
  363. then encrypted. This can be produced by encrypting an already signed
  364. message: see the examples section.
  365. This version of the program only allows one signer per message but it
  366. will verify multiple signers on received messages. Some S/MIME clients
  367. choke if a message contains multiple signers. It is possible to sign
  368. messages "in parallel" by signing an already signed message.
  369. The options B<-encrypt> and B<-decrypt> reflect common usage in S/MIME
  370. clients. Strictly speaking these process CMS enveloped data: CMS
  371. encrypted data is used for other purposes.
  372. The B<-resign> option uses an existing message digest when adding a new
  373. signer. This means that attributes must be present in at least one existing
  374. signer using the same message digest or this operation will fail.
  375. The B<-stream> and B<-indef> options enable streaming I/O support.
  376. As a result the encoding is BER using indefinite length constructed encoding
  377. and no longer DER. Streaming is supported for the B<-encrypt> operation and the
  378. B<-sign> operation if the content is not detached.
  379. Streaming is always used for the B<-sign> operation with detached data but
  380. since the content is no longer part of the CMS structure the encoding
  381. remains DER.
  382. If the B<-decrypt> option is used without a recipient certificate then an
  383. attempt is made to locate the recipient by trying each potential recipient
  384. in turn using the supplied private key. To thwart the MMA attack
  385. (Bleichenbacher's attack on PKCS #1 v1.5 RSA padding) all recipients are
  386. tried whether they succeed or not and if no recipients match the message
  387. is "decrypted" using a random key which will typically output garbage.
  388. The B<-debug_decrypt> option can be used to disable the MMA attack protection
  389. and return an error if no recipient can be found: this option should be used
  390. with caution. For a fuller description see L<CMS_decrypt(3)>).
  391. =head1 CADES BASIC ELECTRONIC SIGNATURE (CADES-BES)
  392. A CAdES Basic Electronic Signature (CAdES-BES), as defined in the European Standard ETSI EN 319 122-1 V1.1.1, contains:
  393. =over 4
  394. =item *
  395. The signed user data as defined in CMS (RFC 3852);
  396. =item *
  397. Content-type of the EncapsulatedContentInfo value being signed;
  398. =item *
  399. Message-digest of the eContent OCTET STRING within encapContentInfo being signed;
  400. =item *
  401. An ESS signing-certificate or ESS signing-certificate-v2 attribute, as defined in Enhanced Security Services (ESS), RFC 2634 and RFC 5035.
  402. An ESS signing-certificate attribute only allows for the use of SHA-1 as a digest algorithm.
  403. An ESS signing-certificate-v2 attribute allows for the use of any digest algorithm.
  404. =item *
  405. The digital signature value computed on the user data and, when present, on the signed attributes.
  406. Note that currently the B<-cades> option applies only to the B<-sign> operation and is ignored during
  407. the B<-verify> operation, i.e. the signing certification is not checked during the verification process.
  408. This feature might be added in a future version.
  409. =back
  410. =head1 EXIT CODES
  411. =over 4
  412. =item Z<>0
  413. The operation was completely successfully.
  414. =item Z<>1
  415. An error occurred parsing the command options.
  416. =item Z<>2
  417. One of the input files could not be read.
  418. =item Z<>3
  419. An error occurred creating the CMS file or when reading the MIME
  420. message.
  421. =item Z<>4
  422. An error occurred decrypting or verifying the message.
  423. =item Z<>5
  424. The message was verified correctly but an error occurred writing out
  425. the signers certificates.
  426. =back
  427. =head1 COMPATIBILITY WITH PKCS#7 FORMAT
  428. L<openssl-smime(1)> can only process the older B<PKCS#7> format.
  429. B<openssl cms> supports Cryptographic Message Syntax format.
  430. Use of some features will result in messages which cannot be processed by
  431. applications which only support the older format. These are detailed below.
  432. The use of the B<-keyid> option with B<-sign> or B<-encrypt>.
  433. The B<-outform> I<PEM> option uses different headers.
  434. The B<-compress> option.
  435. The B<-secretkey> option when used with B<-encrypt>.
  436. The use of PSS with B<-sign>.
  437. The use of OAEP or non-RSA keys with B<-encrypt>.
  438. Additionally the B<-EncryptedData_create> and B<-data_create> type cannot
  439. be processed by the older L<openssl-smime(1)> command.
  440. =head1 EXAMPLES
  441. Create a cleartext signed message:
  442. openssl cms -sign -in message.txt -text -out mail.msg \
  443. -signer mycert.pem
  444. Create an opaque signed message
  445. openssl cms -sign -in message.txt -text -out mail.msg -nodetach \
  446. -signer mycert.pem
  447. Create a signed message, include some additional certificates and
  448. read the private key from another file:
  449. openssl cms -sign -in in.txt -text -out mail.msg \
  450. -signer mycert.pem -inkey mykey.pem -certfile mycerts.pem
  451. Create a signed message with two signers, use key identifier:
  452. openssl cms -sign -in message.txt -text -out mail.msg \
  453. -signer mycert.pem -signer othercert.pem -keyid
  454. Send a signed message under Unix directly to sendmail, including headers:
  455. openssl cms -sign -in in.txt -text -signer mycert.pem \
  456. -from steve@openssl.org -to someone@somewhere \
  457. -subject "Signed message" | sendmail someone@somewhere
  458. Verify a message and extract the signer's certificate if successful:
  459. openssl cms -verify -in mail.msg -signer user.pem -out signedtext.txt
  460. Send encrypted mail using triple DES:
  461. openssl cms -encrypt -in in.txt -from steve@openssl.org \
  462. -to someone@somewhere -subject "Encrypted message" \
  463. -des3 user.pem -out mail.msg
  464. Sign and encrypt mail:
  465. openssl cms -sign -in ml.txt -signer my.pem -text \
  466. | openssl cms -encrypt -out mail.msg \
  467. -from steve@openssl.org -to someone@somewhere \
  468. -subject "Signed and Encrypted message" -des3 user.pem
  469. Note: the encryption command does not include the B<-text> option because the
  470. message being encrypted already has MIME headers.
  471. Decrypt mail:
  472. openssl cms -decrypt -in mail.msg -recip mycert.pem -inkey key.pem
  473. The output from Netscape form signing is a PKCS#7 structure with the
  474. detached signature format. You can use this program to verify the
  475. signature by line wrapping the base64 encoded structure and surrounding
  476. it with:
  477. -----BEGIN PKCS7-----
  478. -----END PKCS7-----
  479. and using the command,
  480. openssl cms -verify -inform PEM -in signature.pem -content content.txt
  481. alternatively you can base64 decode the signature and use
  482. openssl cms -verify -inform DER -in signature.der -content content.txt
  483. Create an encrypted message using 128 bit Camellia:
  484. openssl cms -encrypt -in plain.txt -camellia128 -out mail.msg cert.pem
  485. Add a signer to an existing message:
  486. openssl cms -resign -in mail.msg -signer newsign.pem -out mail2.msg
  487. Sign mail using RSA-PSS:
  488. openssl cms -sign -in message.txt -text -out mail.msg \
  489. -signer mycert.pem -keyopt rsa_padding_mode:pss
  490. Create encrypted mail using RSA-OAEP:
  491. openssl cms -encrypt -in plain.txt -out mail.msg \
  492. -recip cert.pem -keyopt rsa_padding_mode:oaep
  493. Use SHA256 KDF with an ECDH certificate:
  494. openssl cms -encrypt -in plain.txt -out mail.msg \
  495. -recip ecdhcert.pem -keyopt ecdh_kdf_md:sha256
  496. =head1 BUGS
  497. The MIME parser isn't very clever: it seems to handle most messages that I've
  498. thrown at it but it may choke on others.
  499. The code currently will only write out the signer's certificate to a file: if
  500. the signer has a separate encryption certificate this must be manually
  501. extracted. There should be some heuristic that determines the correct
  502. encryption certificate.
  503. Ideally a database should be maintained of a certificates for each email
  504. address.
  505. The code doesn't currently take note of the permitted symmetric encryption
  506. algorithms as supplied in the SMIMECapabilities signed attribute. this means the
  507. user has to manually include the correct encryption algorithm. It should store
  508. the list of permitted ciphers in a database and only use those.
  509. No revocation checking is done on the signer's certificate.
  510. =head1 SEE ALSO
  511. L<ossl_store-file(7)>
  512. =head1 HISTORY
  513. The use of multiple B<-signer> options and the B<-resign> command were first
  514. added in OpenSSL 1.0.0.
  515. The B<-keyopt> option was added in OpenSSL 1.0.2.
  516. Support for RSA-OAEP and RSA-PSS was added in OpenSSL 1.0.2.
  517. The use of non-RSA keys with B<-encrypt> and B<-decrypt>
  518. was added in OpenSSL 1.0.2.
  519. The -no_alt_chains option was added in OpenSSL 1.0.2b.
  520. =head1 COPYRIGHT
  521. Copyright 2008-2019 The OpenSSL Project Authors. All Rights Reserved.
  522. Licensed under the Apache License 2.0 (the "License"). You may not use
  523. this file except in compliance with the License. You can obtain a copy
  524. in the file LICENSE in the source distribution or at
  525. L<https://www.openssl.org/source/license.html>.
  526. =cut