Linux "pkcs12" Command Line Options and Examples
PKCS#12 file utility

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..


Usage:

openssl pkcs12 [-help] [-export] [-chain] [-inkey file_or_id] [-certfile filename] [-name name] [-caname name]
[-in filename] [-out filename] [-noout] [-nomacver] [-nocerts] [-clcerts] [-cacerts] [-nokeys] [-info] [-des |
-des3 | -idea | -aes128 | -aes192 | -aes256 | -camellia128 | -camellia192 | -camellia256 | -nodes] [-noiter]
[-maciter | -nomaciter | -nomac] [-twopass] [-descert] [-certpbe cipher] [-keypbe cipher] [-macalg digest]
[-keyex] [-keysig] [-password arg] [-passin arg] [-passout arg] [-rand file(s)] [-CAfile file] [-CApath dir]
[-no-CAfile] [-no-CApath] [-CSP name]




Command Line Options:

-help
Print out a usage message.
pkcs12 -help ...
-in
This specifies filename of the PKCS#12 file to be parsed. Standard input is used by default.
pkcs12 -in ...
-out
The filename to write certificates and private keys to, standard output by default. They are all writtenin PEM format.
pkcs12 -out ...
-passin
the PKCS#12 file (i.e. input file) password source. For more information about the format of arg see thePASS PHRASE ARGUMENTS section in openssl(1).
pkcs12 -passin ...
-passout
pass phrase source to encrypt any outputted private keys with. For more information about the format ofarg see the PASS PHRASE ARGUMENTS section in openssl(1).
pkcs12 -passout ...
-password
With -export, -password is equivalent to -passout. Otherwise, -password is equivalent to -passin.
pkcs12 -password ...
-noout
this option inhibits output of the keys and certificates to the output file version of the PKCS#12 file.
pkcs12 -noout ...
-clcerts
only output client certificates (not CA certificates).
pkcs12 -clcerts ...
-cacerts
only output CA certificates (not client certificates).
pkcs12 -cacerts ...
-nocerts
no certificates at all will be output.
pkcs12 -nocerts ...
-nokeys
no private keys will be output.
pkcs12 -nokeys ...
-info
output additional information about the PKCS#12 file structure, algorithms used and iteration counts.
pkcs12 -info ...
-des
use DES to encrypt private keys before outputting.
pkcs12 -des ...
-des3
use triple DES to encrypt private keys before outputting, this is the default.
pkcs12 -des3 ...
-idea
use IDEA to encrypt private keys before outputting.
pkcs12 -idea ...
-aes128
use AES to encrypt private keys before outputting.
pkcs12 -aes128 ...
-camellia128
use Camellia to encrypt private keys before outputting.
pkcs12 -camellia128 ...
-nodes
don't encrypt the private keys at all.
pkcs12 -nodes ...
-nomacver
don't attempt to verify the integrity MAC before reading the file.
pkcs12 -nomacver ...
-twopass
prompt for separate integrity and encryption passwords: most software always assumes these are the same sothis option will render such PKCS#12 files unreadable.FILE CREATION OPTIONS
pkcs12 -twopass ...
-export
This option specifies that a PKCS#12 file will be created rather than parsed.
pkcs12 -export ...
-inkey
file to read private key from. If not present then a private key must be present in the input file. If noengine is used, the argument is taken as a file; if an engine is specified, the argument is given to theengine as a key identifier.
pkcs12 -inkey ...
-name
This specifies the "friendly name" for the certificate and private key. This name is typically displayedin list boxes by software importing the file.
pkcs12 -name ...
-certfile
A filename to read additional certificates from.
pkcs12 -certfile ...
-caname
This specifies the "friendly name" for other certificates. This option may be used multiple times tospecify names for all certificates in the order they appear. Netscape ignores friendly names on othercertificates whereas MSIE displays them.
pkcs12 -caname ...
-pass
the PKCS#12 file (i.e. output file) password source. For more information about the format of arg see thePASS PHRASE ARGUMENTS section in openssl(1).
pkcs12 -pass ...
-chain
if this option is present then an attempt is made to include the entire certificate chain of the usercertificate. The standard CA store is used for this search. If the search fails it is considered a fatalerror.
pkcs12 -chain ...
-descert
encrypt the certificate using triple DES, this may render the PKCS#12 file unreadable by some "exportgrade" software. By default the private key is encrypted using triple DES and the certificate using 40 bitRC2.
pkcs12 -descert ...
-keypbe
these options allow the algorithm used to encrypt the private key and certificates to be selected. AnyPKCS#5 v1.5 or PKCS#12 PBE algorithm name can be used (see NOTES section for more information). If acipher name (as output by the list-cipher-algorithms command is specified then it is used with PKCS#5v2.0. For interoperability reasons it is advisable to only use PKCS#12 algorithms.
pkcs12 -keypbe ...
-keyex|-keysig
specifies that the private key is to be used for key exchange or just signing. This option is onlyinterpreted by MSIE and similar MS software. Normally "export grade" software will only allow 512 bit RSAkeys to be used for encryption purposes but arbitrary length keys for signing. The -keysig option marksthe key for signing only. Signing only keys can be used for S/MIME signing, authenticode (ActiveX controlsigning) and SSL client authentication, however due to a bug only MSIE 5.0 and later support the use ofsigning only keys for SSL client authentication.
pkcs12 -keyex|-keysig ...
-macalg
specify the MAC digest algorithm. If not included them SHA1 will be used.
pkcs12 -macalg ...
-nomaciter
these options affect the iteration counts on the MAC and key algorithms. Unless you wish to produce filescompatible with MSIE 4.0 you should leave these options alone.To discourage attacks by using large dictionaries of common passwords the algorithm that derives keys frompasswords can have an iteration count applied to it: this causes a certain part of the algorithm to berepeated and slows it down. The MAC is used to check the file integrity but since it will normally havethe same password as the keys and certificates it could also be attacked. By default both MAC andencryption iteration counts are set to 2048, using these options the MAC and encryption iteration countscan be set to 1, since this reduces the file security you should not use these options unless you reallyhave to. Most software supports both MAC and key iteration counts. MSIE 4.0 doesn't support MAC iterationcounts so it needs the -nomaciter option.
pkcs12 -nomaciter ...
-maciter
This option is included for compatibility with previous versions, it used to be needed to use MACiterations counts but they are now used by default.
pkcs12 -maciter ...
-nomac
don't attempt to provide the MAC integrity.
pkcs12 -nomac ...
-rand
a file or files containing random data used to seed the random number generator, or an EGD socket (seeRAND_egd(3)). Multiple files can be specified separated by an OS-dependent character. The separator is ;for MS-Windows, , for OpenVMS, and : for all others.
pkcs12 -rand ...
-CAfile
CA storage as a file.
pkcs12 -CAfile ...
-CApath
CA storage as a directory. This directory must be a standard certificate directory: that is a hash of eachsubject name (using x509 -hash) should be linked to each certificate.
pkcs12 -CApath ...
-no-CAfile
Do not load the trusted CA certificates from the default file location
pkcs12 -no-CAfile ...
-no-CApath
Do not load the trusted CA certificates from the default directory location
pkcs12 -no-CApath ...
-CSP
write name as a Microsoft CSP name.NOTESAlthough there are a large number of options most of them are very rarely used. For PKCS#12 file parsing only
pkcs12 -CSP ...