Hi,

If any of y'all are OpenSSL gurus, please give this a look. I'm using a demo script to encrypt + decrypt a string, using code lifted straight from the manual. The only difference is I've defined $pub_key and $priv_key as strings containing copies of the keyfiles, pubkey.pem and privkey.pem (an RSA pair generated using the OpenSSL command-line tool).

openssl_pkey_get_private($priv_key);

works fine, but I can't do the equivalent with the public key. I noticed a difference in the keys, I don't know if this is relevant, but the private key begins "----BEGIN RSA PRIVATE KEY----" whereas the public key just has "----BEGIN PUBLIC KEY----". It WAS generated from privkey.pem using openSSL -> rsa -pubout so they should match.

The PHP manual says this should work, unless I'm missing something about the key generation procedure. Any ideas?

    Write a Reply...