473,739 Members | 6,655 Online
Bytes | Software Development & Data Engineering Community
+ 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-----
MIIB8zCCAVygAwI BAgIQC/mb6aRvL5BCaxMVp EBAazANBgkqhkiG 9w0BAQQFADAT
MREwDwYDVQQDEwh UZXN0Q2VydDAeFw 0wMzA3MTExMjI1N DFaFw0zOTEyMzEy MzU5
NTlaMBMxETAPBgN VBAMTCFRlc3RDZX J0MIGfMA0GCSqGS Ib3DQEBAQUAA4GN ADCB
iQKBgQDgp5o5a4y QbIv8RHVfJcWmac QmZmzd/GBxhoNOx7H922J4 8ocGqvgF8beu
PN7wsI/fUqjm5pzFgb12+A yDN5gq0vLMA8wmK S/Cdc+3OCK5EkBE9X i/RSoeno+Q
o0a0M8lLl8mZBOa pyq67FvLsHdQQLc ZHqR8kP6Dn54FsT vyfgQIDAQABo0gw RjBE
BgNVHQEEPTA7gBB fYCG1dYRmxJcj+J/jH9YloRUwEzERMA 8GA1UEAxMIVGVzd ENl
cnSCEAv5m+mkby+ QQmsTFaRAQGswDQ YJKoZIhvcNAQEEB QADgYEAu9H1SWLT Vi4K
mGnsDw/ZeLtd/s8nq+k1b7Ds3LEZ MBLaEyMiCkZ8zzE eGmvlJwB54XS+zh wj0RDW
Kc2McRfsUuPkpnG MfANu3zATydGry0 3FCrO+uid4X91Lf +h9YL+BSewyrsnN jCx0
0qMa+jkZ9C7vcIn RRNzabtnypylza7 A=
-----END CERTIFICATE-----";

$plaintext = "Test String";

# not necessary if we have /dev/random:
# Crypt::OpenSSL: :Random::random _seed($good_ent ropy);

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

$ciphertext = $rsa->encrypt($plain text);

print "ENCRYPTED: [$ciphertext]\n";
=TEST CODE END============ ==
Jul 19 '05 #1
0 2773

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

Similar topics

7
7182
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. I actually got everything to build and install, but when I try to import M2Crypto-- well, here is a sample session: >>> import M2Crypto Traceback (most recent call last): File "<interactive input>", line 1, in ? File...
1
2221
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 office, the SSL handshake fails. The reaon is quite obvious, there is a proxy server in between my computer and the target server, and the proxy does not know that the requests should just be forwarded to the server.
1
1825
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 X.509 certificate, putting the public key in there and getting it out with openssl_get_publickey, but it doesn't work either... All I want to do is to decrypt some data using a public key received
14
18251
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 in C# using WSE. After exporting from certmgr as a CER, I can use it in Java using keytool. My problem is, I simply cannot decrypt the Java encrypted messages in C#. If I encrypt and decrypt in C#, everything is fine. One thing I noticed is...
7
9063
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 giving me exceptions which I couldnt solve as of now. I get the following with m2crypto: rsa = M2Crypto.RSA.load_pub_key("pubkey.pem") gives me:
0
10710
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 am using Apache server/Linux platform and started server with "server certificate". I configured server to listen HTTPS service at port 443. I downloaded download.txt correctly from server using command as $curl --cacert cacert.pem ...
5
4149
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 = openssl_get_privatekey($priv_key, $key_pass); openssl_sign($data, $signature, $privkeyid); openssl_free_key($privkeyid); I've tried several permutations of the stuff in M2Crypto.EVP but I can't get it to work...
1
2678
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 parameters. But openssl names the parameters different to the RSAParameters struct. The openssl output is in the form openssl rsa -in key.pem -noout -text modulus: ...
3
3788
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 *b64, *bio ; long i ; char buffer ; memset(buffer, 0, 512) ;
0
9479
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9337
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9209
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8215
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6754
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6054
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4570
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3280
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.