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

Greetings wise ones, Does anyone know of a module that will allow me to extract the public key from an exported X509 digital certificate on a win32 machine? I am hoping to be able to access other info as well, (algorithm, certificate end date, etc...), but The public key is the main thing I need.
  • Comment on Help extracting public key from X509 .cer file

Replies are listed 'Best First'.
Re: Help extracting public key from X509 .cer file
by Joost (Canon) on Aug 15, 2005 at 13:53 UTC
      Yes, I saw this, but the CPAN tests shows that it fails on win32 sysytems. The following code generated this error. asn decode error: decode error at C:/Perl/site/lib/Convert/ASN1/_decode.pm line 60. at C:\scripts\parsder.pl line 3 Can't use string ("1") as a HASH ref while "strict refs" in use at C:/Perl/site/lib/Crypt/X509.pm line 503.
      use Crypt::X509; $cer = "C:\\temp\\test.cer"; $cert = Crypt::X509->new( cert => $cer ); $subject_email = $cert->subject_email;
        Not a bad result for version 0.01 :)

        Did you try tracking down x509decode, which it's apparently based on? (Judging from a very quick reading of the README).

        Maybe you'll have more luck running Convert::ASN1; it includes the x509decode in the examples subdirectory.

        It may not work any better, but it's probably worth a try.


        Mike