Subject: | certificate version should implicitly be v1 (integer 0) |
this bug causes $v to be undefined in certificates that do not specify a
version. The perl error will be similar to:
Use of uninitialized value $v in numeric eq (==) at
/usr/local/share/perl5/Crypt/X509.pm line 152.
when undefined in the certificate, "version" should return 0 and
"version_string" should return "v1" below is a patch to add logic that
will achieve this functionality.
diff -Naur /usr/local/share/perl5/Crypt/X509.pm.old
/usr/local/share/perl5/Crypt/X509.pm
--- /usr/local/share/perl5/Crypt/X509.pm.old 2012-02-12
01:19:52.733624732 -0500
+++ /usr/local/share/perl5/Crypt/X509.pm 2012-02-12
01:21:08.994094646 -0500
@@ -137,7 +163,10 @@
sub version {
my $self = shift;
- return $self->{tbsCertificate}{version};
+ if ( defined $self->{tbsCertificate}{version} ){
+ return $self->{tbsCertificate}{version};
+ }
+ return 0;
}
=head2 version_string
@@ -148,7 +177,11 @@
sub version_string {
my $self = shift;
- my $v = $self->{tbsCertificate}{version};
+ my $v = 0;
+ if ( defined $self->{tbsCertificate}{version} ){
+ $v = $self->{tbsCertificate}{version};
+ }
+
return "v1" if $v == 0;
return "v2" if $v == 1;
return "v3" if $v == 2;