Skip Menu |

This queue is for tickets about the Crypt-X509 CPAN distribution.

Report information
The Basics
Id: 54144
Status: resolved
Priority: 0/
Queue: Crypt-X509

People
Owner: alexander.w.jung [...] gmail.com
Requestors: TOMHRR [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.40
Fixed in: (no value)



If a malformed certificate is loaded, and then a well-formed certificate is loaded, the second load will fail with the same error (via error() on the returned object) as for the first load. This appears to be because the Convert::ASN1 parser is not reinitialised on new() when the parser is in an error state. Test and patch attached. Perl: v 5.10.1 (*) built for i686-linux-thread-multi Convert::ASN1: v 0.22 Cheers -Tom
Subject: invalid-then-valid.t
use Test::More tests => 5; BEGIN { use_ok('Crypt::X509') } $invalid_cert = Crypt::X509->new( cert => 'invalid' ); ok( $invalid_cert->error, 'got error on invalid data' ); $cert = loadcert('t/verisign.der'); $valid_cert = Crypt::X509->new( cert => $cert ); ok( defined $valid_cert, 'new() returned something' ); is( $valid_cert->error, undef, 'decode successful' ); is( $valid_cert->not_after, 1848787199, 'not_after got parsed' ); sub loadcert { my $file = shift; open FILE, $file || die "cannot load test certificate" . $file . "\n"; binmode FILE; # HELLO Windows, dont fuss with this my $holdTerminator = $/; undef $/; # using slurp mode to read the DER-encoded binary certificate my $cert = <FILE>; $/ = $holdTerminator; close FILE; return $cert; }
Subject: invalid-then-valid.patch
--- /usr/share/perl5/site_perl/5.10.1/Crypt/X509.pm 2009-04-23 21:56:23.000000000 +1000 +++ X509.pm 2010-01-30 10:52:36.965738918 +1000 @@ -89,7 +89,7 @@ sub new { my ( $class, %args ) = @_; - if ( !defined($parser) ) { + if ( !defined($parser) || $parser->error ) { $parser = _init(); } my $self = $parser->decode( $args{'cert'} );
Subject: Crypt::X509 Patch for invalid Parser state
Hello, you probably will not remeber your patch - it is almost a year ago you sent it to me - but I have incorporated it into the next release of the module. It should be on CPAN within the next two days. Thanks for spotting the problem and supplying a ready patch and test. Yours, Alexander Jung
Subject: Cypt::X509 new Version (0.50)
Hello, a new version that incorporates your patch is on CPAN. Thanks, Alexander