Crypt-OpenSSL-PKCS12
view release on metacpan or search on metacpan
package Crypt::OpenSSL::PKCS12;
use warnings;
use strict;
use Exporter;
our $VERSION = '1.94';
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(NOKEYS NOCERTS INFO CLCERTS CACERTS);
use XSLoader;
XSLoader::load 'Crypt::OpenSSL::PKCS12', $VERSION;
END {
__PACKAGE__->__PKCS12_cleanup();
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Crypt::OpenSSL::PKCS12 - Perl extension to OpenSSL's PKCS12 API.
=head1 SYNOPSIS
use Crypt::OpenSSL::PKCS12;
my $pass = "your password";
my $pkcs12 = Crypt::OpenSSL::PKCS12->new_from_file('cert.p12');
print $pkcs12->certificate($pass);
print $pkcs12->private_key($pass);
if ($pkcs12->mac_ok($pass)) {
...
# Creating a file
$pkcs12->create('test-cert.pem', 'test-key.pem', $pass, 'out.p12', 'friendly name');
# Creating a string
my $pksc12_data = $pkcs12->create_as_string('test-cert.pem', 'test-key.pem', $pass, 'friendly name');
# Reproducing OpenSSL's info
my $info = $pkcs12->info($pass);
# Accessing OpenSSL's info as a hash
my $info_hash = $pkcs12->info_as_hash($pass);
=head1 VERSION
This documentation describes version 1.94 of Crypt::OpenSSL::PKCS12
=head1 DESCRIPTION
PKCS12 is a file format for storing cryptography objects as a single file or string. PKCS12 is commonly used to bundle a private key with its X.509 certificate or to bundle all the members of a chain of trust.
This distribution implements a subset of OpenSSL's PKCS12 API.
=head1 SUBROUTINES/METHODS
=over 4
=item * new( )
=item * legacy_support ( )
Check whether the openssl version installed supports the legacy provider.
=item * new_from_string( C<$string> )
=item * new_from_file( C<$filename> )
Create a new Crypt::OpenSSL::PKCS12 instance.
=item * certificate( [C<$pass>] )
Get the Base64 representation of the certificate.
=item * ca_certificate( [C<$pass>] )
Get the Base64 representation of the CA certificate chain.
=item * private_key( [C<$pass>] )
Get the Base64 representation of the private key.
=item * as_string( [C<$pass>] )
Get the binary represenation as a string.
=item * mac_ok( [C<$pass>] )
Verifiy the certificates Message Authentication Code
=item * changepass( C<$old>, C<$new> )
Change a certificate's password.
=item * create( C<$cert>, C<$key>, C<$pass>, C<$output_file>, C<$friendly_name> )
Create a new PKCS12 certificate. $cert & $key may either be strings or filenames.
C<$friendly_name> is optional.
=item * create_as_string( C<$cert>, C<$key>, C<$pass>, C<$friendly_name> )
Create a new PKCS12 certificate string. $cert & $key may either be strings or filenames.
C<$friendly_name> is optional.
Returns a string holding the PKCS12 certicate.
=item * info( C<$pass> )
Returns a string containing the output of information about the pkcs12 file in
the same format as produced by the openssl command:
openssl pkcs12 -in certs/test_le_1.1.p12 -info -nodes
=item * info_as_hash( C<$pass> )
Places the information about the pkcs12 file, the certificates and keys
in a hash.
The format of the hash is complex to represent the data in the PKCS12 file:
Essentially, the hash follows the format of the -info output.
1. pkcs7_data and pkcs7_encrypted_data are arrays as more than one of each can exist
2. mac provieds the top level mac parameters for the file
3. safe_contents_bag is an array that contains an array of bags
4. bags is an array of bags
5. a bag is a container for a key or certificate
Each bag has a type and the following are available:
1. key_bag
2. certificate_bag
3. shrouded_keybag
4. secret_bag
5. safe_contents_bag
{
( run in 0.813 second using v1.01-cache-2.11-cpan-39bf76dae61 )