Crypt-OpenSSL-PKCS10
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Crypt/OpenSSL/PKCS10.pm view on Meta::CPAN
package Crypt::OpenSSL::PKCS10;
use 5.008000;
use strict;
use warnings;
require Exporter;
our @ISA = qw(Exporter);
# Items to export into callers namespace by default. Note: do not export
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.
# This allows declaration use Crypt::OpenSSL::PKCS10 ':all';
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
# will save memory.
our @NIDS = qw(
NID_key_usage NID_subject_alt_name NID_netscape_cert_type NID_netscape_comment
NID_ext_key_usage
);
our %EXPORT_TAGS = (
'all' => [ @NIDS ],
'const' => [ @NIDS ],
);
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
#our @EXPORT = qw(
#);
our $VERSION = '0.25';
require XSLoader;
XSLoader::load('Crypt::OpenSSL::PKCS10', $VERSION);
# Preloaded methods go here.
sub new_from_rsa {
my $self = shift;
my $rsa = shift;
my $priv = $rsa->get_private_key_string();
$self->_new_from_rsa($rsa, $priv);
}
1;
__END__
# ABSTRACT: Perl extension to OpenSSL's PKCS10 API.
=head1 NAME
Crypt::OpenSSL::PKCS10 - Perl extension to OpenSSL's PKCS10 API.
=head1 SYNOPSIS
use Crypt::OpenSSL::PKCS10 qw( :const );
my $req = Crypt::OpenSSL::PKCS10->new;
$req->set_subject("/C=RO/O=UTI/OU=ssi");
$req->add_ext(Crypt::OpenSSL::PKCS10::NID_key_usage,"critical,digitalSignature,keyEncipherment");
$req->add_ext(Crypt::OpenSSL::PKCS10::NID_ext_key_usage,"serverAuth, nsSGC, msSGC, 1.3.4");
$req->add_ext(Crypt::OpenSSL::PKCS10::NID_subject_alt_name,"email:steve@openssl.org");
$req->add_custom_ext('1.2.3.3',"My new extension");
$req->add_ext_final();
$req->sign();
$req->write_pem_req('request.pem');
$req->write_pem_pk('pk.pem');
print $req->get_pem_pubkey();
print $req->pubkey_type();
print $req->get_pem_req();
=head1 ABSTRACT
Crypt::OpenSSL::PKCS10 - Perl extension to OpenSSL's PKCS10 API.
=head1 DESCRIPTION
Crypt::OpenSSL::PKCS10 provides the ability to create PKCS10 certificate requests using RSA key pairs.
=head1 Class Methods
=over
=item new
Create a new Crypt::OpenSSL::PKCS10 object by generating a new RSA key pair. There is one optional argument, the key size,
which has the default value of 1024 if omitted.
=item new_from_rsa( $rsa_object )
Create a new Crypt::OpenSSL::PKCS10 object by using key information from a Crypt::OpenSSL::RSA object. Here is an example:
my $rsa = Crypt::OpenSSL::RSA->generate_key(512);
my $req = Crypt::OpenSSL::PKCS10->new_from_rsa($rsa);
OpenSSL 3.0 has deprecated the RSA object which Crypt::OpenSSL::RSA creates. new_from_rsa() is now a perl sub which obtains the private key as a string that is also passed to the _new_from_rsa() XS function.
=item new_from_file( $filename )
Create a new Crypt::OpenSSL::PKCS10 object by reading the request and key information from a PEM formatted file. Here is an example:
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.640 second using v1.00-cache-2.02-grep-82fe00e-cpan-2cc899e4a130 )