I can’t instanciate my $pemkey
whit a relative path in my php code. When I try to instanciate my key with openssl_pkey_get_private
the program doesn’t find it.
Here is my code :
$pemkey = openssl_pkey_get_private("file:///licensePrivateKey.pem");
if (! $pemkey ){
echo "ERROR - Unable to load signing key.";
die();
}
And here are my files :
- folder
- download_file.php
- licensePrivateKey.pem
(Sorry can’t display images lol)
2
Answers
I solved the error by creating an absolute path with
dirname(__FILE__)
and and my file name. Here's the code :Check this note on PHP manual website https://www.php.net/manual/en/function.openssl-pkey-get-private.php#114998
So you only have to concatenate "file://" with an existing path string in every case
This looks like an absolute path /licensePrivateKey.pem
You are using windows or unix system?