1PKCS12(1)                           OpenSSL                          PKCS12(1)
2
3
4

NAME

6       pkcs12 - PKCS#12 file utility
7

SYNOPSIS

9       openssl pkcs12 [-export] [-chain] [-inkey filename] [-certfile
10       filename] [-name name] [-caname name] [-in filename] [-out filename]
11       [-noout] [-nomacver] [-nocerts] [-clcerts] [-cacerts] [-nokeys] [-info]
12       [-des | -des3 | -idea | -aes128 | -aes192 | -aes256 | -camellia128 |
13       -camellia192 | -camellia256 | -nodes] [-noiter] [-maciter | -nomaciter
14       | -nomac] [-twopass] [-descert] [-certpbe cipher] [-keypbe cipher]
15       [-macalg digest] [-keyex] [-keysig] [-password arg] [-passin arg]
16       [-passout arg] [-rand file(s)] [-CAfile file] [-CApath dir] [-CSP name]
17

DESCRIPTION

19       The pkcs12 command allows PKCS#12 files (sometimes referred to as PFX
20       files) to be created and parsed. PKCS#12 files are used by several
21       programs including Netscape, MSIE and MS Outlook.
22

COMMAND OPTIONS

24       There are a lot of options the meaning of some depends of whether a
25       PKCS#12 file is being created or parsed. By default a PKCS#12 file is
26       parsed. A PKCS#12 file can be created by using the -export option (see
27       below).
28

PARSING OPTIONS

30       -in filename
31           This specifies filename of the PKCS#12 file to be parsed. Standard
32           input is used by default.
33
34       -out filename
35           The filename to write certificates and private keys to, standard
36           output by default.  They are all written in PEM format.
37
38       -passin arg
39           the PKCS#12 file (i.e. input file) password source. For more
40           information about the format of arg see the PASS PHRASE ARGUMENTS
41           section in openssl(1).
42
43       -passout arg
44           pass phrase source to encrypt any outputted private keys with. For
45           more information about the format of arg see the PASS PHRASE
46           ARGUMENTS section in openssl(1).
47
48       -password arg
49           With -export, -password is equivalent to -passout.  Otherwise,
50           -password is equivalent to -passin.
51
52       -noout
53           this option inhibits output of the keys and certificates to the
54           output file version of the PKCS#12 file.
55
56       -clcerts
57           only output client certificates (not CA certificates).
58
59       -cacerts
60           only output CA certificates (not client certificates).
61
62       -nocerts
63           no certificates at all will be output.
64
65       -nokeys
66           no private keys will be output.
67
68       -info
69           output additional information about the PKCS#12 file structure,
70           algorithms used and iteration counts.
71
72       -des
73           use DES to encrypt private keys before outputting.
74
75       -des3
76           use triple DES to encrypt private keys before outputting, this is
77           the default.
78
79       -idea
80           use IDEA to encrypt private keys before outputting.
81
82       -aes128, -aes192, -aes256
83           use AES to encrypt private keys before outputting.
84
85       -camellia128, -camellia192, -camellia256
86           use Camellia to encrypt private keys before outputting.
87
88       -nodes
89           don't encrypt the private keys at all.
90
91       -nomacver
92           don't attempt to verify the integrity MAC before reading the file.
93
94       -twopass
95           prompt for separate integrity and encryption passwords: most
96           software always assumes these are the same so this option will
97           render such PKCS#12 files unreadable.
98

FILE CREATION OPTIONS

