CloudWindMoonSun - 2017-05-17 10:33:47
Hi,
I created public key in PHP and exported it to a file. e.g.:
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA498EWxuZK/KsUgIEusEt
QOJulgTHwb8C4avtzJnzhosTeKooXvyGFPpex6HcQGSRqrWpNr2yhw1BvJvH2UyE
Jisl5BJA5Za+ofmbGifCFwCllZ37U1YpOmqpB2Yt+yYElGh5dp+lqs5Q3u3nPknd
nLS3bxH7qlZBvR9YPWj9x7IuSXJyopAmdJato8xeNHzmBxWD8FgQKICFpLtGsPXq
XRwT0imTs6/EcMqq6fdlp0OyBKyZjw6t47gMeqiuSYz6k41Nf/SbtIC4snUyoUgI
TvnHjWe1cY7js4kY62A9ZpHX0NpG7JXctxVb+aZOv1rS36bUjcP+bug1W3ZKrTG6
hwIDAQAB
-----END PUBLIC KEY-----
On server side (OSX Sierra) I need to read the key file and use it for encryption/decryption using PHP. My PHP code is as following:
$pub_key = file_get_contents("../user_pub_key.crt");
$public_key = openssl_pkey_get_public($pub_key);
var_dump($public_key);
echo openssl_error_string();
Although $public_key is apparently created and var_dump returns the resource number of it, like:
resource(5) of type (OpenSSL key)
but strangely enough, openssl_error_string() also shows the following error:
error:0906D06C:PEM routines:PEM_read_bio:no start line
Does it mean that OpenSSL and PHP on my Mac are not compatible. Any suggestion for resolving this problem please?
Thanks,
Hassan&