It is possible to use "openssl rsa -in foo.cert.pem -text -noout" to dump the keys. Alternatively, you could probably parse them yourself with Convert::ASN1. It's nontrivial, though, ASN.1 being what it is, I guess. Besides, there is no proper x509v3 reader for Perl. (I have some certs here which Convert::ASN1's x509 example can not read.)
So just use openssl.
The parameters you want are called modulus, private exponent and public exponent. They go by the names N, D and E. Use N and D for privkey and N and E for pubkey.
There is a bug in Crypt::RSA::Key::Private, and this doesn't work:
my $key = Crypt::RSA::Key::Private->new();
$key->n($n); # where $n is "0x12345678", the hexdigits dumped by openssl without space or colons.
You have to do:
until it is fixed. Public key accessor methods n() and e() do work, though. I have already reported this issue, but no new version exists as of this date.
3 out of 3 found this review helpful. Was this review helpful to you? Yes No