Blame doc/man1/pkcs12.pod

Packit c4476c
=pod
Packit c4476c
Packit c4476c
=head1 NAME
Packit c4476c
Packit c4476c
openssl-pkcs12,
Packit c4476c
pkcs12 - PKCS#12 file utility
Packit c4476c
Packit c4476c
=head1 SYNOPSIS
Packit c4476c
Packit c4476c
B<openssl> B<pkcs12>
Packit c4476c
[B<-help>]
Packit c4476c
[B<-export>]
Packit c4476c
[B<-chain>]
Packit c4476c
[B<-inkey file_or_id>]
Packit c4476c
[B<-certfile filename>]
Packit c4476c
[B<-name name>]
Packit c4476c
[B<-caname name>]
Packit c4476c
[B<-in filename>]
Packit c4476c
[B<-out filename>]
Packit c4476c
[B<-noout>]
Packit c4476c
[B<-nomacver>]
Packit c4476c
[B<-nocerts>]
Packit c4476c
[B<-clcerts>]
Packit c4476c
[B<-cacerts>]
Packit c4476c
[B<-nokeys>]
Packit c4476c
[B<-info>]
Packit c4476c
[B<-des | -des3 | -idea | -aes128 | -aes192 | -aes256 | -aria128 | -aria192 | -aria256 | -camellia128 | -camellia192 | -camellia256 | -nodes>]
Packit c4476c
[B<-noiter>]
Packit c4476c
[B<-maciter | -nomaciter | -nomac>]
Packit c4476c
[B<-twopass>]
Packit c4476c
[B<-descert>]
Packit c4476c
[B<-certpbe cipher>]
Packit c4476c
[B<-keypbe cipher>]
Packit c4476c
[B<-macalg digest>]
Packit c4476c
[B<-keyex>]
Packit c4476c
[B<-keysig>]
Packit c4476c
[B<-password arg>]
Packit c4476c
[B<-passin arg>]
Packit c4476c
[B<-passout arg>]
Packit c4476c
[B<-rand file...>]
Packit c4476c
[B<-writerand file>]
Packit c4476c
[B<-CAfile file>]
Packit c4476c
[B<-CApath dir>]
Packit c4476c
[B<-no-CAfile>]
Packit c4476c
[B<-no-CApath>]
Packit c4476c
[B<-CSP name>]
Packit c4476c
Packit c4476c
=head1 DESCRIPTION
Packit c4476c
Packit c4476c
The B<pkcs12> command allows PKCS#12 files (sometimes referred to as
Packit c4476c
PFX files) to be created and parsed. PKCS#12 files are used by several
Packit c4476c
programs including Netscape, MSIE and MS Outlook.
Packit c4476c
Packit c4476c
=head1 OPTIONS
Packit c4476c
Packit c4476c
There are a lot of options the meaning of some depends of whether a PKCS#12 file
Packit c4476c
is being created or parsed. By default a PKCS#12 file is parsed. A PKCS#12
Packit c4476c
file can be created by using the B<-export> option (see below).
Packit c4476c
Packit c4476c
=head1 PARSING OPTIONS
Packit c4476c
Packit c4476c
=over 4
Packit c4476c
Packit c4476c
=item B<-help>
Packit c4476c
Packit c4476c
Print out a usage message.
Packit c4476c
Packit c4476c
=item B<-in filename>
Packit c4476c
Packit c4476c
This specifies filename of the PKCS#12 file to be parsed. Standard input is used
Packit c4476c
by default.
Packit c4476c
Packit c4476c
=item B<-out filename>
Packit c4476c
Packit c4476c
The filename to write certificates and private keys to, standard output by
Packit c4476c
default.  They are all written in PEM format.
Packit c4476c
Packit c4476c
=item B<-passin arg>
Packit c4476c
Packit c4476c
The PKCS#12 file (i.e. input file) password source. For more information about
Packit c4476c
the format of B<arg> see the B<PASS PHRASE ARGUMENTS> section in
Packit c4476c
L<openssl(1)>.
Packit c4476c
Packit c4476c
=item B<-passout arg>
Packit c4476c
Packit c4476c
Pass phrase source to encrypt any outputted private keys with. For more
Packit c4476c
information about the format of B<arg> see the B<PASS PHRASE ARGUMENTS> section
Packit c4476c
in L<openssl(1)>.
Packit c4476c
Packit c4476c
=item B<-password arg>
Packit c4476c
Packit c4476c
With -export, -password is equivalent to -passout.
Packit c4476c
Otherwise, -password is equivalent to -passin.
Packit c4476c
Packit c4476c
=item B<-noout>
Packit c4476c
Packit c4476c
This option inhibits output of the keys and certificates to the output file
Packit c4476c
version of the PKCS#12 file.
Packit c4476c
Packit c4476c
=item B<-clcerts>
Packit c4476c
Packit c4476c
Only output client certificates (not CA certificates).
Packit c4476c
Packit c4476c
=item B<-cacerts>
Packit c4476c
Packit c4476c
Only output CA certificates (not client certificates).
Packit c4476c
Packit c4476c
=item B<-nocerts>
Packit c4476c
Packit c4476c
No certificates at all will be output.
Packit c4476c
Packit c4476c
=item B<-nokeys>
Packit c4476c
Packit c4476c
No private keys will be output.
Packit c4476c
Packit c4476c
=item B<-info>
Packit c4476c
Packit c4476c
Output additional information about the PKCS#12 file structure, algorithms
Packit c4476c
used and iteration counts.
Packit c4476c
Packit c4476c
=item B<-des>
Packit c4476c
Packit c4476c
Use DES to encrypt private keys before outputting.
Packit c4476c
Packit c4476c
=item B<-des3>
Packit c4476c
Packit c4476c
Use triple DES to encrypt private keys before outputting, this is the default.
Packit c4476c
Packit c4476c
=item B<-idea>
Packit c4476c
Packit c4476c
Use IDEA to encrypt private keys before outputting.
Packit c4476c
Packit c4476c
=item B<-aes128>, B<-aes192>, B<-aes256>
Packit c4476c
Packit c4476c
Use AES to encrypt private keys before outputting.
Packit c4476c
Packit c4476c
=item B<-aria128>, B<-aria192>, B<-aria256>
Packit c4476c
Packit c4476c
Use ARIA to encrypt private keys before outputting.
Packit c4476c
Packit c4476c
=item B<-camellia128>, B<-camellia192>, B<-camellia256>
Packit c4476c
Packit c4476c
Use Camellia to encrypt private keys before outputting.
Packit c4476c
Packit c4476c
=item B<-nodes>
Packit c4476c
Packit c4476c
Don't encrypt the private keys at all.
Packit c4476c
Packit c4476c
=item B<-nomacver>
Packit c4476c
Packit c4476c
Don't attempt to verify the integrity MAC before reading the file.
Packit c4476c
Packit c4476c
=item B<-twopass>
Packit c4476c
Packit c4476c
Prompt for separate integrity and encryption passwords: most software
Packit c4476c
always assumes these are the same so this option will render such
Packit c4476c
PKCS#12 files unreadable. Cannot be used in combination with the options
Packit c4476c
-password, -passin (if importing) or -passout (if exporting).
Packit c4476c
Packit c4476c
=back
Packit c4476c
Packit c4476c
=head1 FILE CREATION OPTIONS
Packit c4476c
Packit c4476c
=over 4
Packit c4476c
Packit c4476c
=item B<-export>
Packit c4476c
Packit c4476c
This option specifies that a PKCS#12 file will be created rather than
Packit c4476c
parsed.
Packit c4476c
Packit c4476c
=item B<-out filename>
Packit c4476c
Packit c4476c
This specifies filename to write the PKCS#12 file to. Standard output is used
Packit c4476c
by default.
Packit c4476c
Packit c4476c
=item B<-in filename>
Packit c4476c
Packit c4476c
The filename to read certificates and private keys from, standard input by
Packit c4476c
default.  They must all be in PEM format. The order doesn't matter but one
Packit c4476c
private key and its corresponding certificate should be present. If additional
Packit c4476c
certificates are present they will also be included in the PKCS#12 file.
Packit c4476c
Packit c4476c
=item B<-inkey file_or_id>
Packit c4476c
Packit c4476c
File to read private key from. If not present then a private key must be present
Packit c4476c
in the input file.
Packit c4476c
If no engine is used, the argument is taken as a file; if an engine is
Packit c4476c
specified, the argument is given to the engine as a key identifier.
Packit c4476c
Packit c4476c
=item B<-name friendlyname>
Packit c4476c
Packit c4476c
This specifies the "friendly name" for the certificate and private key. This
Packit c4476c
name is typically displayed in list boxes by software importing the file.
Packit c4476c
Packit c4476c
=item B<-certfile filename>
Packit c4476c
Packit c4476c
A filename to read additional certificates from.
Packit c4476c
Packit c4476c
=item B<-caname friendlyname>
Packit c4476c
Packit c4476c
This specifies the "friendly name" for other certificates. This option may be
Packit c4476c
used multiple times to specify names for all certificates in the order they
Packit c4476c
appear. Netscape ignores friendly names on other certificates whereas MSIE
Packit c4476c
displays them.
Packit c4476c
Packit c4476c
=item B<-pass arg>, B<-passout arg>
Packit c4476c
Packit c4476c
The PKCS#12 file (i.e. output file) password source. For more information about
Packit c4476c
the format of B<arg> see the B<PASS PHRASE ARGUMENTS> section in
Packit c4476c
L<openssl(1)>.
Packit c4476c
Packit c4476c
=item B<-passin password>
Packit c4476c
Packit c4476c
Pass phrase source to decrypt any input private keys with. For more information
Packit c4476c
about the format of B<arg> see the B<PASS PHRASE ARGUMENTS> section in
Packit c4476c
L<openssl(1)>.
Packit c4476c
Packit c4476c
=item B<-chain>
Packit c4476c
Packit c4476c
If this option is present then an attempt is made to include the entire
Packit c4476c
certificate chain of the user certificate. The standard CA store is used
Packit c4476c
for this search. If the search fails it is considered a fatal error.
Packit c4476c
Packit c4476c
=item B<-descert>
Packit c4476c
Packit c4476c
Encrypt the certificate using triple DES, this may render the PKCS#12
Packit c4476c
file unreadable by some "export grade" software. By default the private
Packit c4476c
key is encrypted using triple DES and the certificate using 40 bit RC2
Packit c4476c
unless RC2 is disabled in which case triple DES is used.
Packit c4476c
Packit c4476c
=item B<-keypbe alg>, B<-certpbe alg>
Packit c4476c
Packit c4476c
These options allow the algorithm used to encrypt the private key and
Packit c4476c
certificates to be selected. Any PKCS#5 v1.5 or PKCS#12 PBE algorithm name
Packit c4476c
can be used (see B<NOTES> section for more information). If a cipher name
Packit c4476c
(as output by the B<list-cipher-algorithms> command is specified then it
Packit c4476c
is used with PKCS#5 v2.0. For interoperability reasons it is advisable to only
Packit c4476c
use PKCS#12 algorithms.
Packit c4476c
Packit c4476c
=item B<-keyex|-keysig>
Packit c4476c
Packit c4476c
Specifies that the private key is to be used for key exchange or just signing.
Packit c4476c
This option is only interpreted by MSIE and similar MS software. Normally
Packit c4476c
"export grade" software will only allow 512 bit RSA keys to be used for
Packit c4476c
encryption purposes but arbitrary length keys for signing. The B<-keysig>
Packit c4476c
option marks the key for signing only. Signing only keys can be used for
Packit c4476c
S/MIME signing, authenticode (ActiveX control signing)  and SSL client
Packit c4476c
authentication, however due to a bug only MSIE 5.0 and later support
Packit c4476c
the use of signing only keys for SSL client authentication.
Packit c4476c
Packit c4476c
=item B<-macalg digest>
Packit c4476c
Packit c4476c
Specify the MAC digest algorithm. If not included them SHA1 will be used.
Packit c4476c
Packit c4476c
=item B<-nomaciter>, B<-noiter>
Packit c4476c
Packit c4476c
These options affect the iteration counts on the MAC and key algorithms.
Packit c4476c
Unless you wish to produce files compatible with MSIE 4.0 you should leave
Packit c4476c
these options alone.
Packit c4476c
Packit c4476c
To discourage attacks by using large dictionaries of common passwords the
Packit c4476c
algorithm that derives keys from passwords can have an iteration count applied
Packit c4476c
to it: this causes a certain part of the algorithm to be repeated and slows it
Packit c4476c
down. The MAC is used to check the file integrity but since it will normally
Packit c4476c
have the same password as the keys and certificates it could also be attacked.
Packit c4476c
By default both MAC and encryption iteration counts are set to 2048, using
Packit c4476c
these options the MAC and encryption iteration counts can be set to 1, since
Packit c4476c
this reduces the file security you should not use these options unless you
Packit c4476c
really have to. Most software supports both MAC and key iteration counts.
Packit c4476c
MSIE 4.0 doesn't support MAC iteration counts so it needs the B<-nomaciter>
Packit c4476c
option.
Packit c4476c
Packit c4476c
=item B<-maciter>
Packit c4476c
Packit c4476c
This option is included for compatibility with previous versions, it used
Packit c4476c
to be needed to use MAC iterations counts but they are now used by default.
Packit c4476c
Packit c4476c
=item B<-nomac>
Packit c4476c
Packit c4476c
Don't attempt to provide the MAC integrity.
Packit c4476c
Packit c4476c
=item B<-rand file...>
Packit c4476c
Packit c4476c
A file or files containing random data used to seed the random number
Packit c4476c
generator.
Packit c4476c
Multiple files can be specified separated by an OS-dependent character.
Packit c4476c
The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
Packit c4476c
all others.
Packit c4476c
Packit c4476c
=item [B<-writerand file>]
Packit c4476c
Packit c4476c
Writes random data to the specified I<file> upon exit.
Packit c4476c
This can be used with a subsequent B<-rand> flag.
Packit c4476c
Packit c4476c
=item B<-CAfile file>
Packit c4476c
Packit c4476c
CA storage as a file.
Packit c4476c
Packit c4476c
=item B<-CApath dir>
Packit c4476c
Packit c4476c
CA storage as a directory. This directory must be a standard certificate
Packit c4476c
directory: that is a hash of each subject name (using B<x509 -hash>) should be
Packit c4476c
linked to each certificate.
Packit c4476c
Packit c4476c
=item B<-no-CAfile>
Packit c4476c
Packit c4476c
Do not load the trusted CA certificates from the default file location.
Packit c4476c
Packit c4476c
=item B<-no-CApath>
Packit c4476c
Packit c4476c
Do not load the trusted CA certificates from the default directory location.
Packit c4476c
Packit c4476c
=item B<-CSP name>
Packit c4476c
Packit c4476c
Write B<name> as a Microsoft CSP name.
Packit c4476c
Packit c4476c
=back
Packit c4476c
Packit c4476c
=head1 NOTES
Packit c4476c
Packit c4476c
Although there are a large number of options most of them are very rarely
Packit c4476c
used. For PKCS#12 file parsing only B<-in> and B<-out> need to be used
Packit c4476c
for PKCS#12 file creation B<-export> and B<-name> are also used.
Packit c4476c
Packit c4476c
If none of the B<-clcerts>, B<-cacerts> or B<-nocerts> options are present
Packit c4476c
then all certificates will be output in the order they appear in the input
Packit c4476c
PKCS#12 files. There is no guarantee that the first certificate present is
Packit c4476c
the one corresponding to the private key. Certain software which requires
Packit c4476c
a private key and certificate and assumes the first certificate in the
Packit c4476c
file is the one corresponding to the private key: this may not always
Packit c4476c
be the case. Using the B<-clcerts> option will solve this problem by only
Packit c4476c
outputting the certificate corresponding to the private key. If the CA
Packit c4476c
certificates are required then they can be output to a separate file using
Packit c4476c
the B<-nokeys -cacerts> options to just output CA certificates.
Packit c4476c
Packit c4476c
The B<-keypbe> and B<-certpbe> algorithms allow the precise encryption
Packit c4476c
algorithms for private keys and certificates to be specified. Normally
Packit c4476c
the defaults are fine but occasionally software can't handle triple DES
Packit c4476c
encrypted private keys, then the option B<-keypbe PBE-SHA1-RC2-40> can
Packit c4476c
be used to reduce the private key encryption to 40 bit RC2. A complete
Packit c4476c
description of all algorithms is contained in the B<pkcs8> manual page.
Packit c4476c
Packit c4476c
Prior 1.1 release passwords containing non-ASCII characters were encoded
Packit c4476c
in non-compliant manner, which limited interoperability, in first hand
Packit c4476c
with Windows. But switching to standard-compliant password encoding
Packit c4476c
poses problem accessing old data protected with broken encoding. For
Packit c4476c
this reason even legacy encodings is attempted when reading the
Packit c4476c
data. If you use PKCS#12 files in production application you are advised
Packit c4476c
to convert the data, because implemented heuristic approach is not
Packit c4476c
MT-safe, its sole goal is to facilitate the data upgrade with this
Packit c4476c
utility.
Packit c4476c
Packit c4476c
=head1 EXAMPLES
Packit c4476c
Packit c4476c
Parse a PKCS#12 file and output it to a file:
Packit c4476c
Packit c4476c
 openssl pkcs12 -in file.p12 -out file.pem
Packit c4476c
Packit c4476c
Output only client certificates to a file:
Packit c4476c
Packit c4476c
 openssl pkcs12 -in file.p12 -clcerts -out file.pem
Packit c4476c
Packit c4476c
Don't encrypt the private key:
Packit c4476c
Packit c4476c
 openssl pkcs12 -in file.p12 -out file.pem -nodes
Packit c4476c
Packit c4476c
Print some info about a PKCS#12 file:
Packit c4476c
Packit c4476c
 openssl pkcs12 -in file.p12 -info -noout
Packit c4476c
Packit c4476c
Create a PKCS#12 file:
Packit c4476c
Packit c4476c
 openssl pkcs12 -export -in file.pem -out file.p12 -name "My Certificate"
Packit c4476c
Packit c4476c
Include some extra certificates:
Packit c4476c
Packit c4476c
 openssl pkcs12 -export -in file.pem -out file.p12 -name "My Certificate" \
Packit c4476c
  -certfile othercerts.pem
Packit c4476c
Packit c4476c
=head1 SEE ALSO
Packit c4476c
Packit c4476c
L<pkcs8(1)>
Packit c4476c
Packit c4476c
=head1 COPYRIGHT
Packit c4476c
Packit c4476c
Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved.
Packit c4476c
Packit c4476c
Licensed under the OpenSSL license (the "License").  You may not use
Packit c4476c
this file except in compliance with the License.  You can obtain a copy
Packit c4476c
in the file LICENSE in the source distribution or at
Packit c4476c
L<https://www.openssl.org/source/license.html>.
Packit c4476c
Packit c4476c
=cut