openssl-pkcs12.pod.in 13 KB

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