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 "Pass Phrase Options" in
46 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 "Pass Phrase Options"
51 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 "Pass Phrase Options" in
148 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 "Pass Phrase Options" in
153 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 unless RC2 is disabled in which case triple DES is
166 used.
167
168 -keypbe alg, -certpbe alg
169 These options allow the algorithm used to encrypt the private key
170 and certificates to be selected. Any PKCS#5 v1.5 or PKCS#12 PBE
171 algorithm name can be used (see NOTES section for more
172 information). If a cipher name (as output by the list-cipher-
173 algorithms command is specified then it is used with PKCS#5 v2.0.
174 For interoperability reasons it is advisable to only use PKCS#12
175 algorithms.
176
177 -keyex|-keysig
178 Specifies that the private key is to be used for key exchange or
179 just signing. This option is only interpreted by MSIE and similar
180 MS software. Normally "export grade" software will only allow 512
181 bit RSA keys to be used for encryption purposes but arbitrary
182 length keys for signing. The -keysig option marks the key for
183 signing only. Signing only keys can be used for S/MIME signing,
184 authenticode (ActiveX control signing) and SSL client
185 authentication, however, due to a bug only MSIE 5.0 and later
186 support the use of signing only keys for SSL client authentication.
187
188 -macalg digest
189 Specify the MAC digest algorithm. If not included them SHA1 will be
190 used.
191
192 -nomaciter, -noiter
193 These options affect the iteration counts on the MAC and key
194 algorithms. Unless you wish to produce files compatible with MSIE
195 4.0 you should leave these options alone.
196
197 To discourage attacks by using large dictionaries of common
198 passwords the algorithm that derives keys from passwords can have
199 an iteration count applied to it: this causes a certain part of the
200 algorithm to be repeated and slows it down. The MAC is used to
201 check the file integrity but since it will normally have the same
202 password as the keys and certificates it could also be attacked.
203 By default both MAC and encryption iteration counts are set to
204 2048, using these options the MAC and encryption iteration counts
205 can be set to 1, since this reduces the file security you should
206 not use these options unless you really have to. Most software
207 supports both MAC and key iteration counts. MSIE 4.0 doesn't
208 support MAC iteration counts so it needs the -nomaciter option.
209
210 -maciter
211 This option is included for compatibility with previous versions,
212 it used to be needed to use MAC iterations counts but they are now
213 used by default.
214
215 -nomac
216 Don't attempt to provide the MAC integrity.
217
218 -rand file...
219 A file or files containing random data used to seed the random
220 number generator. Multiple files can be specified separated by an
221 OS-dependent character. The separator is ; for MS-Windows, , for
222 OpenVMS, and : for all others.
223
224 [-writerand file]
225 Writes random data to the specified file upon exit. This can be
226 used with a subsequent -rand flag.
227
228 -CAfile file
229 CA storage as a file.
230
231 -CApath dir
232 CA storage as a directory. This directory must be a standard
233 certificate directory: that is a hash of each subject name (using
234 x509 -hash) should be linked to each certificate.
235
236 -no-CAfile
237 Do not load the trusted CA certificates from the default file
238 location.
239
240 -no-CApath
241 Do not load the trusted CA certificates from the default directory
242 location.
243
244 -CSP name
245 Write name as a Microsoft CSP name.
246
248 Although there are a large number of options most of them are very
249 rarely used. For PKCS#12 file parsing only -in and -out need to be used
250 for PKCS#12 file creation -export and -name are also used.
251
252 If none of the -clcerts, -cacerts or -nocerts options are present then
253 all certificates will be output in the order they appear in the input
254 PKCS#12 files. There is no guarantee that the first certificate present
255 is the one corresponding to the private key. Certain software which
256 requires a private key and certificate and assumes the first
257 certificate in the file is the one corresponding to the private key:
258 this may not always be the case. Using the -clcerts option will solve
259 this problem by only outputting the certificate corresponding to the
260 private key. If the CA certificates are required then they can be
261 output to a separate file using the -nokeys -cacerts options to just
262 output CA certificates.
263
264 The -keypbe and -certpbe algorithms allow the precise encryption
265 algorithms for private keys and certificates to be specified. Normally
266 the defaults are fine but occasionally software can't handle triple DES
267 encrypted private keys, then the option -keypbe PBE-SHA1-RC2-40 can be
268 used to reduce the private key encryption to 40 bit RC2. A complete
269 description of all algorithms is contained in the pkcs8 manual page.
270
271 Prior 1.1 release passwords containing non-ASCII characters were
272 encoded in non-compliant manner, which limited interoperability, in
273 first hand with Windows. But switching to standard-compliant password
274 encoding poses problem accessing old data protected with broken
275 encoding. For this reason even legacy encodings is attempted when
276 reading the data. If you use PKCS#12 files in production application
277 you are advised to convert the data, because implemented heuristic
278 approach is not MT-safe, its sole goal is to facilitate the data
279 upgrade with this utility.
280
282 Parse a PKCS#12 file and output it to a file:
283
284 openssl pkcs12 -in file.p12 -out file.pem
285
286 Output only client certificates to a file:
287
288 openssl pkcs12 -in file.p12 -clcerts -out file.pem
289
290 Don't encrypt the private key:
291
292 openssl pkcs12 -in file.p12 -out file.pem -nodes
293
294 Print some info about a PKCS#12 file:
295
296 openssl pkcs12 -in file.p12 -info -noout
297
298 Create a PKCS#12 file:
299
300 openssl pkcs12 -export -in file.pem -out file.p12 -name "My Certificate"
301
302 Include some extra certificates:
303
304 openssl pkcs12 -export -in file.pem -out file.p12 -name "My Certificate" \
305 -certfile othercerts.pem
306
308 pkcs8(1)
309
311 Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
312
313 Licensed under the OpenSSL license (the "License"). You may not use
314 this file except in compliance with the License. You can obtain a copy
315 in the file LICENSE in the source distribution or at
316 <https://www.openssl.org/source/license.html>.
317
318
319
3201.1.1k 2021-03-26 PKCS12(1)