openssl-pkcs12.pod.in 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. =pod
  2. {- OpenSSL::safe::output_do_not_edit_headers(); -}
  3. =head1 NAME
  4. openssl-pkcs12 - PKCS#12 file command
  5. =head1 SYNOPSIS
  6. B<openssl> B<pkcs12>
  7. [B<-help>]
  8. [B<-passin> I<arg>]
  9. [B<-passout> I<arg>]
  10. [B<-password> I<arg>]
  11. [B<-twopass>]
  12. [B<-in> I<filename>|I<uri>]
  13. [B<-out> I<filename>]
  14. [B<-nokeys>]
  15. [B<-nocerts>]
  16. [B<-noout>]
  17. [B<-legacy>]
  18. {- $OpenSSL::safe::opt_engine_synopsis -}{- $OpenSSL::safe::opt_provider_synopsis -}
  19. {- $OpenSSL::safe::opt_r_synopsis -}
  20. PKCS#12 input (parsing) options:
  21. [B<-info>]
  22. [B<-nomacver>]
  23. [B<-clcerts>]
  24. [B<-cacerts>]
  25. [B<-aes128>]
  26. [B<-aes192>]
  27. [B<-aes256>]
  28. [B<-aria128>]
  29. [B<-aria192>]
  30. [B<-aria256>]
  31. [B<-camellia128>]
  32. [B<-camellia192>]
  33. [B<-camellia256>]
  34. [B<-des>]
  35. [B<-des3>]
  36. [B<-idea>]
  37. [B<-noenc>]
  38. [B<-nodes>]
  39. PKCS#12 output (export) options:
  40. [B<-export>]
  41. [B<-inkey> I<filename>|I<uri>]
  42. [B<-certfile> I<filename>]
  43. [B<-passcerts> I<arg>]
  44. [B<-chain>]
  45. [B<-untrusted> I<filename>]
  46. {- $OpenSSL::safe::opt_trust_synopsis -}
  47. [B<-name> I<name>]
  48. [B<-caname> I<name>]
  49. [B<-CSP> I<name>]
  50. [B<-LMK>]
  51. [B<-keyex>]
  52. [B<-keysig>]
  53. [B<-keypbe> I<cipher>]
  54. [B<-certpbe> I<cipher>]
  55. [B<-descert>]
  56. [B<-macalg> I<digest>]
  57. [B<-iter> I<count>]
  58. [B<-noiter>]
  59. [B<-nomaciter>]
  60. [B<-maciter>]
  61. [B<-nomac>]
  62. =for openssl ifdef engine
  63. =head1 DESCRIPTION
  64. This command allows PKCS#12 files (sometimes referred to as
  65. PFX files) to be created and parsed. PKCS#12 files are used by several
  66. programs including Netscape, MSIE and MS Outlook.
  67. =head1 OPTIONS
  68. There are a lot of options the meaning of some depends of whether a PKCS#12 file
  69. is being created or parsed. By default a PKCS#12 file is parsed.
  70. A PKCS#12 file can be created by using the B<-export> option (see below).
  71. The PKCS#12 export encryption and MAC options such as B<-certpbe> and B<-iter>
  72. and many further options such as B<-chain> are relevant only with B<-export>.
  73. Conversely, the options regarding encryption of private keys when outputting
  74. PKCS#12 input are relevant only when the B<-export> option is not given.
  75. The default encryption algorithm is AES-256-CBC with PBKDF2 for key derivation.
  76. =over 4
  77. =item B<-help>
  78. Print out a usage message.
  79. =item B<-passin> I<arg>
  80. The password source for the input, and for encrypting any private keys that
  81. are output.
  82. For more information about the format of B<arg>
  83. see L<openssl-passphrase-options(1)/Pass Phrase Options>.
  84. =item B<-passout> I<arg>
  85. The password source for output files.
  86. =item B<-password> I<arg>
  87. With B<-export>, B<-password> is equivalent to B<-passout>,
  88. otherwise it is equivalent to B<-passin>.
  89. =item B<-twopass>
  90. Prompt for separate integrity and encryption passwords: most software
  91. always assumes these are the same so this option will render such
  92. PKCS#12 files unreadable. Cannot be used in combination with the options
  93. B<-password>, B<-passin> if importing from PKCS#12, or B<-passout> if exporting.
  94. =item B<-nokeys>
  95. No private keys will be output.
  96. =item B<-nocerts>
  97. No certificates will be output.
  98. =item B<-noout>
  99. This option inhibits all credentials output,
  100. and so the input is just verified.
  101. =item B<-legacy>
  102. Use legacy mode of operation and automatically load the legacy provider.
  103. In the legacy mode, the default algorithm for certificate encryption
  104. is RC2_CBC or 3DES_CBC depending on whether the RC2 cipher is enabled
  105. in the build. The default algorithm for private key encryption is 3DES_CBC.
  106. If the legacy option is not specified, then the legacy provider is not loaded
  107. and the default encryption algorithm for both certificates and private keys is
  108. AES_256_CBC with PBKDF2 for key derivation.
  109. {- $OpenSSL::safe::opt_engine_item -}
  110. {- $OpenSSL::safe::opt_provider_item -}
  111. {- $OpenSSL::safe::opt_r_item -}
  112. =back
  113. =head2 PKCS#12 input (parsing) options
  114. =over 4
  115. =item B<-in> I<filename>|I<uri>
  116. This specifies the input filename or URI.
  117. Standard input is used by default.
  118. Without the B<-export> option this must be PKCS#12 file to be parsed.
  119. For use with the B<-export> option
  120. see the L</PKCS#12 output (export) options> section.
  121. =item B<-out> I<filename>
  122. The filename to write certificates and private keys to, standard output by
  123. default. They are all written in PEM format.
  124. =item B<-info>
  125. Output additional information about the PKCS#12 file structure, algorithms
  126. used and iteration counts.
  127. =item B<-nomacver>
  128. Don't attempt to verify the integrity MAC.
  129. =item B<-clcerts>
  130. Only output client certificates (not CA certificates).
  131. =item B<-cacerts>
  132. Only output CA certificates (not client certificates).
  133. =item B<-aes128>, B<-aes192>, B<-aes256>
  134. Use AES to encrypt private keys before outputting.
  135. =item B<-aria128>, B<-aria192>, B<-aria256>
  136. Use ARIA to encrypt private keys before outputting.
  137. =item B<-camellia128>, B<-camellia192>, B<-camellia256>
  138. Use Camellia to encrypt private keys before outputting.
  139. =item B<-des>
  140. Use DES to encrypt private keys before outputting.
  141. =item B<-des3>
  142. Use triple DES to encrypt private keys before outputting.
  143. =item B<-idea>
  144. Use IDEA to encrypt private keys before outputting.
  145. =item B<-noenc>
  146. Don't encrypt private keys at all.
  147. =item B<-nodes>
  148. This option is deprecated since OpenSSL 3.0; use B<-noenc> instead.
  149. =back
  150. =head2 PKCS#12 output (export) options
  151. =over 4
  152. =item B<-export>
  153. This option specifies that a PKCS#12 file will be created rather than
  154. parsed.
  155. =item B<-out> I<filename>
  156. This specifies filename to write the PKCS#12 file to. Standard output is used
  157. by default.
  158. =item B<-in> I<filename>|I<uri>
  159. This specifies the input filename or URI.
  160. Standard input is used by default.
  161. With the B<-export> option this is a file with certificates and a key,
  162. or a URI that refers to a key accessed via an engine.
  163. The order of credentials in a file doesn't matter but one private key and
  164. its corresponding certificate should be present. If additional
  165. certificates are present they will also be included in the PKCS#12 output file.
  166. =item B<-inkey> I<filename>|I<uri>
  167. The private key input for PKCS12 output.
  168. If this option is not specified then the input file (B<-in> argument) must
  169. contain a private key.
  170. If no engine is used, the argument is taken as a file.
  171. If the B<-engine> option is used or the URI has prefix C<org.openssl.engine:>
  172. then the rest of the URI is taken as key identifier for the given engine.
  173. =item B<-certfile> I<filename>
  174. An input file with extra certificates to be added to the PKCS#12 output
  175. if the B<-export> option is given.
  176. =item B<-passcerts> I<arg>
  177. The password source for certificate input such as B<-certfile>
  178. and B<-untrusted>.
  179. For more information about the format of B<arg>
  180. see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)>.
  181. =item B<-chain>
  182. If this option is present then the certificate chain of the end entity
  183. certificate is built and included in the PKCS#12 output file.
  184. The end entity certificate is the first one read from the B<-in> file
  185. if no key is given, else the first certificate matching the given key.
  186. The standard CA trust store is used for chain building,
  187. as well as any untrusted CA certificates given with the B<-untrusted> option.
  188. =item B<-untrusted> I<filename>
  189. An input file of untrusted certificates that may be used
  190. for chain building, which is relevant only when a PKCS#12 file is created
  191. with the B<-export> option and the B<-chain> option is given as well.
  192. Any certificates that are actually part of the chain are added to the output.
  193. {- $OpenSSL::safe::opt_trust_item -}
  194. =item B<-name> I<friendlyname>
  195. This specifies the "friendly name" for the certificates and private key. This
  196. name is typically displayed in list boxes by software importing the file.
  197. =item B<-caname> I<friendlyname>
  198. This specifies the "friendly name" for other certificates. This option may be
  199. used multiple times to specify names for all certificates in the order they
  200. appear. Netscape ignores friendly names on other certificates whereas MSIE
  201. displays them.
  202. =item B<-CSP> I<name>
  203. Write I<name> as a Microsoft CSP name.
  204. The password source for the input, and for encrypting any private keys that
  205. are output.
  206. For more information about the format of B<arg>
  207. see L<openssl-passphrase-options(1)>.
  208. =item B<-LMK>
  209. Add the "Local Key Set" identifier to the attributes.
  210. =item B<-keyex>|B<-keysig>
  211. Specifies that the private key is to be used for key exchange or just signing.
  212. This option is only interpreted by MSIE and similar MS software. Normally
  213. "export grade" software will only allow 512 bit RSA keys to be used for
  214. encryption purposes but arbitrary length keys for signing. The B<-keysig>
  215. option marks the key for signing only. Signing only keys can be used for
  216. S/MIME signing, authenticode (ActiveX control signing) and SSL client
  217. authentication, however, due to a bug only MSIE 5.0 and later support
  218. the use of signing only keys for SSL client authentication.
  219. =item B<-keypbe> I<alg>, B<-certpbe> I<alg>
  220. These options allow the algorithm used to encrypt the private key and
  221. certificates to be selected. Any PKCS#5 v1.5 or PKCS#12 PBE algorithm name
  222. can be used (see L</NOTES> section for more information). If a cipher name
  223. (as output by C<openssl list -cipher-algorithms>) is specified then it
  224. is used with PKCS#5 v2.0. For interoperability reasons it is advisable to only
  225. use PKCS#12 algorithms.
  226. Special value C<NONE> disables encryption of the private key and certificates.
  227. =item B<-descert>
  228. Encrypt the certificates using triple DES. By default the private
  229. key and the certificates are encrypted using AES-256-CBC unless
  230. the '-legacy' option is used. If '-descert' is used with the '-legacy'
  231. then both, the private key and the certificates are encrypted using triple DES.
  232. =item B<-macalg> I<digest>
  233. Specify the MAC digest algorithm. If not included them SHA1 will be used.
  234. =item B<-iter> I<count>
  235. This option specifies the iteration count for the encryption key and MAC. The
  236. default value is 2048.
  237. To discourage attacks by using large dictionaries of common passwords the
  238. algorithm that derives keys from passwords can have an iteration count applied
  239. to it: this causes a certain part of the algorithm to be repeated and slows it
  240. down. The MAC is used to check the file integrity but since it will normally
  241. have the same password as the keys and certificates it could also be attacked.
  242. =item B<-noiter>, B<-nomaciter>
  243. By default both encryption and MAC iteration counts are set to 2048, using
  244. these options the MAC and encryption iteration counts can be set to 1, since
  245. this reduces the file security you should not use these options unless you
  246. really have to. Most software supports both MAC and encryption iteration counts.
  247. MSIE 4.0 doesn't support MAC iteration counts so it needs the B<-nomaciter>
  248. option.
  249. =item B<-maciter>
  250. This option is included for compatibility with previous versions, it used
  251. to be needed to use MAC iterations counts but they are now used by default.
  252. =item B<-nomac>
  253. Don't attempt to provide the MAC integrity.
  254. =back
  255. =head1 NOTES
  256. Although there are a large number of options most of them are very rarely
  257. used. For PKCS#12 file parsing only B<-in> and B<-out> need to be used
  258. for PKCS#12 file creation B<-export> and B<-name> are also used.
  259. If none of the B<-clcerts>, B<-cacerts> or B<-nocerts> options are present
  260. then all certificates will be output in the order they appear in the input
  261. PKCS#12 files. There is no guarantee that the first certificate present is
  262. the one corresponding to the private key.
  263. Certain software which tries to get a private key and the corresponding
  264. certificate might assume that the first certificate in the file is the one
  265. corresponding to the private key, but that may not always be the case.
  266. Using the B<-clcerts> option will solve this problem by only
  267. outputting the certificate corresponding to the private key. If the CA
  268. certificates are required then they can be output to a separate file using
  269. the B<-nokeys> B<-cacerts> options to just output CA certificates.
  270. The B<-keypbe> and B<-certpbe> algorithms allow the precise encryption
  271. algorithms for private keys and certificates to be specified. Normally
  272. the defaults are fine but occasionally software can't handle triple DES
  273. encrypted private keys, then the option B<-keypbe> I<PBE-SHA1-RC2-40> can
  274. be used to reduce the private key encryption to 40 bit RC2. A complete
  275. description of all algorithms is contained in L<openssl-pkcs8(1)>.
  276. Prior 1.1 release passwords containing non-ASCII characters were encoded
  277. in non-compliant manner, which limited interoperability, in first hand
  278. with Windows. But switching to standard-compliant password encoding
  279. poses problem accessing old data protected with broken encoding. For
  280. this reason even legacy encodings is attempted when reading the
  281. data. If you use PKCS#12 files in production application you are advised
  282. to convert the data, because implemented heuristic approach is not
  283. MT-safe, its sole goal is to facilitate the data upgrade with this
  284. command.
  285. =head1 EXAMPLES
  286. Parse a PKCS#12 file and output it to a PEM file:
  287. openssl pkcs12 -in file.p12 -out file.pem
  288. Output only client certificates to a file:
  289. openssl pkcs12 -in file.p12 -clcerts -out file.pem
  290. Don't encrypt the private key:
  291. openssl pkcs12 -in file.p12 -out file.pem -noenc
  292. Print some info about a PKCS#12 file:
  293. openssl pkcs12 -in file.p12 -info -noout
  294. Print some info about a PKCS#12 file in legacy mode:
  295. openssl pkcs12 -in file.p12 -info -noout -legacy
  296. Create a PKCS#12 file from a PEM file that may contain a key and certificates:
  297. openssl pkcs12 -export -in file.pem -out file.p12 -name "My PSE"
  298. Include some extra certificates:
  299. openssl pkcs12 -export -in file.pem -out file.p12 -name "My PSE" \
  300. -certfile othercerts.pem
  301. Export a PKCS#12 file with data from a certificate PEM file and from a further
  302. PEM file containing a key, with default algorithms as in the legacy provider:
  303. openssl pkcs12 -export -in cert.pem -inkey key.pem -out file.p12 -legacy
  304. =head1 SEE ALSO
  305. L<openssl(1)>,
  306. L<openssl-pkcs8(1)>,
  307. L<ossl_store-file(7)>
  308. =head1 HISTORY
  309. The B<-engine> option was deprecated in OpenSSL 3.0.
  310. The B<-nodes> option was deprecated in OpenSSL 3.0, too; use B<-noenc> instead.
  311. =head1 COPYRIGHT
  312. Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
  313. Licensed under the Apache License 2.0 (the "License"). You may not use
  314. this file except in compliance with the License. You can obtain a copy
  315. in the file LICENSE in the source distribution or at
  316. L<https://www.openssl.org/source/license.html>.
  317. =cut