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