skip book previous and next navigation links
go up to top of book: HP Open Source Security for OpenVMS Volume 2:... HP Open Source Security for OpenVMS Volume 2:...
go to beginning of reference: OpenSSL Command Line Interface (CLI) Reference OpenSSL Command Line Interface (CLI) Reference
go to previous page: passwd passwd
go to next page: pkcs7pkcs7
end of book navigation links


pkcs12
Description
Parsing Options
Notes
Restrictions
 Command Options
File Creation Options
Examples
See Also

NAME

pkcs12 - PKCS#12 file utility

Synopsis  

openssl pkcs12 [-export] [-chain] [-inkey filename] [-certfile filename] [-name name] [-caname name] [-in filename] [-out filename] [-noout] [-nomacver] [-nocerts] [-clcerts] [-cacerts] [-nokeys] [-info] [-des] [-des3] [-idea] [-nodes] [-noiter] [-maciter] [-twopass] [-descert] [-certpbe] [-keypbe] [-keyex] [-keysig] [-password arg] [-passin arg] [-passout arg] [-rand file(s)]


return to top DESCRIPTION  

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


return to top COMMAND OPTIONS  

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


return to top PARSING OPTIONS  


return to top FILE CREATION OPTIONS  


return to top NOTES  

Although there are a large number of options most of them are very rarely used. For PKCS#12 file parsing only -in and -out need to be used for PKCS#12 file creation -export and -name are also used.

If none of the -clcerts, -cacerts or -nocerts options are present then all certificates will be output in the order they appear in the input PKCS#12 files. There is no guarantee that the first certificate present is the one corresponding to the private key. Certain software which requires a private key and certificate and assumes the first certificate in the file is the one corresponding to the private key: this may not always be the case. Using the -clcerts option will solve this problem by only outputting the certificate corresponding to the private key. If the CA certificates are required then they can be output to a separate file using the -nokeys -cacerts options to just output CA certificates.

The -keypbe and -certpbe algorithms allow the precise encryption algorithms for private keys and certificates to be specified. Normally the defaults are fine but occasionally software can't handle triple DES encrypted private keys, then the option -keypbe PBE-SHA1-RC2-40 can be used to reduce the private key encryption to 40 bit RC2. A complete description of all algorithms is contained in the pkcs8 manual page.


return to top EXAMPLES  

Parse a PKCS#12 file and output it to a file:
 openssl pkcs12 -in file.p12 -out file.pem
Output only client certificates to a file:
 openssl pkcs12 -in file.p12 -clcerts -out file.pem
Don't encrypt the private key: openssl pkcs12 -in file.p12 -out file.pem -nodes

Print some info about a PKCS#12 file:

 openssl pkcs12 -in file.p12 -info -noout
Create a PKCS#12 file:
 openssl pkcs12 -export -in file.pem -out file.p12 -name "My Certificate"
Include some extra certificates:
 openssl pkcs12 -export -in file.pem -out file.p12 -name "My Certificate" \
  -certfile othercerts.pem


return to top Restrictions  

Some would argue that the PKCS#12 standard is one big bug :-)

Versions of OpenSSL before 0.9.6a had a bug in the PKCS#12 key generation routines. Under rare circumstances this could produce a PKCS#12 file encrypted with an invalid key. As a result some PKCS#12 files which triggered this bug from other implementations (MSIE or Netscape) could not be decrypted by OpenSSL and similarly OpenSSL could produce PKCS#12 files which could not be decrypted by other implementations. The chances of producing such a file are relatively small: less than 1 in 256.

A side effect of fixing this bug is that any old invalidly encrypted PKCS#12 files cannot no longer be parsed by the fixed version. Under such circumstances the pkcs12 utility will report that the MAC is OK but fail with a decryption error when extracting private keys.

This problem can be resolved by extracting the private keys and certificates from the PKCS#12 file using an older version of OpenSSL and recreating the PKCS#12 file from the keys and certificates using a newer version of OpenSSL. For example:

 old-openssl -in bad.p12 -out keycerts.pem
 openssl -in keycerts.pem -export -name "My PKCS#12 file" -out fixed.p12


return to top SEE ALSO  

pkcs8(1)
go to previous page: passwd passwd
go to next page: pkcs7pkcs7