2 {- OpenSSL::safe::output_do_not_edit_headers(); -}
6 openssl-pkcs12 - PKCS#12 file command
14 [B<-untrusted> I<filename>]
15 [B<-inkey> I<filename>|I<uri>]
16 [B<-certfile> I<filename>]
17 [B<-passcerts> I<arg>]
20 [B<-in> I<filename>|I<uri>]
51 [B<-certpbe> I<cipher>]
52 [B<-keypbe> I<cipher>]
53 [B<-macalg> I<digest>]
61 {- $OpenSSL::safe::opt_trust_synopsis -}
62 {- $OpenSSL::safe::opt_r_synopsis -}
63 {- $OpenSSL::safe::opt_engine_synopsis -}{- $OpenSSL::safe::opt_provider_synopsis -}
65 =for openssl ifdef engine
69 This command allows PKCS#12 files (sometimes referred to as
70 PFX files) to be created and parsed. PKCS#12 files are used by several
71 programs including Netscape, MSIE and MS Outlook.
75 There are a lot of options the meaning of some depends of whether a PKCS#12 file
76 is being created or parsed. By default a PKCS#12 file is parsed.
77 A PKCS#12 file can be created by using the B<-export> option (see below).
78 Many further options such as B<-chain> make sense only with B<-export>.
79 The default encryption algorithm is AES-256-CBC with PBKDF2 for key derivation.
81 =head1 PARSING OPTIONS
87 Print out a usage message.
89 =item B<-in> I<filename>|I<uri>
91 This specifies the input filename or URI.
92 Standard input is used by default.
93 Without the B<-export> option this is a PKCS#12 file to be parsed.
94 With the B<-export> option this is a file with certificates and possibly a key,
95 or a URI that refers to a key accessed via an engine.
97 =item B<-out> I<filename>
99 The filename to write certificates and private keys to, standard output by
100 default. They are all written in PEM format.
102 =item B<-password> I<arg>
104 With B<-export>, B<-password> is equivalent to B<-passout>,
105 otherwise it is equivalent to B<-passin>.
109 This option inhibits credentials output,
110 and so the PKCS#12 input is just verified.
114 Only output client certificates (not CA certificates).
118 Only output CA certificates (not client certificates).
122 No certificates at all will be output.
126 No private keys will be output.
130 Output additional information about the PKCS#12 file structure, algorithms
131 used and iteration counts.
135 Use DES to encrypt private keys before outputting.
139 Use triple DES to encrypt private keys before outputting.
143 Use IDEA to encrypt private keys before outputting.
145 =item B<-aes128>, B<-aes192>, B<-aes256>
147 Use AES to encrypt private keys before outputting.
149 =item B<-aria128>, B<-aria192>, B<-aria256>
151 Use ARIA to encrypt private keys before outputting.
153 =item B<-camellia128>, B<-camellia192>, B<-camellia256>
155 Use Camellia to encrypt private keys before outputting.
159 Don't encrypt the private keys at all.
163 This option is deprecated since OpenSSL 3.0; use B<-noenc> instead.
167 Don't attempt to verify the integrity MAC before reading the file.
171 Prompt for separate integrity and encryption passwords: most software
172 always assumes these are the same so this option will render such
173 PKCS#12 files unreadable. Cannot be used in combination with the options
174 B<-password>, B<-passin> if importing, or B<-passout> if exporting.
178 Use legacy mode of operation and automatically load the legacy provider.
179 In the legacy mode, the default algorithm for certificate encryption
180 is RC2_CBC or 3DES_CBC depending on whether the RC2 cipher is enabled
181 in the build. The default algorithm for private key encryption is 3DES_CBC.
182 If the legacy option is not specified, then the legacy provider is not loaded
183 and the default encryption algorithm for both certificates and private keys is
184 AES_256_CBC with PBKDF2 for key derivation by default.
188 =head1 FILE CREATION OPTIONS
194 This option specifies that a PKCS#12 file will be created rather than
197 =item B<-out> I<filename>
199 This specifies filename to write the PKCS#12 file to. Standard output is used
202 =item B<-in> I<filename>
204 The filename or URI to read certificates and private keys from, standard input
205 by default. They can be in PEM, DER, or PKCS#12 format.
206 The order doesn't matter but one private key and
207 its corresponding certificate should be present. If additional
208 certificates are present they will also be included in the PKCS#12 file.
210 =item B<-inkey> I<filename>|I<uri>
212 The private key input for PKCS12 output. If this option is not specified then
213 the input file (B<-in> argument) must contain a private key.
214 If no engine is used, the argument is taken as a file;
215 if the B<-engine> option is used or the URI has prefix C<org.openssl.engine:>
216 then the rest of the URI is taken as key identifier for the given engine.
218 =item B<-name> I<friendlyname>
220 This specifies the "friendly name" for the certificate and private key. This
221 name is typically displayed in list boxes by software importing the file.
223 =item B<-certfile> I<filename>
225 An input file with extra certificates to be added to the PKCS12 output
226 if the B<-export> option is given.
228 =item B<-untrusted> I<filename>
230 An input file of untrusted certificates that may be used
231 for chain building, which is relevant only when a PKCS#12 file is created
232 with the B<-export> option and the B<-chain> option is given as well.
233 Any certificates that are actually part of the chain are added to the output.
235 =item B<-passcerts> I<arg>
237 The password source for certificate input such as B<-certfile>
239 For more information about the format of B<arg>
240 see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)>.
242 =item B<-caname> I<friendlyname>
244 This specifies the "friendly name" for other certificates. This option may be
245 used multiple times to specify names for all certificates in the order they
246 appear. Netscape ignores friendly names on other certificates whereas MSIE
249 =item B<-passin> I<arg>, B<-passout> I<arg>
251 The password source for the input, and for encrypting any private keys that
253 For more information about the format of B<arg>
254 see L<openssl(1)/Pass Phrase Options>.
258 If this option is present then the certificate chain of the end entity
259 certificate is built and included in the PKCS#12 output file.
260 The end entity certificate is the first one read from the B<-in> file
261 if no key is given, else the first certificate matching the given key.
262 The standard CA trust store is used for chain building,
263 as well as any untrusted CA certificates given with the B<-untrusted> option.
267 Encrypt the certificate using triple DES, this may render the PKCS#12
268 file unreadable by some "export grade" software. By default the private
269 key and the certificates are encrypted using AES-256-CBC unless
270 the '-legacy' option is used. If '-descert' is used with the '-legacy'
271 then both, the private key and the certificate are encrypted using triple DES.
273 =item B<-keypbe> I<alg>, B<-certpbe> I<alg>
275 These options allow the algorithm used to encrypt the private key and
276 certificates to be selected. Any PKCS#5 v1.5 or PKCS#12 PBE algorithm name
277 can be used (see L</NOTES> section for more information). If a cipher name
278 (as output by C<openssl list -cipher-algorithms>) is specified then it
279 is used with PKCS#5 v2.0. For interoperability reasons it is advisable to only
280 use PKCS#12 algorithms.
282 Special value C<NONE> disables encryption of the private key and certificate.
284 =item B<-keyex>|B<-keysig>
286 Specifies that the private key is to be used for key exchange or just signing.
287 This option is only interpreted by MSIE and similar MS software. Normally
288 "export grade" software will only allow 512 bit RSA keys to be used for
289 encryption purposes but arbitrary length keys for signing. The B<-keysig>
290 option marks the key for signing only. Signing only keys can be used for
291 S/MIME signing, authenticode (ActiveX control signing) and SSL client
292 authentication, however, due to a bug only MSIE 5.0 and later support
293 the use of signing only keys for SSL client authentication.
295 =item B<-macalg> I<digest>
297 Specify the MAC digest algorithm. If not included them SHA1 will be used.
299 =item B<-iter> I<count>
301 This option specifies the iteration count for the encryption key and MAC. The
302 default value is 2048.
304 To discourage attacks by using large dictionaries of common passwords the
305 algorithm that derives keys from passwords can have an iteration count applied
306 to it: this causes a certain part of the algorithm to be repeated and slows it
307 down. The MAC is used to check the file integrity but since it will normally
308 have the same password as the keys and certificates it could also be attacked.
310 =item B<-nomaciter>, B<-noiter>
312 By default both MAC and encryption iteration counts are set to 2048, using
313 these options the MAC and encryption iteration counts can be set to 1, since
314 this reduces the file security you should not use these options unless you
315 really have to. Most software supports both MAC and key iteration counts.
316 MSIE 4.0 doesn't support MAC iteration counts so it needs the B<-nomaciter>
321 This option is included for compatibility with previous versions, it used
322 to be needed to use MAC iterations counts but they are now used by default.
326 Don't attempt to provide the MAC integrity.
330 Add the "Local Key Set" identifier to the attributes.
332 =item B<-CSP> I<name>
334 Write I<name> as a Microsoft CSP name.
336 {- $OpenSSL::safe::opt_trust_item -}
338 {- $OpenSSL::safe::opt_r_item -}
340 {- $OpenSSL::safe::opt_engine_item -}
342 {- $OpenSSL::safe::opt_provider_item -}
348 Although there are a large number of options most of them are very rarely
349 used. For PKCS#12 file parsing only B<-in> and B<-out> need to be used
350 for PKCS#12 file creation B<-export> and B<-name> are also used.
352 If none of the B<-clcerts>, B<-cacerts> or B<-nocerts> options are present
353 then all certificates will be output in the order they appear in the input
354 PKCS#12 files. There is no guarantee that the first certificate present is
355 the one corresponding to the private key. Certain software which requires
356 a private key and certificate and assumes the first certificate in the
357 file is the one corresponding to the private key: this may not always
358 be the case. Using the B<-clcerts> option will solve this problem by only
359 outputting the certificate corresponding to the private key. If the CA
360 certificates are required then they can be output to a separate file using
361 the B<-nokeys> B<-cacerts> options to just output CA certificates.
363 The B<-keypbe> and B<-certpbe> algorithms allow the precise encryption
364 algorithms for private keys and certificates to be specified. Normally
365 the defaults are fine but occasionally software can't handle triple DES
366 encrypted private keys, then the option B<-keypbe> I<PBE-SHA1-RC2-40> can
367 be used to reduce the private key encryption to 40 bit RC2. A complete
368 description of all algorithms is contained in L<openssl-pkcs8(1)>.
370 Prior 1.1 release passwords containing non-ASCII characters were encoded
371 in non-compliant manner, which limited interoperability, in first hand
372 with Windows. But switching to standard-compliant password encoding
373 poses problem accessing old data protected with broken encoding. For
374 this reason even legacy encodings is attempted when reading the
375 data. If you use PKCS#12 files in production application you are advised
376 to convert the data, because implemented heuristic approach is not
377 MT-safe, its sole goal is to facilitate the data upgrade with this
382 Parse a PKCS#12 file and output it to a file:
384 openssl pkcs12 -in file.p12 -out file.pem
386 Output only client certificates to a file:
388 openssl pkcs12 -in file.p12 -clcerts -out file.pem
390 Don't encrypt the private key:
392 openssl pkcs12 -in file.p12 -out file.pem -noenc
394 Print some info about a PKCS#12 file:
396 openssl pkcs12 -in file.p12 -info -noout
398 Print some info about a PKCS#12 file in legacy mode:
400 openssl pkcs12 -in file.p12 -info -noout -legacy
402 Create a PKCS#12 file:
404 openssl pkcs12 -export -in file.pem -out file.p12 -name "My Certificate"
406 Include some extra certificates:
408 openssl pkcs12 -export -in file.pem -out file.p12 -name "My Certificate" \
409 -certfile othercerts.pem
411 Export a PKCS#12 file with default algorithms as in the legacy provider:
413 openssl pkcs12 -export -in cert.pem -inkey key.pem -out file.p12 -legacy
419 L<ossl_store-file(7)>
423 The B<-engine> option was deprecated in OpenSSL 3.0.
424 The B<-nodes> option was deprecated in OpenSSL 3.0, too; use B<-noenc> instead.
428 Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
430 Licensed under the Apache License 2.0 (the "License"). You may not use
431 this file except in compliance with the License. You can obtain a copy
432 in the file LICENSE in the source distribution or at
433 L<https://www.openssl.org/source/license.html>.