473,466 Members | 1,457 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

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==============
Jul 19 '05 #1
0 2755

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Carl Waldbieser | last post by:
I tried to adapt the instructions for building the M2Crypto module (http://sandbox.rulemaker.net/ngps/m2/INSTALL.html) to build a version compatible with Python2.3, but I've had some mixed results....
1
by: Jorge Rivera | last post by:
I am trying to write a client application that uses SSL. I am using openSSL in Red Hat Linux 9.0, using C++. When I am at home, my application works fine. However, when I return to the...
1
by: diogoko | last post by:
Has anyone been sucessful in getting/reading a RSA or DSA public key using the openssl functions? openssl_get_publickey should work with PEM files, but it doesn't... I've tried creating a...
14
by: Bryan | last post by:
Hey guys, I've been fighting with trying to use RSA to encrypt data in Java and decrypt the data in C#. I've been able to create an X.509 certificate using makecert and successfully access it...
7
by: Abhisek Datta | last post by:
Hello, I am looking for good RSA implementations in python that can import a public key in PEM format and encrypt a buffer using the imported public key. I tried m2crypto, but somehow it is...
0
by: mahesh anasuri | last post by:
Hi all, I am new to this mailing list. Thankful if any one is using curl/linux version to and worked on Https. I have created certificates (PEM format) for client and server using openSSL. I...
5
by: KW | last post by:
I'm trying to convert some PHP code using OpenSSL to Python and I'm stuck on openssl_sign() which uses an RSA private key to compute a signature. Example PHP code: $privkeyid =...
1
by: SammyBar | last post by:
Hi all, I need to fill a System.Security.Cryptography.RSAParameters structure with my private key parameters. The private key is in PEM format so by using openssl I can obtain all the...
3
by: d-fan | last post by:
void decodebio( unsigned char *encbuf, unsigned char * decbuf, int destbuf ) { /* Read Base64 encoded data from standard input and write the decoded data to standard output: */ BIO...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.