Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Error using Crypt::OpenSSL::RSA - Fails loading public key - Help needed

Reply
Thread Tools

Error using Crypt::OpenSSL::RSA - Fails loading public key - Help needed

 
 
John Bergstrom
Guest
Posts: n/a
 
      08-03-2003
Hello everyone!

I wrote a simple perl program to encrypt a string using
Crypt::OpenSSL::RSA.

Everything as described in the module documentation. The public key
is a valid X.509 encrypted certificate.

When I tried executing the code I get the following error:
-------------------
Failed to read key at blib/lib/Crypt/OpenSSL/RSA.pm (autosplit into
blib/lib/auto/Crypt/OpenSSL/RSA/load_public_key.al) line 225
-------------------

Below is the exact code I that I'm trying to get working.

Anyone any ideas?

Thanks a lot in advance for your help!

=TEST CODE START=======================
use lib qw(/usr/local/lib/perl5/site_perl/5.6.1/i386-freebsd/);
use lib qw(/usr/local/lib/perl5/site_perl/5.6.1/i386-freebsd/auto/);

use Crypt::OpenSSL::Random;
use Crypt::OpenSSL::RSA;

$key_string ="-----BEGIN CERTIFICATE-----
MIIB8zCCAVygAwIBAgIQC/mb6aRvL5BCaxMVpEBAazANBgkqhkiG9w0BAQQFADAT
MREwDwYDVQQDEwhUZXN0Q2VydDAeFw0wMzA3MTExMjI1NDFaFw 0zOTEyMzEyMzU5
NTlaMBMxETAPBgNVBAMTCFRlc3RDZXJ0MIGfMA0GCSqGSIb3DQ EBAQUAA4GNADCB
iQKBgQDgp5o5a4yQbIv8RHVfJcWmacQmZmzd/GBxhoNOx7H922J48ocGqvgF8beu
PN7wsI/fUqjm5pzFgb12+AyDN5gq0vLMA8wmKS/Cdc+3OCK5EkBE9Xi/RSoeno+Q
o0a0M8lLl8mZBOapyq67FvLsHdQQLcZHqR8kP6Dn54FsTvyfgQ IDAQABo0gwRjBE
BgNVHQEEPTA7gBBfYCG1dYRmxJcj+J/jH9YloRUwEzERMA8GA1UEAxMIVGVzdENl
cnSCEAv5m+mkby+QQmsTFaRAQGswDQYJKoZIhvcNAQEEBQADgY EAu9H1SWLTVi4K
mGnsDw/ZeLtd/s8nq+k1b7Ds3LEZMBLaEyMiCkZ8zzEeGmvlJwB54XS+zhwj0RD W
Kc2McRfsUuPkpnGMfANu3zATydGry03FCrO+uid4X91Lf+h9YL +BSewyrsnNjCx0
0qMa+jkZ9C7vcInRRNzabtnypylza7A=
-----END CERTIFICATE-----";

$plaintext = "Test String";

# not necessary if we have /dev/random:
# Crypt::OpenSSL::Random::random_seed($good_entropy) ;

Crypt::OpenSSL::RSA->import_random_seed();
$rsa_pub = Crypt::OpenSSL::RSA->new_public_key($key_string);

$ciphertext = $rsa->encrypt($plaintext);

print "ENCRYPTED: [$ciphertext]\n";
=TEST CODE END==============
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd loyola MCSE 4 11-15-2006 02:40 AM
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd loyola Microsoft Certification 3 11-14-2006 05:18 PM
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd loyola MCSD 3 11-14-2006 05:18 PM
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd realexxams@yahoo.com Microsoft Certification 0 05-10-2006 02:35 PM
microsoft.public.dotnet.faqs,microsoft.public.dotnet.framework,microsoft.public.dotnet.framework.windowsforms,microsoft.public.dotnet.general,microsoft.public.dotnet.languages.vb Charles A. Lackman ASP .Net 1 12-08-2004 07:08 PM



Advertisments