openssl-smime.1ossl 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. .\" -*- mode: troff; coding: utf-8 -*-
  2. .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
  3. .\"
  4. .\" Standard preamble:
  5. .\" ========================================================================
  6. .de Sp \" Vertical space (when we can't use .PP)
  7. .if t .sp .5v
  8. .if n .sp
  9. ..
  10. .de Vb \" Begin verbatim text
  11. .ft CW
  12. .nf
  13. .ne \\$1
  14. ..
  15. .de Ve \" End verbatim text
  16. .ft R
  17. .fi
  18. ..
  19. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
  20. .ie n \{\
  21. . ds C` ""
  22. . ds C' ""
  23. 'br\}
  24. .el\{\
  25. . ds C`
  26. . ds C'
  27. 'br\}
  28. .\"
  29. .\" Escape single quotes in literal strings from groff's Unicode transform.
  30. .ie \n(.g .ds Aq \(aq
  31. .el .ds Aq '
  32. .\"
  33. .\" If the F register is >0, we'll generate index entries on stderr for
  34. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  35. .\" entries marked with X<> in POD. Of course, you'll have to process the
  36. .\" output yourself in some meaningful fashion.
  37. .\"
  38. .\" Avoid warning from groff about undefined register 'F'.
  39. .de IX
  40. ..
  41. .nr rF 0
  42. .if \n(.g .if rF .nr rF 1
  43. .if (\n(rF:(\n(.g==0)) \{\
  44. . if \nF \{\
  45. . de IX
  46. . tm Index:\\$1\t\\n%\t"\\$2"
  47. ..
  48. . if !\nF==2 \{\
  49. . nr % 0
  50. . nr F 2
  51. . \}
  52. . \}
  53. .\}
  54. .rr rF
  55. .\" ========================================================================
  56. .\"
  57. .IX Title "OPENSSL-SMIME 1ossl"
  58. .TH OPENSSL-SMIME 1ossl 2025-01-17 3.4.0 OpenSSL
  59. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  60. .\" way too many mistakes in technical documents.
  61. .if n .ad l
  62. .nh
  63. .SH NAME
  64. openssl\-smime \- S/MIME command
  65. .SH SYNOPSIS
  66. .IX Header "SYNOPSIS"
  67. \&\fBopenssl\fR \fBsmime\fR
  68. [\fB\-help\fR]
  69. [\fB\-encrypt\fR]
  70. [\fB\-decrypt\fR]
  71. [\fB\-sign\fR]
  72. [\fB\-resign\fR]
  73. [\fB\-verify\fR]
  74. [\fB\-pk7out\fR]
  75. [\fB\-binary\fR]
  76. [\fB\-crlfeol\fR]
  77. [\fB\-\fR\f(BIcipher\fR]
  78. [\fB\-in\fR \fIfile\fR]
  79. [\fB\-certfile\fR \fIfile\fR]
  80. [\fB\-signer\fR \fIfile\fR]
  81. [\fB\-nointern\fR]
  82. [\fB\-noverify\fR]
  83. [\fB\-nochain\fR]
  84. [\fB\-nosigs\fR]
  85. [\fB\-nocerts\fR]
  86. [\fB\-noattr\fR]
  87. [\fB\-nodetach\fR]
  88. [\fB\-nosmimecap\fR]
  89. [\fB\-recip\fR \fI file\fR]
  90. [\fB\-inform\fR \fBDER\fR|\fBPEM\fR|\fBSMIME\fR]
  91. [\fB\-outform\fR \fBDER\fR|\fBPEM\fR|\fBSMIME\fR]
  92. [\fB\-keyform\fR \fBDER\fR|\fBPEM\fR|\fBP12\fR|\fBENGINE\fR]
  93. [\fB\-passin\fR \fIarg\fR]
  94. [\fB\-inkey\fR \fIfilename\fR|\fIuri\fR]
  95. [\fB\-out\fR \fIfile\fR]
  96. [\fB\-content\fR \fIfile\fR]
  97. [\fB\-to\fR \fIaddr\fR]
  98. [\fB\-from\fR \fIad\fR]
  99. [\fB\-subject\fR \fIs\fR]
  100. [\fB\-text\fR]
  101. [\fB\-indef\fR]
  102. [\fB\-noindef\fR]
  103. [\fB\-stream\fR]
  104. [\fB\-md\fR \fIdigest\fR]
  105. [\fB\-CAfile\fR \fIfile\fR]
  106. [\fB\-no\-CAfile\fR]
  107. [\fB\-CApath\fR \fIdir\fR]
  108. [\fB\-no\-CApath\fR]
  109. [\fB\-CAstore\fR \fIuri\fR]
  110. [\fB\-no\-CAstore\fR]
  111. [\fB\-engine\fR \fIid\fR]
  112. [\fB\-rand\fR \fIfiles\fR]
  113. [\fB\-writerand\fR \fIfile\fR]
  114. [\fB\-allow_proxy_certs\fR]
  115. [\fB\-attime\fR \fItimestamp\fR]
  116. [\fB\-no_check_time\fR]
  117. [\fB\-check_ss_sig\fR]
  118. [\fB\-crl_check\fR]
  119. [\fB\-crl_check_all\fR]
  120. [\fB\-explicit_policy\fR]
  121. [\fB\-extended_crl\fR]
  122. [\fB\-ignore_critical\fR]
  123. [\fB\-inhibit_any\fR]
  124. [\fB\-inhibit_map\fR]
  125. [\fB\-partial_chain\fR]
  126. [\fB\-policy\fR \fIarg\fR]
  127. [\fB\-policy_check\fR]
  128. [\fB\-policy_print\fR]
  129. [\fB\-purpose\fR \fIpurpose\fR]
  130. [\fB\-suiteB_128\fR]
  131. [\fB\-suiteB_128_only\fR]
  132. [\fB\-suiteB_192\fR]
  133. [\fB\-trusted_first\fR]
  134. [\fB\-no_alt_chains\fR]
  135. [\fB\-use_deltas\fR]
  136. [\fB\-auth_level\fR \fInum\fR]
  137. [\fB\-verify_depth\fR \fInum\fR]
  138. [\fB\-verify_email\fR \fIemail\fR]
  139. [\fB\-verify_hostname\fR \fIhostname\fR]
  140. [\fB\-verify_ip\fR \fIip\fR]
  141. [\fB\-verify_name\fR \fIname\fR]
  142. [\fB\-x509_strict\fR]
  143. [\fB\-issuer_checks\fR]
  144. [\fB\-provider\fR \fIname\fR]
  145. [\fB\-provider\-path\fR \fIpath\fR]
  146. [\fB\-propquery\fR \fIpropq\fR]
  147. [\fB\-config\fR \fIconfigfile\fR]
  148. \&\fIrecipcert\fR ...
  149. .SH DESCRIPTION
  150. .IX Header "DESCRIPTION"
  151. This command handles S/MIME mail. It can encrypt, decrypt, sign
  152. and verify S/MIME messages.
  153. .SH OPTIONS
  154. .IX Header "OPTIONS"
  155. There are six operation options that set the type of operation to be performed:
  156. \&\fB\-encrypt\fR, \fB\-decrypt\fR, \fB\-sign\fR, \fB\-resign\fR, \fB\-verify\fR, and \fB\-pk7out\fR.
  157. These are mutually exclusive.
  158. The meaning of the other options varies according to the operation type.
  159. .IP \fB\-help\fR 4
  160. .IX Item "-help"
  161. Print out a usage message.
  162. .IP \fB\-encrypt\fR 4
  163. .IX Item "-encrypt"
  164. Encrypt mail for the given recipient certificates. Input file is the message
  165. to be encrypted. The output file is the encrypted mail in MIME format.
  166. .Sp
  167. Note that no revocation check is done for the recipient cert, so if that
  168. key has been compromised, others may be able to decrypt the text.
  169. .IP \fB\-decrypt\fR 4
  170. .IX Item "-decrypt"
  171. Decrypt mail using the supplied certificate and private key. Expects an
  172. encrypted mail message in MIME format for the input file. The decrypted mail
  173. is written to the output file.
  174. .IP \fB\-sign\fR 4
  175. .IX Item "-sign"
  176. Sign mail using the supplied certificate and private key. Input file is
  177. the message to be signed. The signed message in MIME format is written
  178. to the output file.
  179. .IP \fB\-resign\fR 4
  180. .IX Item "-resign"
  181. Resign a message: take an existing message and one or more new signers.
  182. .IP \fB\-verify\fR 4
  183. .IX Item "-verify"
  184. Verify signed mail. Expects a signed mail message on input and outputs
  185. the signed data. Both clear text and opaque signing is supported.
  186. .IP \fB\-pk7out\fR 4
  187. .IX Item "-pk7out"
  188. Takes an input message and writes out a PEM encoded PKCS#7 structure.
  189. .IP "\fB\-in\fR \fIfilename\fR" 4
  190. .IX Item "-in filename"
  191. The input message to be encrypted or signed or the MIME message to
  192. be decrypted or verified.
  193. .IP "\fB\-out\fR \fIfilename\fR" 4
  194. .IX Item "-out filename"
  195. The message text that has been decrypted or verified or the output MIME
  196. format message that has been signed or verified.
  197. .IP "\fB\-inform\fR \fBDER\fR|\fBPEM\fR|\fBSMIME\fR" 4
  198. .IX Item "-inform DER|PEM|SMIME"
  199. The input format of the PKCS#7 (S/MIME) structure (if one is being read);
  200. the default is \fBSMIME\fR.
  201. See \fBopenssl\-format\-options\fR\|(1) for details.
  202. .IP "\fB\-outform\fR \fBDER\fR|\fBPEM\fR|\fBSMIME\fR" 4
  203. .IX Item "-outform DER|PEM|SMIME"
  204. The output format of the PKCS#7 (S/MIME) structure (if one is being written);
  205. the default is \fBSMIME\fR.
  206. See \fBopenssl\-format\-options\fR\|(1) for details.
  207. .IP "\fB\-keyform\fR \fBDER\fR|\fBPEM\fR|\fBP12\fR|\fBENGINE\fR" 4
  208. .IX Item "-keyform DER|PEM|P12|ENGINE"
  209. The key format; unspecified by default.
  210. See \fBopenssl\-format\-options\fR\|(1) for details.
  211. .IP "\fB\-stream\fR, \fB\-indef\fR, \fB\-noindef\fR" 4
  212. .IX Item "-stream, -indef, -noindef"
  213. The \fB\-stream\fR and \fB\-indef\fR options are equivalent and enable streaming I/O
  214. for encoding operations. This permits single pass processing of data without
  215. the need to hold the entire contents in memory, potentially supporting very
  216. large files. Streaming is automatically set for S/MIME signing with detached
  217. data if the output format is \fBSMIME\fR it is currently off by default for all
  218. other operations.
  219. .IP \fB\-noindef\fR 4
  220. .IX Item "-noindef"
  221. Disable streaming I/O where it would produce and indefinite length constructed
  222. encoding. This option currently has no effect. In future streaming will be
  223. enabled by default on all relevant operations and this option will disable it.
  224. .IP "\fB\-content\fR \fIfilename\fR" 4
  225. .IX Item "-content filename"
  226. This specifies a file containing the detached content, this is only
  227. useful with the \fB\-verify\fR command. This is only usable if the PKCS#7
  228. structure is using the detached signature form where the content is
  229. not included. This option will override any content if the input format
  230. is S/MIME and it uses the multipart/signed MIME content type.
  231. .IP \fB\-text\fR 4
  232. .IX Item "-text"
  233. This option adds plain text (text/plain) MIME headers to the supplied
  234. message if encrypting or signing. If decrypting or verifying it strips
  235. off text headers: if the decrypted or verified message is not of MIME
  236. type text/plain then an error occurs.
  237. .IP "\fB\-md\fR \fIdigest\fR" 4
  238. .IX Item "-md digest"
  239. Digest algorithm to use when signing or resigning. If not present then the
  240. default digest algorithm for the signing key will be used (usually SHA1).
  241. .IP \fB\-\fR\f(BIcipher\fR 4
  242. .IX Item "-cipher"
  243. The encryption algorithm to use. For example DES (56 bits) \- \fB\-des\fR,
  244. triple DES (168 bits) \- \fB\-des3\fR,
  245. \&\fBEVP_get_cipherbyname()\fR function) can also be used preceded by a dash, for
  246. example \fB\-aes\-128\-cbc\fR. See \fBopenssl\-enc\fR\|(1) for list of ciphers
  247. supported by your version of OpenSSL.
  248. .Sp
  249. If not specified triple DES is used. Only used with \fB\-encrypt\fR.
  250. .IP \fB\-nointern\fR 4
  251. .IX Item "-nointern"
  252. When verifying a message normally certificates (if any) included in
  253. the message are searched for the signing certificate. With this option
  254. only the certificates specified in the \fB\-certfile\fR option are used.
  255. The supplied certificates can still be used as untrusted CAs however.
  256. .IP \fB\-noverify\fR 4
  257. .IX Item "-noverify"
  258. Do not verify the signers certificate of a signed message.
  259. .IP \fB\-nochain\fR 4
  260. .IX Item "-nochain"
  261. Do not do chain verification of signers certificates; that is, do not
  262. use the certificates in the signed message as untrusted CAs.
  263. .IP \fB\-nosigs\fR 4
  264. .IX Item "-nosigs"
  265. Don't try to verify the signatures on the message.
  266. .IP \fB\-nocerts\fR 4
  267. .IX Item "-nocerts"
  268. When signing a message, the signer's certificate is normally included.
  269. With this option it is excluded. This will reduce the size of the
  270. signed message, but the verifier must have a copy of the signers certificate
  271. available locally (passed using the \fB\-certfile\fR option for example).
  272. .IP \fB\-noattr\fR 4
  273. .IX Item "-noattr"
  274. Normally, when a message is signed, a set of attributes are included which
  275. include the signing time and supported symmetric algorithms. With this
  276. option they are not included.
  277. .IP \fB\-nodetach\fR 4
  278. .IX Item "-nodetach"
  279. When signing a message use opaque signing. This form is more resistant
  280. to translation by mail relays but it cannot be read by mail agents that
  281. do not support S/MIME. Without this option cleartext signing with
  282. the MIME type multipart/signed is used.
  283. .IP \fB\-nosmimecap\fR 4
  284. .IX Item "-nosmimecap"
  285. When signing a message, do not include the \fBSMIMECapabilities\fR attribute.
  286. .IP \fB\-binary\fR 4
  287. .IX Item "-binary"
  288. Normally the input message is converted to "canonical" format which is
  289. effectively using CR and LF as end of line: as required by the S/MIME
  290. specification. When this option is present no translation occurs. This
  291. is useful when handling binary data which may not be in MIME format.
  292. .IP \fB\-crlfeol\fR 4
  293. .IX Item "-crlfeol"
  294. Normally the output file uses a single \fBLF\fR as end of line. When this
  295. option is present \fBCRLF\fR is used instead.
  296. .IP "\fB\-certfile\fR \fIfile\fR" 4
  297. .IX Item "-certfile file"
  298. Allows additional certificates to be specified. When signing these will
  299. be included with the message. When verifying, these will be searched for
  300. signer certificates and will be used for chain building.
  301. .Sp
  302. The input can be in PEM, DER, or PKCS#12 format.
  303. .IP "\fB\-signer\fR \fIfile\fR" 4
  304. .IX Item "-signer file"
  305. A signing certificate when signing or resigning a message, this option can be
  306. used multiple times if more than one signer is required. If a message is being
  307. verified then the signers certificates will be written to this file if the
  308. verification was successful.
  309. .IP "\fB\-recip\fR \fIfile\fR" 4
  310. .IX Item "-recip file"
  311. The recipients certificate when decrypting a message. This certificate
  312. must match one of the recipients of the message or an error occurs.
  313. .IP "\fB\-inkey\fR \fIfilename\fR|\fIuri\fR" 4
  314. .IX Item "-inkey filename|uri"
  315. The private key to use when signing or decrypting. This must match the
  316. corresponding certificate. If this option is not specified then the
  317. private key must be included in the certificate file specified with
  318. the \fB\-recip\fR or \fB\-signer\fR file. When signing this option can be used
  319. multiple times to specify successive keys.
  320. .IP "\fB\-passin\fR \fIarg\fR" 4
  321. .IX Item "-passin arg"
  322. The private key password source. For more information about the format of \fIarg\fR
  323. see \fBopenssl\-passphrase\-options\fR\|(1).
  324. .IP "\fB\-to\fR, \fB\-from\fR, \fB\-subject\fR" 4
  325. .IX Item "-to, -from, -subject"
  326. The relevant mail headers. These are included outside the signed
  327. portion of a message so they may be included manually. If signing
  328. then many S/MIME mail clients check the signers certificate's email
  329. address matches that specified in the From: address.
  330. .IP "\fB\-allow_proxy_certs\fR, \fB\-attime\fR, \fB\-no_check_time\fR, \fB\-check_ss_sig\fR, \fB\-crl_check\fR, \fB\-crl_check_all\fR, \fB\-explicit_policy\fR, \fB\-extended_crl\fR, \fB\-ignore_critical\fR, \fB\-inhibit_any\fR, \fB\-inhibit_map\fR, \fB\-no_alt_chains\fR, \fB\-partial_chain\fR, \fB\-policy\fR, \fB\-policy_check\fR, \fB\-policy_print\fR, \fB\-purpose\fR, \fB\-suiteB_128\fR, \fB\-suiteB_128_only\fR, \fB\-suiteB_192\fR, \fB\-trusted_first\fR, \fB\-use_deltas\fR, \fB\-auth_level\fR, \fB\-verify_depth\fR, \fB\-verify_email\fR, \fB\-verify_hostname\fR, \fB\-verify_ip\fR, \fB\-verify_name\fR, \fB\-x509_strict\fR \fB\-issuer_checks\fR" 4
  331. .IX Item "-allow_proxy_certs, -attime, -no_check_time, -check_ss_sig, -crl_check, -crl_check_all, -explicit_policy, -extended_crl, -ignore_critical, -inhibit_any, -inhibit_map, -no_alt_chains, -partial_chain, -policy, -policy_check, -policy_print, -purpose, -suiteB_128, -suiteB_128_only, -suiteB_192, -trusted_first, -use_deltas, -auth_level, -verify_depth, -verify_email, -verify_hostname, -verify_ip, -verify_name, -x509_strict -issuer_checks"
  332. Set various options of certificate chain verification.
  333. See "Verification Options" in \fBopenssl\-verification\-options\fR\|(1) for details.
  334. .Sp
  335. Any verification errors cause the command to exit.
  336. .IP "\fB\-CAfile\fR \fIfile\fR, \fB\-no\-CAfile\fR, \fB\-CApath\fR \fIdir\fR, \fB\-no\-CApath\fR, \fB\-CAstore\fR \fIuri\fR, \fB\-no\-CAstore\fR" 4
  337. .IX Item "-CAfile file, -no-CAfile, -CApath dir, -no-CApath, -CAstore uri, -no-CAstore"
  338. See "Trusted Certificate Options" in \fBopenssl\-verification\-options\fR\|(1) for details.
  339. .IP "\fB\-engine\fR \fIid\fR" 4
  340. .IX Item "-engine id"
  341. See "Engine Options" in \fBopenssl\fR\|(1).
  342. This option is deprecated.
  343. .IP "\fB\-rand\fR \fIfiles\fR, \fB\-writerand\fR \fIfile\fR" 4
  344. .IX Item "-rand files, -writerand file"
  345. See "Random State Options" in \fBopenssl\fR\|(1) for details.
  346. .IP "\fB\-provider\fR \fIname\fR" 4
  347. .IX Item "-provider name"
  348. .PD 0
  349. .IP "\fB\-provider\-path\fR \fIpath\fR" 4
  350. .IX Item "-provider-path path"
  351. .IP "\fB\-propquery\fR \fIpropq\fR" 4
  352. .IX Item "-propquery propq"
  353. .PD
  354. See "Provider Options" in \fBopenssl\fR\|(1), \fBprovider\fR\|(7), and \fBproperty\fR\|(7).
  355. .IP "\fB\-config\fR \fIconfigfile\fR" 4
  356. .IX Item "-config configfile"
  357. See "Configuration Option" in \fBopenssl\fR\|(1).
  358. .IP "\fIrecipcert\fR ..." 4
  359. .IX Item "recipcert ..."
  360. One or more certificates of message recipients, used when encrypting
  361. a message.
  362. .SH NOTES
  363. .IX Header "NOTES"
  364. The MIME message must be sent without any blank lines between the
  365. headers and the output. Some mail programs will automatically add
  366. a blank line. Piping the mail directly to sendmail is one way to
  367. achieve the correct format.
  368. .PP
  369. The supplied message to be signed or encrypted must include the
  370. necessary MIME headers or many S/MIME clients won't display it
  371. properly (if at all). You can use the \fB\-text\fR option to automatically
  372. add plain text headers.
  373. .PP
  374. A "signed and encrypted" message is one where a signed message is
  375. then encrypted. This can be produced by encrypting an already signed
  376. message: see the examples section.
  377. .PP
  378. This version of the program only allows one signer per message but it
  379. will verify multiple signers on received messages. Some S/MIME clients
  380. choke if a message contains multiple signers. It is possible to sign
  381. messages "in parallel" by signing an already signed message.
  382. .PP
  383. The options \fB\-encrypt\fR and \fB\-decrypt\fR reflect common usage in S/MIME
  384. clients. Strictly speaking these process PKCS#7 enveloped data: PKCS#7
  385. encrypted data is used for other purposes.
  386. .PP
  387. The \fB\-resign\fR option uses an existing message digest when adding a new
  388. signer. This means that attributes must be present in at least one existing
  389. signer using the same message digest or this operation will fail.
  390. .PP
  391. The \fB\-stream\fR and \fB\-indef\fR options enable streaming I/O support.
  392. As a result the encoding is BER using indefinite length constructed encoding
  393. and no longer DER. Streaming is supported for the \fB\-encrypt\fR operation and the
  394. \&\fB\-sign\fR operation if the content is not detached.
  395. .PP
  396. Streaming is always used for the \fB\-sign\fR operation with detached data but
  397. since the content is no longer part of the PKCS#7 structure the encoding
  398. remains DER.
  399. .SH "EXIT CODES"
  400. .IX Header "EXIT CODES"
  401. .IP 0 4
  402. The operation was completely successfully.
  403. .IP 1 4
  404. .IX Item "1"
  405. An error occurred parsing the command options.
  406. .IP 2 4
  407. .IX Item "2"
  408. One of the input files could not be read.
  409. .IP 3 4
  410. .IX Item "3"
  411. An error occurred creating the PKCS#7 file or when reading the MIME
  412. message.
  413. .IP 4 4
  414. .IX Item "4"
  415. An error occurred decrypting or verifying the message.
  416. .IP 5 4
  417. .IX Item "5"
  418. The message was verified correctly but an error occurred writing out
  419. the signers certificates.
  420. .SH EXAMPLES
  421. .IX Header "EXAMPLES"
  422. Create a cleartext signed message:
  423. .PP
  424. .Vb 2
  425. \& openssl smime \-sign \-in message.txt \-text \-out mail.msg \e
  426. \& \-signer mycert.pem
  427. .Ve
  428. .PP
  429. Create an opaque signed message:
  430. .PP
  431. .Vb 2
  432. \& openssl smime \-sign \-in message.txt \-text \-out mail.msg \-nodetach \e
  433. \& \-signer mycert.pem
  434. .Ve
  435. .PP
  436. Create a signed message, include some additional certificates and
  437. read the private key from another file:
  438. .PP
  439. .Vb 2
  440. \& openssl smime \-sign \-in in.txt \-text \-out mail.msg \e
  441. \& \-signer mycert.pem \-inkey mykey.pem \-certfile mycerts.pem
  442. .Ve
  443. .PP
  444. Create a signed message with two signers:
  445. .PP
  446. .Vb 2
  447. \& openssl smime \-sign \-in message.txt \-text \-out mail.msg \e
  448. \& \-signer mycert.pem \-signer othercert.pem
  449. .Ve
  450. .PP
  451. Send a signed message under Unix directly to sendmail, including headers:
  452. .PP
  453. .Vb 3
  454. \& openssl smime \-sign \-in in.txt \-text \-signer mycert.pem \e
  455. \& \-from steve@openssl.org \-to someone@somewhere \e
  456. \& \-subject "Signed message" | sendmail someone@somewhere
  457. .Ve
  458. .PP
  459. Verify a message and extract the signer's certificate if successful:
  460. .PP
  461. .Vb 1
  462. \& openssl smime \-verify \-in mail.msg \-signer user.pem \-out signedtext.txt
  463. .Ve
  464. .PP
  465. Send encrypted mail using triple DES:
  466. .PP
  467. .Vb 3
  468. \& openssl smime \-encrypt \-in in.txt \-from steve@openssl.org \e
  469. \& \-to someone@somewhere \-subject "Encrypted message" \e
  470. \& \-des3 user.pem \-out mail.msg
  471. .Ve
  472. .PP
  473. Sign and encrypt mail:
  474. .PP
  475. .Vb 4
  476. \& openssl smime \-sign \-in ml.txt \-signer my.pem \-text \e
  477. \& | openssl smime \-encrypt \-out mail.msg \e
  478. \& \-from steve@openssl.org \-to someone@somewhere \e
  479. \& \-subject "Signed and Encrypted message" \-des3 user.pem
  480. .Ve
  481. .PP
  482. Note: the encryption command does not include the \fB\-text\fR option because the
  483. message being encrypted already has MIME headers.
  484. .PP
  485. Decrypt mail:
  486. .PP
  487. .Vb 1
  488. \& openssl smime \-decrypt \-in mail.msg \-recip mycert.pem \-inkey key.pem
  489. .Ve
  490. .PP
  491. The output from Netscape form signing is a PKCS#7 structure with the
  492. detached signature format. You can use this program to verify the
  493. signature by line wrapping the base64 encoded structure and surrounding
  494. it with:
  495. .PP
  496. .Vb 2
  497. \& \-\-\-\-\-BEGIN PKCS7\-\-\-\-\-
  498. \& \-\-\-\-\-END PKCS7\-\-\-\-\-
  499. .Ve
  500. .PP
  501. and using the command:
  502. .PP
  503. .Vb 1
  504. \& openssl smime \-verify \-inform PEM \-in signature.pem \-content content.txt
  505. .Ve
  506. .PP
  507. Alternatively you can base64 decode the signature and use:
  508. .PP
  509. .Vb 1
  510. \& openssl smime \-verify \-inform DER \-in signature.der \-content content.txt
  511. .Ve
  512. .PP
  513. Create an encrypted message using 128 bit Camellia:
  514. .PP
  515. .Vb 1
  516. \& openssl smime \-encrypt \-in plain.txt \-camellia128 \-out mail.msg cert.pem
  517. .Ve
  518. .PP
  519. Add a signer to an existing message:
  520. .PP
  521. .Vb 1
  522. \& openssl smime \-resign \-in mail.msg \-signer newsign.pem \-out mail2.msg
  523. .Ve
  524. .SH BUGS
  525. .IX Header "BUGS"
  526. The MIME parser isn't very clever: it seems to handle most messages that I've
  527. thrown at it but it may choke on others.
  528. .PP
  529. The code currently will only write out the signer's certificate to a file: if
  530. the signer has a separate encryption certificate this must be manually
  531. extracted. There should be some heuristic that determines the correct
  532. encryption certificate.
  533. .PP
  534. Ideally a database should be maintained of a certificates for each email
  535. address.
  536. .PP
  537. The code doesn't currently take note of the permitted symmetric encryption
  538. algorithms as supplied in the SMIMECapabilities signed attribute. This means the
  539. user has to manually include the correct encryption algorithm. It should store
  540. the list of permitted ciphers in a database and only use those.
  541. .PP
  542. No revocation checking is done on the signer's certificate.
  543. .PP
  544. The current code can only handle S/MIME v2 messages, the more complex S/MIME v3
  545. structures may cause parsing errors.
  546. .SH "SEE ALSO"
  547. .IX Header "SEE ALSO"
  548. \&\fBossl_store\-file\fR\|(7)
  549. .SH HISTORY
  550. .IX Header "HISTORY"
  551. The use of multiple \fB\-signer\fR options and the \fB\-resign\fR command were first
  552. added in OpenSSL 1.0.0
  553. .PP
  554. The \-no_alt_chains option was added in OpenSSL 1.1.0.
  555. .PP
  556. The \fB\-engine\fR option was deprecated in OpenSSL 3.0.
  557. .SH COPYRIGHT
  558. .IX Header "COPYRIGHT"
  559. Copyright 2000\-2024 The OpenSSL Project Authors. All Rights Reserved.
  560. .PP
  561. Licensed under the Apache License 2.0 (the "License"). You may not use
  562. this file except in compliance with the License. You can obtain a copy
  563. in the file LICENSE in the source distribution or at
  564. <https://www.openssl.org/source/license.html>.