3
When calling the function openssl_encrypt
, always returned false. When checking the function openssl_error_string
, I get the following error:
error:0906D06C:PEM routines:Pem_read_bio:no start line
The code I’m doing the tests is this:
$data = 'Olá, Wallace!';
$encryption_key = openssl_random_pseudo_bytes(32);
$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('AES-256-CBC'));
$encrypted = openssl_encrypt($data, 'AES-256-CBC', $encryption_key, 0, $iv);
if (false === $encrypted) {
var_dump(openssl_error_string());
exit;
}
Why this error is generated?
I’m doing these tests trying to find a solution to this question:
Hello, I ran the code here and it worked right, Ubuntu with PHP 7.0. Which OS and PHP version you are using?
– Fernando Mertins
I was using version 5.6 of PHP
– Wallace Maxters
Hello, and what OS-Operating System?
– Fernando Mertins
My OS is Linux, Ubuntu 16.04
– Wallace Maxters
Idem here, Ubuntu 16.04 64-bit LTS, but from what I know, the default version that comes from PHP is 7, I ran the code here and it works cool, as you are in version 5.6 must have changed some configuration and maybe started generating this error?
– Fernando Mertins