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