100       -export
101           This option specifies that a PKCS#12 file will be created rather
102           than parsed.
103
104       -out filename
105           This specifies filename to write the PKCS#12 file to. Standard
106           output is used by default.
107
108       -in filename
109           The filename to read certificates and private keys from, standard
110           input by default.  They must all be in PEM format. The order
111           doesn't matter but one private key and its corresponding
112           certificate should be present. If additional certificates are
113           present they will also be included in the PKCS#12 file.
114
115       -inkey filename
116           file to read private key from. If not present then a private key
117           must be present in the input file.
118
119       -name friendlyname
120           This specifies the "friendly name" for the certificate and private
121           key. This name is typically displayed in list boxes by software
122           importing the file.
123
124       -certfile filename
125           A filename to read additional certificates from.
126
127       -caname friendlyname
128           This specifies the "friendly name" for other certificates. This
129           option may be used multiple times to specify names for all
130           certificates in the order they appear. Netscape ignores friendly
131           names on other certificates whereas MSIE displays them.
132
133       -pass arg, -passout arg
134           the PKCS#12 file (i.e. output file) password source. For more
135           information about the format of arg see the PASS PHRASE ARGUMENTS
136           section in openssl(1).
137
138       -passin password
139           pass phrase source to decrypt any input private keys with. For more
140           information about the format of arg see the PASS PHRASE ARGUMENTS
141           section in openssl(1).
142
143       -chain
144           if this option is present then an attempt is made to include the
145           entire certificate chain of the user certificate. The standard CA
146           store is used for this search. If the search fails it is considered
147           a fatal error.
148
149       -descert
150           encrypt the certificate using triple DES, this may render the
151           PKCS#12 file unreadable by some "export grade" software. By default
152           the private key is encrypted using triple DES and the certificate
153           using 40 bit RC2.
154
155       -keypbe alg, -certpbe alg
156           these options allow the algorithm used to encrypt the private key
157           and certificates to be selected. Any PKCS#5 v1.5 or PKCS#12 PBE
158           algorithm name can be used (see NOTES section for more
159           information). If a cipher name (as output by the list-cipher-
160           algorithms command is specified then it is used with PKCS#5 v2.0.
161           For interoperability reasons it is advisable to only use PKCS#12
162           algorithms.
163
164       -keyex|-keysig
165           specifies that the private key is to be used for key exchange or
166           just signing.  This option is only interpreted by MSIE and similar
167           MS software. Normally "export grade" software will only allow 512
168           bit RSA keys to be used for encryption purposes but arbitrary
169           length keys for signing. The -keysig option marks the key for
170           signing only. Signing only keys can be used for S/MIME signing,
171           authenticode (ActiveX control signing)  and SSL client
172           authentication, however due to a bug only MSIE 5.0 and later
173           support the use of signing only keys for SSL client authentication.
174
175       -macalg digest
176           specify the MAC digest algorithm. If not included them SHA1 will be
177           used.
178
179       -nomaciter, -noiter
180           these options affect the iteration counts on the MAC and key
181           algorithms.  Unless you wish to produce files compatible with MSIE
182           4.0 you should leave these options alone.
183
184           To discourage attacks by using large dictionaries of common
185           passwords the algorithm that derives keys from passwords can have
186           an iteration count applied to it: this causes a certain part of the
187           algorithm to be repeated and slows it down. The MAC is used to
188           check the file integrity but since it will normally have the same
189           password as the keys and certificates it could also be attacked.
190           By default both MAC and encryption iteration counts are set to
191           2048, using these options the MAC and encryption iteration counts
192           can be set to 1, since this reduces the file security you should
193           not use these options unless you really have to. Most software
194           supports both MAC and key iteration counts.  MSIE 4.0 doesn't
195           support MAC iteration counts so it needs the -nomaciter option.
196
197       -maciter
198           This option is included for compatibility with previous versions,
199           it used to be needed to use MAC iterations counts but they are now
200           used by default.
201
202       -nomac
203           don't attempt to provide the MAC integrity.
204
205       -rand file(s)
206           a file or files containing random data used to seed the random
207           number generator, or an EGD socket (see RAND_egd(3)).  Multiple
208           files can be specified separated by a OS-dependent character.  The
209           separator is ; for MS-Windows, , for OpenVMS, and : for all others.
210
211       -CAfile file
212           CA storage as a file.
213
214       -CApath dir
215           CA storage as a directory. This directory must be a standard
216           certificate directory: that is a hash of each subject name (using
217           x509 -hash) should be linked to each certificate.
218
219       -CSP name
220           write name as a Microsoft CSP name.
221

NOTES

223       Although there are a large number of options most of them are very
224       rarely used. For PKCS#12 file parsing only -in and -out need to be used
225       for PKCS#12 file creation -export and -name are also used.
226
227       If none of the -clcerts, -cacerts or -nocerts options are present then
228       all certificates will be output in the order they appear in the input
229       PKCS#12 files. There is no guarantee that the first certificate present
230       is the one corresponding to the private key. Certain software which
231       requires a private key and certificate and assumes the first
232       certificate in the file is the one corresponding to the private key:
233       this may not always be the case. Using the -clcerts option will solve
234       this problem by only outputting the certificate corresponding to the
235       private key. If the CA certificates are required then they can be
236       output to a separate file using the -nokeys -cacerts options to just
237       output CA certificates.
238
239       The -keypbe and -certpbe algorithms allow the precise encryption
240       algorithms for private keys and certificates to be specified. Normally
241       the defaults are fine but occasionally software can't handle triple DES
242       encrypted private keys, then the option -keypbe PBE-SHA1-RC2-40 can be
243       used to reduce the private key encryption to 40 bit RC2. A complete
244       description of all algorithms is contained in the pkcs8 manual page.
245

EXAMPLES

247       Parse a PKCS#12 file and output it to a file:
248
249        openssl pkcs12 -in file.p12 -out file.pem
250
251       Output only client certificates to a file:
252
253        openssl pkcs12 -in file.p12 -clcerts -out file.pem
254
255       Don't encrypt the private key:
256
257        openssl pkcs12 -in file.p12 -out file.pem -nodes
258
259       Print some info about a PKCS#12 file:
260
261        openssl pkcs12 -in file.p12 -info -noout
262
263       Create a PKCS#12 file:
264
265        openssl pkcs12 -export -in file.pem -out file.p12 -name "My Certificate"
266
267       Include some extra certificates:
268
269        openssl pkcs12 -export -in file.pem -out file.p12 -name "My Certificate" \
270         -certfile othercerts.pem
271

BUGS

273       Some would argue that the PKCS#12 standard is one big bug :-)
274
275       Versions of OpenSSL before 0.9.6a had a bug in the PKCS#12 key
276       generation routines. Under rare circumstances this could produce a
277       PKCS#12 file encrypted with an invalid key. As a result some PKCS#12
278       files which triggered this bug from other implementations (MSIE or
279       Netscape) could not be decrypted by OpenSSL and similarly OpenSSL could
280       produce PKCS#12 files which could not be decrypted by other
281       implementations. The chances of producing such a file are relatively
282       small: less than 1 in 256.
283
284       A side effect of fixing this bug is that any old invalidly encrypted
285       PKCS#12 files cannot no longer be parsed by the fixed version. Under
286       such circumstances the pkcs12 utility will report that the MAC is OK
287       but fail with a decryption error when extracting private keys.
288
289       This problem can be resolved by extracting the private keys and
290       certificates from the PKCS#12 file using an older version of OpenSSL
291       and recreating the PKCS#12 file from the keys and certificates using a
292       newer version of OpenSSL. For example:
293
294        old-openssl -in bad.p12 -out keycerts.pem
295        openssl -in keycerts.pem -export -name "My PKCS#12 file" -out fixed.p12
296

SEE ALSO

298       pkcs8(1)
299
300
301
3021.0.2k                            2017-01-26                         PKCS12(1)
Impressum