1PKCS12(1) OpenSSL PKCS12(1)
2
3
4
6 openssl-pkcs12, pkcs12 - PKCS#12 file utility
7
9 openssl pkcs12 [-help] [-export] [-chain] [-inkey file_or_id]
10 [-certfile filename] [-name name] [-caname name] [-in filename] [-out
11 filename] [-noout] [-nomacver] [-nocerts] [-clcerts] [-cacerts]
12 [-nokeys] [-info] [-des | -des3 | -idea | -aes128 | -aes192 | -aes256 |
13 -aria128 | -aria192 | -aria256 | -camellia128 | -camellia192 |
14 -camellia256 | -nodes] [-noiter] [-maciter | -nomaciter | -nomac]
15 [-twopass] [-descert] [-certpbe cipher] [-keypbe cipher] [-macalg
16 digest] [-keyex] [-keysig] [-password arg] [-passin arg] [-passout arg]
17 [-rand file...] [-writerand file] [-CAfile file] [-CApath dir]
18 [-no-CAfile] [-no-CApath] [-CSP name]
19
21 The pkcs12 command allows PKCS#12 files (sometimes referred to as PFX
22 files) to be created and parsed. PKCS#12 files are used by several
23 programs including Netscape, MSIE and MS Outlook.
24
26 There are a lot of options the meaning of some depends of whether a
27 PKCS#12 file is being created or parsed. By default a PKCS#12 file is
28 parsed. A PKCS#12 file can be created by using the -export option (see
29 below).
30
32 -help
33 Print out a usage message.
34
35 -in filename
36 This specifies filename of the PKCS#12 file to be parsed. Standard
37 input is used by default.
38
39 -out filename
40 The filename to write certificates and private keys to, standard
41 output by default. They are all written in PEM format.
42
43 -passin arg
44 The PKCS#12 file (i.e. input file) password source. For more
45 information about the format of arg see the PASS PHRASE ARGUMENTS
46 section in openssl(1).
47
48 -passout arg
49 Pass phrase source to encrypt any outputted private keys with. For
50 more information about the format of arg see the PASS PHRASE
51 ARGUMENTS section in openssl(1).
52
53 -password arg
54 With -export, -password is equivalent to -passout. Otherwise,
55 -password is equivalent to -passin.
56
57 -noout
58 This option inhibits output of the keys and certificates to the
59 output file version of the PKCS#12 file.
60
61 -clcerts
62 Only output client certificates (not CA certificates).
63
64 -cacerts
65 Only output CA certificates (not client certificates).
66
67 -nocerts
68 No certificates at all will be output.
69
70 -nokeys
71 No private keys will be output.
72
73 -info
74 Output additional information about the PKCS#12 file structure,
75 algorithms used and iteration counts.
76
77 -des
78 Use DES to encrypt private keys before outputting.
79
80 -des3
81 Use triple DES to encrypt private keys before outputting, this is
82 the default.
83
84 -idea
85 Use IDEA to encrypt private keys before outputting.
86
87 -aes128, -aes192, -aes256
88 Use AES to encrypt private keys before outputting.
89
90 -aria128, -aria192, -aria256
91 Use ARIA to encrypt private keys before outputting.
92
93 -camellia128, -camellia192, -camellia256
94 Use Camellia to encrypt private keys before outputting.
95
96 -nodes
97 Don't encrypt the private keys at all.
98
99 -nomacver
100 Don't attempt to verify the integrity MAC before reading the file.
101
102 -twopass
103 Prompt for separate integrity and encryption passwords: most
104 software always assumes these are the same so this option will
105 render such PKCS#12 files unreadable.
106
108 -export
109 This option specifies that a PKCS#12 file will be created rather
110 than parsed.
111
112 -out filename
113 This specifies filename to write the PKCS#12 file to. Standard
114 output is used by default.
115
116 -in filename
117 The filename to read certificates and private keys from, standard
118 input by default. They must all be in PEM format. The order
119 doesn't matter but one private key and its corresponding
120 certificate should be present. If additional certificates are
121 present they will also be included in the PKCS#12 file.
122
123 -inkey file_or_id
124 File to read private key from. If not present then a private key
125 must be present in the input file. If no engine is used, the
126 argument is taken as a file; if an engine is specified, the
127 argument is given to the engine as a key identifier.
128
129 -name friendlyname
130 This specifies the "friendly name" for the certificate and private
131 key. This name is typically displayed in list boxes by software
132 importing the file.
133
134 -certfile filename
135 A filename to read additional certificates from.
136
137 -caname friendlyname
138 This specifies the "friendly name" for other certificates. This
139 option may be used multiple times to specify names for all
140 certificates in the order they appear. Netscape ignores friendly
141 names on other certificates whereas MSIE displays them.
142
143 -pass arg, -passout arg
144 The PKCS#12 file (i.e. output file) password source. For more
145 information about the format of arg see the PASS PHRASE ARGUMENTS
146 section in openssl(1).
147
148 -passin password
149 Pass phrase source to decrypt any input private keys with. For more
150 information about the format of arg see the PASS PHRASE ARGUMENTS
151 section in openssl(1).
152
153 -chain
154 If this option is present then an attempt is made to include the
155 entire certificate chain of the user certificate. The standard CA
156 store is used for this search. If the search fails it is considered
157 a fatal error.
158
159 -descert
160 Encrypt the certificate using triple DES, this may render the
161 PKCS#12 file unreadable by some "export grade" software. By default
162 the private key is encrypted using triple DES and the certificate
163 using 40 bit RC2.
164
165 -keypbe alg, -certpbe alg
166 These options allow the algorithm used to encrypt the private key
167 and certificates to be selected. Any PKCS#5 v1.5 or PKCS#12 PBE
168 algorithm name can be used (see NOTES section for more
169 information). If a cipher name (as output by the list-cipher-
170 algorithms command is specified then it is used with PKCS#5 v2.0.
171 For interoperability reasons it is advisable to only use PKCS#12
172 algorithms.
173
174 -keyex|-keysig
175 Specifies that the private key is to be used for key exchange or
176 just signing. This option is only interpreted by MSIE and similar
177 MS software. Normally "export grade" software will only allow 512
178 bit RSA keys to be used for encryption purposes but arbitrary
179 length keys for signing. The -keysig option marks the key for
180 signing only. Signing only keys can be used for S/MIME signing,
181 authenticode (ActiveX control signing) and SSL client
182 authentication, however due to a bug only MSIE 5.0 and later
183 support the use of signing only keys for SSL client authentication.
184
185 -macalg digest
186 Specify the MAC digest algorithm. If not included them SHA1 will be
187 used.
188
189 -nomaciter, -noiter
190 These options affect the iteration counts on the MAC and key
191 algorithms. Unless you wish to produce files compatible with MSIE
192 4.0 you should leave these options alone.
193
194 To discourage attacks by using large dictionaries of common
195 passwords the algorithm that derives keys from passwords can have
196 an iteration count applied to it: this causes a certain part of the
197 algorithm to be repeated and slows it down. The MAC is used to
198 check the file integrity but since it will normally have the same
199 password as the keys and certificates it could also be attacked.
200 By default both MAC and encryption iteration counts are set to
201 2048, using these options the MAC and encryption iteration counts
202 can be set to 1, since this reduces the file security you should
203 not use these options unless you really have to. Most software
204 supports both MAC and key iteration counts. MSIE 4.0 doesn't
205 support MAC iteration counts so it needs the -nomaciter option.
206
207 -maciter
208 This option is included for compatibility with previous versions,
209 it used to be needed to use MAC iterations counts but they are now
210 used by default.
211
212 -nomac
213 Don't attempt to provide the MAC integrity.
214
215 -rand file...
216 A file or files containing random data used to seed the random
217 number generator. Multiple files can be specified separated by an
218 OS-dependent character. The separator is ; for MS-Windows, , for
219 OpenVMS, and : for all others.
220
221 [-writerand file]
222 Writes random data to the specified file upon exit. This can be
223 used with a subsequent -rand flag.
224
225 -CAfile file
226 CA storage as a file.
227
228 -CApath dir
229 CA storage as a directory. This directory must be a standard
230 certificate directory: that is a hash of each subject name (using
231 x509 -hash) should be linked to each certificate.
232
233 -no-CAfile
234 Do not load the trusted CA certificates from the default file
235 location.
236
237 -no-CApath
238 Do not load the trusted CA certificates from the default directory
239 location.
240
241 -CSP name
242 Write name as a Microsoft CSP name.
243
245 Although there are a large number of options most of them are very
246 rarely used. For PKCS#12 file parsing only -in and -out need to be used
247 for PKCS#12 file creation -export and -name are also used.
248
249 If none of the -clcerts, -cacerts or -nocerts options are present then
250 all certificates will be output in the order they appear in the input
251 PKCS#12 files. There is no guarantee that the first certificate present
252 is the one corresponding to the private key. Certain software which
253 requires a private key and certificate and assumes the first
254 certificate in the file is the one corresponding to the private key:
255 this may not always be the case. Using the -clcerts option will solve
256 this problem by only outputting the certificate corresponding to the
257 private key. If the CA certificates are required then they can be
258 output to a separate file using the -nokeys -cacerts options to just
259 output CA certificates.
260
261 The -keypbe and -certpbe algorithms allow the precise encryption
262 algorithms for private keys and certificates to be specified. Normally
263 the defaults are fine but occasionally software can't handle triple DES
264 encrypted private keys, then the option -keypbe PBE-SHA1-RC2-40 can be
265 used to reduce the private key encryption to 40 bit RC2. A complete
266 description of all algorithms is contained in the pkcs8 manual page.
267
268 Prior 1.1 release passwords containing non-ASCII characters were
269 encoded in non-compliant manner, which limited interoperability, in
270 first hand with Windows. But switching to standard-compliant password
271 encoding poses problem accessing old data protected with broken
272 encoding. For this reason even legacy encodings is attempted when
273 reading the data. If you use PKCS#12 files in production application
274 you are advised to convert the data, because implemented heuristic
275 approach is not MT-safe, its sole goal is to facilitate the data
276 upgrade with this utility.
277
279 Parse a PKCS#12 file and output it to a file:
280
281 openssl pkcs12 -in file.p12 -out file.pem
282
283 Output only client certificates to a file:
284
285 openssl pkcs12 -in file.p12 -clcerts -out file.pem
286
287 Don't encrypt the private key:
288
289 openssl pkcs12 -in file.p12 -out file.pem -nodes
290
291 Print some info about a PKCS#12 file:
292
293 openssl pkcs12 -in file.p12 -info -noout
294
295 Create a PKCS#12 file:
296
297 openssl pkcs12 -export -in file.pem -out file.p12 -name "My Certificate"
298
299 Include some extra certificates:
300
301 openssl pkcs12 -export -in file.pem -out file.p12 -name "My Certificate" \
302 -certfile othercerts.pem
303
305 pkcs8(1)
306
308 Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved.
309
310 Licensed under the OpenSSL license (the "License"). You may not use
311 this file except in compliance with the License. You can obtain a copy
312 in the file LICENSE in the source distribution or at
313 <https://www.openssl.org/source/license.html>.
314
315
316
3171.1.1 2018-09-11 PKCS12(1)