I am cloning a repo of a Laravel project.
I clone the repo and do php artisan key: generate
which correctly sets the keys in .env. However when the app makes an external API request, it fails with the error
openssl_seal(): not a public key (1th member of pubkeys)
I have checked and the env('API_KEY') and 'API_URL' variables are correct.
public static function request(string $url, $data = []): Response
{
//This is where the code fails
$encrypt_result = self::encrypt($data, env('API_KEY'));
return Http::asForm()->post(env('API_URL') . $url, [
'key' => env('API_KEY'),
'hash' => $encrypt_result['hash'],
'e_key' => $encrypt_result['key']
]);
}
public static function encrypt(array $data, string $public_key): array
{
//This is where the code fails
openssl_seal(json_encode($data), $encrypted, $e_keys, [base64_decode($public_key)]);
return [
'hash' => base64_encode($encrypted),
'key' => base64_encode($e_keys[0])
];
}
I have previously seen questions that attribute this to an error with XAMPP, and I was using XAMPP on Windows though have subsequently replaced it with Wampserver and the issue persists.
While using Linux on this project fulltime is not viable, I will be testing it later.
Is there anything simple I might be overlooking?