Help using openssl with PHP 5.1.6 (can't extract public key)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
mecha_godzilla
Forum Contributor
Posts: 375
Joined: Wed Apr 14, 2010 4:45 pm
Location: UK

Help using openssl with PHP 5.1.6 (can't extract public key)

Post by mecha_godzilla »

Hi,

Hope someone can help me as I'm banging my head against a brick wall with this :D

Does anyone have an example of how to generate a public/private key pair using openssl that works with PHP version 5.1.6 please? My main problem at the moment is that most of the examples I've seen require openssl_pkey_get_details (which doesn't work with this version) and all the other things I've tried give me errors such as

"supplied resource is not a valid OpenSSL X.509/key resource"

or

"Don't know how to get public key from this private key"

Getting the private key and/or certificate is easy enough, but it all seems to fall down when I try to get the public key.

I've tried some of the examples on the main PHP site but none seem to work and upgrading the version of PHP I'm using isn't an option. What I think I'll probably end up doing is just generating the keys on my local PHP install but I find it difficult to believe that openssl is this difficult to get working under 5.1.6 - I've wasted probably three hours on this already 8O

Thanks in advance,

Mecha Godzilla
Post Reply