PKCS10(3pm) | User Contributed Perl Documentation | PKCS10(3pm) |
Crypt::OpenSSL::PKCS10 - Perl extension to OpenSSL's PKCS10 API.
use Crypt::OpenSSL::PKCS10::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();
Crypt::OpenSSL::PKCS10 - Perl extension to OpenSSL's PKCS10 API.
Crypt::OpenSSL::PKCS10 provides the ability to create PKCS10 certificate requests using RSA key pairs.
my $rsa = Crypt::OpenSSL::RSA->generate_key(512); my $req = Crypt::OpenSSL::PKCS10->new_from_rsa($rsa);
my $req = Crypt::OpenSSL::PKCS10->new_from_file("CSR.csr");
$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_custom_ext_raw($oid, pack('H*','1E06006100620063')) # BMPString 'abc'
$req->add_ext(Crypt::OpenSSL::PKCS10::NID_subject_alt_name,"email:my@email.org"); $req->add_ext_final();
$req->sign();
$req->pubkey_type();
$req->get_pubkey();
$req->get_pem_req();
$req->write_pem_req('request.pem');
$req->get_pem_pk();
$req->write_pem_pk('request.pem');
$subject = $req->subject();
$keyinfo = $req->keyinfo();
None by default.
On request:
NID_key_usage NID_subject_alt_name NID_netscape_cert_type NID_netscape_comment NID_ext_key_usage
If you destroy $req object that is linked to a Crypt::OpenSSL::RSA object, the RSA private key is also freed, thus you can't use latter object anymore. Avoid this:
my $rsa = Crypt::OpenSSL::RSA->generate_key(512); my $req = Crypt::OpenSSL::PKCS10->new_from_rsa($rsa); undef $req; print $rsa->get_private_key_string();
"Crypt::OpenSSL::RSA", "Crypt::OpenSSL::X509".
JoNO, <jonozzz@yahoo.com>
Copyright (C) 2006 by JoNO
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.2 or, at your option, any later version of Perl 5 you may have available.
2022-10-20 | perl v5.36.0 |