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       -pass arg, -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 outputed private keys with. For
45           more information about the format of arg see the PASS PHRASE
46           ARGUMENTS section in openssl(1).
47
48       -noout
49           this option inhibits output of the keys and certificates to the
50           output file version of the PKCS#12 file.
51
52       -clcerts
53           only output client certificates (not CA certificates).
54
55       -cacerts
56           only output CA certificates (not client certificates).
57
58       -nocerts
59           no certificates at all will be output.
60
61       -nokeys
62           no private keys will be output.
63
64       -info
65           output additional information about the PKCS#12 file structure,
66           algorithms used and iteration counts.
67
68       -des
69           use DES to encrypt private keys before outputting.
70
71       -des3
72           use triple DES to encrypt private keys before outputting, this is
73           the default.
74
75       -idea
76           use IDEA to encrypt private keys before outputting.
77
78       -aes128, -aes192, -aes256
79           use AES to encrypt private keys before outputting.
80
81       -camellia128, -camellia192, -camellia256
82           use Camellia to encrypt private keys before outputting.
83
84       -nodes
85           don't encrypt the private keys at all.
86
87       -nomacver
88           don't attempt to verify the integrity MAC before reading the file.
89
90       -twopass
91           prompt for separate integrity and encryption passwords: most
92           software always assumes these are the same so this option will
93           render such PKCS#12 files unreadable.
94

FILE CREATION OPTIONS

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

NOTES

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

EXAMPLES

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

BUGS

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

SEE ALSO

294       pkcs8(1)
295
296
297
2981.0.1e                            2013-02-11                         PKCS12(1)
Impressum