For Programmers: Free Programming Magazines  


Home > Archive > LDAP > August 2007 > Crypt::X509 / Blessing error









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Crypt::X509 / Blessing error
Jean-Luc Boss

2007-08-22, 8:17 am

Hi,

when i try to run this simple Crypt::X509 script, i have
this
error: "Attempt to bless into a reference at
/opt/perl_32/lib/site_perl/5.8.8/Crypt/X509.pm line 105."
I want to build a mailer to send alerts to our customer,
if they have to renew their certificates, the ldap
extraction is already running.
________________________________________
___________
use Crypt::X509;
#INITIALIZING
my $certfile="46B2D0D7.cer";
my $certificate;

open CERTFILE , $certfile or die "Error to open file";
binmode binmode
read (CERTFILE, $certificate, 65536);
close CERTFILE;

$decoded = new Crypt::X509->new( cert => $certificate );

print "Certificate Subject: ".$decoded->Subject;
________________________________________
___________

Does someone know what's wrong with this?

Thank you,
JL
Chris Ridd

2007-08-22, 7:17 pm

On 22/8/07 10:34, "Jean-Luc Boss" <jean-luc.boss@flaschenpost.cetrel.net>
wrote:

> Hi,
>
> when i try to run this simple Crypt::X509 script, i have
> this
> error: "Attempt to bless into a reference at
> /opt/perl_32/lib/site_perl/5.8.8/Crypt/X509.pm line 105."
> I want to build a mailer to send alerts to our customer,
> if they have to renew their certificates, the ldap
> extraction is already running.
> ________________________________________
___________
> use Crypt::X509;
> #INITIALIZING
> my $certfile="46B2D0D7.cer";
> my $certificate;
>
> open CERTFILE , $certfile or die "Error to open file";
> binmode binmode


Presumably that ought to be:

binmode CERTFILE;

?

> read (CERTFILE, $certificate, 65536);
> close CERTFILE;
>
> $decoded = new Crypt::X509->new( cert => $certificate );
>
> print "Certificate Subject: ".$decoded->Subject;
> ________________________________________
___________
>
> Does someone know what's wrong with this?


What happens if you single-step with the perl debugger?

Cheers,

Chris


Alexander Jung

2007-08-22, 7:17 pm

Hello,

2007/8/22, Chris Ridd <chrisridd@mac.com>:
> On 22/8/07 10:34, "Jean-Luc Boss" <jean-luc.boss@flaschenpost.cetrel.net>=

wrote:
[color=darkred]
This happens in the following code:
sub new {
=09my ($class,%args) =3D @_;
=09if (!defined ($parser)) {
=09=09$parser=3D_init();
=09}
=09my $self =3D $parser->decode($args{'cert'});
=09
=09$self->{"_error"} =3D $parser->error;
=09bless ($self, $class); <=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Error comes down=
here
=09return $self;
}

This can only happen, when the given cert argument is not a string (or
scalar in Perl speak)

Like Chris already suggested, you probably give the new function an
undef, which leads to an uninitialised parser, that cannot be blessed.

Did the Tests work when you installed Crypt::X509 ? When you look in
the t subdirectory you'll find an example how to read a *binary*
certificate file and use the module.

Mit freundlichen Gr=FC=DFen,

Alexander Jung
Graham Barr

2007-08-22, 10:16 pm

On Aug 22, 2007, at 4:34 AM, Jean-Luc Boss wrote:
>
> $decoded = new Crypt::X509->new( cert => $certificate );


You are calling new on the result of calling new

take out that first 'new'

Graham.

Alexander Jung

2007-08-23, 4:30 am

Hello,


2007/8/23, Graham Barr <gbarr@pobox.com>:
> On Aug 22, 2007, at 4:34 AM, Jean-Luc Boss wrote:
> You are calling new on the result of calling new

thanks, I just looked into my code and did noch check his. oh well,
looks I'm getting old and selfish.

Mit freundlichen Gr=FC=DFen,

Alexander Jung
Jean-Luc Boss

2007-08-31, 6:17 am

On Thu, 23 Aug 2007 08:28:16 +0200
"Alexander Jung" <alexander.w.jung@gmail.com> wrote:
>Hello,
>
>
>2007/8/23, Graham Barr <gbarr@pobox.com>:
>thanks, I just looked into my code and did noch check
>his. oh well,
>looks I'm getting old and selfish.
>
>Mit freundlichen Grüßen,
>
>Alexander Jung


Thank you,

It works great now, i'm able to check all the certificates
in my LDAP now :)

Best regards,
Jean-Luc Boss
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com