From: Chris R. <chr...@me...> - 2000-07-31 15:25:19
|
Graham Barr <gb...@po...> wrote: > On Mon, Jul 31, 2000 at 03:57:33PM +0100, Chris Ridd wrote: >> I just had a quick go, and am having problems. > > Like ? Erm, I think I just had the ASN.1 wrong :-) Well, here's an attempt at decoding the timestamps from a cert: ----- #!/usr/bin/perl -w use strict; use Carp; use Convert::ASN1; my $cert; { local $/ = undef; open CERT, "mycert.der" or die; $cert = <CERT>; close CERT; } my $asn = Convert::ASN1->new; # Can't get this to work. Want to stop Convert::ASN1 from changing the # UTCTime values... #my %opts = ( # timezone => [0,0] # ); #$asn->configure(decode => \%opts); # Ignore pretty much everything $asn->prepare(q< SEQUENCE { SEQUENCE { version [0] IMPLICIT INTEGER OPTIONAL, serialNumber ANY, signature ANY, issuer ANY, SEQUENCE { notBefore UTCTime, notAfter UTCTime } subject ANY, spkinfo ANY, issueruid [1] IMPLICIT ANY OPTIONAL, subjectuid [2] IMPLICIT ANY OPTIONAL, extensions [3] ANY OPTIONAL } alg ANY OPTIONAL, sig BIT STRING }>) or die; my $out = $asn->decode($cert) or die; print "NotBefore: " . $out->{notBefore} . "\n"; print "NotAfter: " . $out->{notAfter} . "\n"; ---- I couldn't persuade Convert::ASN1 from messing with the time strings. Replacing 'UTCTime' above with '[UNIVERSAL 23] IMPLICIT STRING' will get the correct unadulterated times back... Cheers, Chris |