The OpenSSL function is not available under HTTPS
Issue: LINUX+APACHE2+PHP5 environment, configure SSL to make HTTPS accessible, and then execute the test code:
#ssl-encry.php
$source = "This is encry-content.";
echo "1.Source: $source";
$FP =fopen ("/path/to/certificate.crt", "R");
$pub _key=fread ($fp, 8192);
Fclose ($FP);
Openssl_get_publickey ($pub _key);
Openssl_public_encrypt ($source, $crypttext, $pub _key);
echo "2.String crypted: $crypttext";
$FP =fopen ("/path/to/private.key", "R");
$priv _key=fread ($fp, 8192);
Fclose ($FP);
$passphrase is required if your key is encoded (suggested)
$passphrase = ";
$res = Openssl_get_privatekey ($priv _key, $passphrase);
Openssl_private_decrypt ($crypttext, $newsource, $res);
echo "3.String decrypt: $newsource";
After running, the page prompt cannot connect to the server.
After testing, the problem is that the Openssl_public_encrypt () function cannot be executed.
The Openssl_get_publickey () function passes normally, but the Openssl_public_encrypt () function causes Apache to collapse.
Direct background execution:/path/php-f ssl-encry.php, only 1, 2 has the result, the 3rd space.
Test the normal output in a Windows environment.
How is this kind of situation solved? OpenSSL Apache PHP HTTPS
Share to:
------Solution--------------------
The Openssl_get_publickey () function passes normally, but the Openssl_public_encrypt () function causes Apache to collapse.
Check Apache error log