APPS: Adapt load_key() and load_pubkey() for the engine: loader
[openssl.git] / doc / man1 / openssl-pkcs12.pod.in
1 =pod
2 {- OpenSSL::safe::output_do_not_edit_headers(); -}
3
4 =head1 NAME
5
6 openssl-pkcs12 - PKCS#12 file command
7
8 =head1 SYNOPSIS
9
10 B<openssl> B<pkcs12>
11 [B<-help>]
12 [B<-export>]
13 [B<-chain>]
14 [B<-untrusted> I<filename>]
15 [B<-inkey> I<filename>|I<uri>]
16 [B<-certfile> I<filename>]
17 [B<-passcerts> I<arg>]
18 [B<-name> I<name>]
19 [B<-caname> I<name>]
20 [B<-in> I<filename>|I<uri>]
21 [B<-out> I<filename>]
22 [B<-noout>]
23 [B<-nomacver>]
24 [B<-nocerts>]
25 [B<-clcerts>]
26 [B<-cacerts>]
27 [B<-nokeys>]
28 [B<-info>]
29 [B<-des>]
30 [B<-des3>]
31 [B<-idea>]
32 [B<-aes128>]
33 [B<-aes192>]
34 [B<-aes256>]
35 [B<-aria128>]
36 [B<-aria192>]
37 [B<-aria256>]
38 [B<-camellia128>]
39 [B<-camellia192>]
40 [B<-camellia256>]
41 [B<-noenc>]
42 [B<-nodes>]
43 [B<-iter> I<count>]
44 [B<-noiter>]
45 [B<-nomaciter>]
46 [B<-maciter>]
47 [B<-nomac>]
48 [B<-twopass>]
49 [B<-legacy>]
50 [B<-descert>]
51 [B<-certpbe> I<cipher>]
52 [B<-keypbe> I<cipher>]
53 [B<-macalg> I<digest>]
54 [B<-keyex>]
55 [B<-keysig>]
56 [B<-password> I<arg>]
57 [B<-passin> I<arg>]
58 [B<-passout> I<arg>]
59 [B<-LMK>]
60 [B<-CSP> I<name>]
61 {- $OpenSSL::safe::opt_trust_synopsis -}
62 {- $OpenSSL::safe::opt_r_synopsis -}
63 {- $OpenSSL::safe::opt_engine_synopsis -}{- $OpenSSL::safe::opt_provider_synopsis -}
64
65 =for openssl ifdef engine
66
67 =head1 DESCRIPTION
68
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.
72
73 =head1 OPTIONS
74
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.
80
81 =head1 PARSING OPTIONS
82
83 =over 4
84
85 =item B<-help>
86
87 Print out a usage message.
88
89 =item B<-in> I<filename>|I<uri>
90
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.
96
97 =item B<-out> I<filename>
98
99 The filename to write certificates and private keys to, standard output by
100 default.  They are all written in PEM format.
101
102 =item B<-password> I<arg>
103
104 With B<-export>, B<-password> is equivalent to B<-passout>,
105 otherwise it is equivalent to B<-passin>.
106
107 =item B<-noout>
108
109 This option inhibits credentials output,
110 and so the PKCS#12 input is just verified.
111
112 =item B<-clcerts>
113
114 Only output client certificates (not CA certificates).
115
116 =item B<-cacerts>
117
118 Only output CA certificates (not client certificates).
119
120 =item B<-nocerts>
121
122 No certificates at all will be output.
123
124 =item B<-nokeys>
125
126 No private keys will be output.
127
128 =item B<-info>
129
130 Output additional information about the PKCS#12 file structure, algorithms
131 used and iteration counts.
132
133 =item B<-des>
134
135 Use DES to encrypt private keys before outputting.
136
137 =item B<-des3>
138
139 Use triple DES to encrypt private keys before outputting.
140
141 =item B<-idea>
142
143 Use IDEA to encrypt private keys before outputting.
144
145 =item B<-aes128>, B<-aes192>, B<-aes256>
146
147 Use AES to encrypt private keys before outputting.
148
149 =item B<-aria128>, B<-aria192>, B<-aria256>
150
151 Use ARIA to encrypt private keys before outputting.
152
153 =item B<-camellia128>, B<-camellia192>, B<-camellia256>
154
155 Use Camellia to encrypt private keys before outputting.
156
157 =item B<-noenc>
158
159 Don't encrypt the private keys at all.
160
161 =item B<-nodes>
162
163 This option is deprecated since OpenSSL 3.0; use B<-noenc> instead.
164
165 =item B<-nomacver>
166
167 Don't attempt to verify the integrity MAC before reading the file.
168
169 =item B<-twopass>
170
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.
175
176 =item B<-legacy>
177
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.
185
186 =back
187
188 =head1 FILE CREATION OPTIONS
189
190 =over 4
191
192 =item B<-export>
193
194 This option specifies that a PKCS#12 file will be created rather than
195 parsed.
196
197 =item B<-out> I<filename>
198
199 This specifies filename to write the PKCS#12 file to. Standard output is used
200 by default.
201
202 =item B<-in> I<filename>
203
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.
209
210 =item B<-inkey> I<filename>|I<uri>
211
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.
217
218 =item B<-name> I<friendlyname>
219
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.
222
223 =item B<-certfile> I<filename>
224
225 An input file with extra certificates to be added to the PKCS12 output
226 if the B<-export> option is given.
227
228 =item B<-untrusted> I<filename>
229
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.
234
235 =item B<-passcerts> I<arg>
236
237 The password source for certificate input such as B<-certfile>
238 and B<-untrusted>.
239 For more information about the format of B<arg>
240 see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)>.
241
242 =item B<-caname> I<friendlyname>
243
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
247 displays them.
248
249 =item B<-passin> I<arg>, B<-passout> I<arg>
250
251 The password source for the input, and for encrypting any private keys that
252 are output.
253 For more information about the format of B<arg>
254 see L<openssl(1)/Pass Phrase Options>.
255
256 =item B<-chain>
257
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.
264
265 =item B<-descert>
266
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.
272
273 =item B<-keypbe> I<alg>, B<-certpbe> I<alg>
274
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.
281
282 Special value C<NONE> disables encryption of the private key and certificate.
283
284 =item B<-keyex>|B<-keysig>
285
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.
294
295 =item B<-macalg> I<digest>
296
297 Specify the MAC digest algorithm. If not included them SHA1 will be used.
298
299 =item B<-iter> I<count>
300
301 This option specifies the iteration count for the encryption key and MAC. The
302 default value is 2048.
303
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.
309
310 =item B<-nomaciter>, B<-noiter>
311
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>
317 option.
318
319 =item B<-maciter>
320
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.
323
324 =item B<-nomac>
325
326 Don't attempt to provide the MAC integrity.
327
328 =item B<-LMK>
329
330 Add the "Local Key Set" identifier to the attributes.
331
332 =item B<-CSP> I<name>
333
334 Write I<name> as a Microsoft CSP name.
335
336 {- $OpenSSL::safe::opt_trust_item -}
337
338 {- $OpenSSL::safe::opt_r_item -}
339
340 {- $OpenSSL::safe::opt_engine_item -}
341
342 {- $OpenSSL::safe::opt_provider_item -}
343
344 =back
345
346 =head1 NOTES
347
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.
351
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.
362
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)>.
369
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
378 command.
379
380 =head1 EXAMPLES
381
382 Parse a PKCS#12 file and output it to a file:
383
384  openssl pkcs12 -in file.p12 -out file.pem
385
386 Output only client certificates to a file:
387
388  openssl pkcs12 -in file.p12 -clcerts -out file.pem
389
390 Don't encrypt the private key:
391
392  openssl pkcs12 -in file.p12 -out file.pem -noenc
393
394 Print some info about a PKCS#12 file:
395
396  openssl pkcs12 -in file.p12 -info -noout
397
398 Print some info about a PKCS#12 file in legacy mode:
399
400  openssl pkcs12 -in file.p12 -info -noout -legacy
401
402 Create a PKCS#12 file:
403
404  openssl pkcs12 -export -in file.pem -out file.p12 -name "My Certificate"
405
406 Include some extra certificates:
407
408  openssl pkcs12 -export -in file.pem -out file.p12 -name "My Certificate" \
409   -certfile othercerts.pem
410
411 Export a PKCS#12 file with default algorithms as in the legacy provider:
412
413  openssl pkcs12 -export -in cert.pem -inkey key.pem -out file.p12 -legacy
414
415 =head1 SEE ALSO
416
417 L<openssl(1)>,
418 L<openssl-pkcs8(1)>,
419 L<ossl_store-file(7)>
420
421 =head1 HISTORY
422
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.
425
426 =head1 COPYRIGHT
427
428 Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
429
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>.
434
435 =cut