Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Crypt::OpenSSL::RSA->new_public_key does not accept a x.509 public key

by mgr007 (Initiate)
on Sep 16, 2015 at 16:42 UTC ( [id://1142212]=perlquestion: print w/replies, xml ) Need Help??

mgr007 has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I'm trying to verify a xml signed document. Reading the x.509 certificate works fine, as well as extracting the public key. But if try to read the key with

Crypt::OpenSSL::RSA->new_public_key

I will get the error message

RSA.xs:178: OpenSSL error: expecting an rsa key at blib/lib/Crypt/OpenSSL/RSA.pm (autosplit into blib/lib/auto/Crypt/OpenSSL/RSA/new_public_key.al) line 91, <STDIN> line 1.

My code is:

... $x509 = Crypt::OpenSSL::X509->new_from_string($cert); $rsa = Crypt::OpenSSL::RSA->new_public_key($x509->pubkey); ...

$x509->pubkey seems correctly pem encoded (starting with "-----BEGIN PUBLIC KEY-----" ) and comes from a http://www.w3.org/2000/09/xmldsig signature compliant certificate.

Is there a difference between a rsa public key and a x.509 public key ?

What's the problem ? Do you have an idea ?

Replies are listed 'Best First'.
Re: Crypt::OpenSSL::RSA->new_public_key does not accept a x.509 public key
by CountZero (Bishop) on Sep 16, 2015 at 19:41 UTC
    What does the "Public Key Algorithm" field of the X.509 certificate say?

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

    My blog: Imperial Deltronics

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1142212]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-03-29 05:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found