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. Cannot be used in combination
106 with the options -password, -passin (if importing) or -passout (if
107 exporting).
108
110 -export
111 This option specifies that a PKCS#12 file will be created rather
112 than parsed.
113
114 -out filename
115 This specifies filename to write the PKCS#12 file to. Standard
116 output is used by default.
117
118 -in filename
119 The filename to read certificates and private keys from, standard
120 input by default. They must all be in PEM format. The order
121 doesn't matter but one private key and its corresponding
122 certificate should be present. If additional certificates are
123 present they will also be included in the PKCS#12 file.
124
125 -inkey file_or_id
126 File to read private key from. If not present then a private key
127 must be present in the input file. If no engine is used, the
128 argument is taken as a file; if an engine is specified, the
129 argument is given to the engine as a key identifier.
130
131 -name friendlyname
132 This specifies the "friendly name" for the certificate and private
133 key. This name is typically displayed in list boxes by software
134 importing the file.
135
136 -certfile filename
137 A filename to read additional certificates from.
138
139 -caname friendlyname
140 This specifies the "friendly name" for other certificates. This
141 option may be used multiple times to specify names for all
142 certificates in the order they appear. Netscape ignores friendly
143 names on other certificates whereas MSIE displays them.
144
145 -pass arg, -passout arg
146 The PKCS#12 file (i.e. output file) password source. For more
147 information about the format of arg see the PASS PHRASE ARGUMENTS
148 section in openssl(1).
149
150 -passin password
151 Pass phrase source to decrypt any input private keys with. For more
152 information about the format of arg see the PASS PHRASE ARGUMENTS
153 section in openssl(1).
154
155 -chain
156 If this option is present then an attempt is made to include the
157 entire certificate chain of the user certificate. The standard CA
158 store is used for this search. If the search fails it is considered
159 a fatal error.
160
161 -descert
162 Encrypt the certificate using triple DES, this may render the
163 PKCS#12 file unreadable by some "export grade" software. By default
164 the private key is encrypted using triple DES and the certificate
165 using 40 bit RC2.
166
167 -keypbe alg, -certpbe alg
168 These options allow the algorithm used to encrypt the private key
169 and certificates to be selected. Any PKCS#5 v1.5 or PKCS#12 PBE
170 algorithm name can be used (see NOTES section for more
171 information). If a cipher name (as output by the list-cipher-
172 algorithms command is specified then it is used with PKCS#5 v2.0.
173 For interoperability reasons it is advisable to only use PKCS#12
174 algorithms.
175
176 -keyex|-keysig
177 Specifies that the private key is to be used for key exchange or
178 just signing. This option is only interpreted by MSIE and similar
179 MS software. Normally "export grade" software will only allow 512
180 bit RSA keys to be used for encryption purposes but arbitrary
181 length keys for signing. The -keysig option marks the key for
182 signing only. Signing only keys can be used for S/MIME signing,
183 authenticode (ActiveX control signing) and SSL client
184 authentication, however due to a bug only MSIE 5.0 and later
185 support the use of signing only keys for SSL client authentication.
186
187 -macalg digest
188 Specify the MAC digest algorithm. If not included them SHA1 will be
189 used.
190
191 -nomaciter, -noiter
192 These options affect the iteration counts on the MAC and key
193 algorithms. Unless you wish to produce files compatible with MSIE
194 4.0 you should leave these options alone.
195
196 To discourage attacks by using large dictionaries of common
197 passwords the algorithm that derives keys from passwords can have
198 an iteration count applied to it: this causes a certain part of the
199 algorithm to be repeated and slows it down. The MAC is used to
200 check the file integrity but since it will normally have the same
201 password as the keys and certificates it could also be attacked.
202 By default both MAC and encryption iteration counts are set to
203 2048, using these options the MAC and encryption iteration counts
204 can be set to 1, since this reduces the file security you should
205 not use these options unless you really have to. Most software
206 supports both MAC and key iteration counts. MSIE 4.0 doesn't
207 support MAC iteration counts so it needs the -nomaciter option.
208
209 -maciter
210 This option is included for compatibility with previous versions,
211 it used to be needed to use MAC iterations counts but they are now
212 used by default.
213
214 -nomac
215 Don't attempt to provide the MAC integrity.
216
217 -rand file...
218 A file or files containing random data used to seed the random
219 number generator. Multiple files can be specified separated by an
220 OS-dependent character. The separator is ; for MS-Windows, , for
221 OpenVMS, and : for all others.
222
223 [-writerand file]
224 Writes random data to the specified file upon exit. This can be
225 used with a subsequent -rand flag.
226
227 -CAfile file
228 CA storage as a file.
229
230 -CApath dir
231 CA storage as a directory. This directory must be a standard
232 certificate directory: that is a hash of each subject name (using
233 x509 -hash) should be linked to each certificate.
234
235 -no-CAfile
236 Do not load the trusted CA certificates from the default file
237 location.
238
239 -no-CApath
240 Do not load the trusted CA certificates from the default directory
241 location.
242
243 -CSP name
244 Write name as a Microsoft CSP name.
245
247 Although there are a large number of options most of them are very
248 rarely used. For PKCS#12 file parsing only -in and -out need to be used
249 for PKCS#12 file creation -export and -name are also used.
250
251 If none of the -clcerts, -cacerts or -nocerts options are present then
252 all certificates will be output in the order they appear in the input
253 PKCS#12 files. There is no guarantee that the first certificate present
254 is the one corresponding to the private key. Certain software which
255 requires a private key and certificate and assumes the first
256 certificate in the file is the one corresponding to the private key:
257 this may not always be the case. Using the -clcerts option will solve
258 this problem by only outputting the certificate corresponding to the
259 private key. If the CA certificates are required then they can be
260 output to a separate file using the -nokeys -cacerts options to just
261 output CA certificates.
262
263 The -keypbe and -certpbe algorithms allow the precise encryption
264 algorithms for private keys and certificates to be specified. Normally
265 the defaults are fine but occasionally software can't handle triple DES
266 encrypted private keys, then the option -keypbe PBE-SHA1-RC2-40 can be
267 used to reduce the private key encryption to 40 bit RC2. A complete
268 description of all algorithms is contained in the pkcs8 manual page.
269
270 Prior 1.1 release passwords containing non-ASCII characters were
271 encoded in non-compliant manner, which limited interoperability, in
272 first hand with Windows. But switching to standard-compliant password
273 encoding poses problem accessing old data protected with broken
274 encoding. For this reason even legacy encodings is attempted when
275 reading the data. If you use PKCS#12 files in production application
276 you are advised to convert the data, because implemented heuristic
277 approach is not MT-safe, its sole goal is to facilitate the data
278 upgrade with this utility.
279
281 Parse a PKCS#12 file and output it to a file:
282
283 openssl pkcs12 -in file.p12 -out file.pem
284
285 Output only client certificates to a file:
286
287 openssl pkcs12 -in file.p12 -clcerts -out file.pem
288
289 Don't encrypt the private key:
290
291 openssl pkcs12 -in file.p12 -out file.pem -nodes
292
293 Print some info about a PKCS#12 file:
294
295 openssl pkcs12 -in file.p12 -info -noout
296
297 Create a PKCS#12 file:
298
299 openssl pkcs12 -export -in file.pem -out file.p12 -name "My Certificate"
300
301 Include some extra certificates:
302
303 openssl pkcs12 -export -in file.pem -out file.p12 -name "My Certificate" \
304 -certfile othercerts.pem
305
307 pkcs8(1)
308
310 Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved.
311
312 Licensed under the OpenSSL license (the "License"). You may not use
313 this file except in compliance with the License. You can obtain a copy
314 in the file LICENSE in the source distribution or at
315 <https://www.openssl.org/source/license.html>.
316
317
318
3191.1.1c 2019-05-28 PKCS12(1)