openssl 関数は https
では使用できません 問題: Linux apache2 php5 環境で、https にアクセスできるように ssl を設定し、テスト コードを実行します:
<br /> <?php<br /> #ssl-encry.php<br /> $source = "This is encry-content.";<br /> echo "1.Source: $source";<br /> $fp=fopen("/path/to/certificate.crt","r");<br /> $pub_key=fread($fp,8192);<br /> fclose($fp);<br /> openssl_get_publickey($pub_key);<br /> openssl_public_encrypt($source,$crypttext,$pub_key);<br /> echo "2.String crypted: $crypttext";<br /> <br /> $fp=fopen("/path/to/private.key","r");<br /> $priv_key=fread($fp,8192);<br /> fclose($fp);<br /> // $passphrase is required if your key is encoded (suggested)<br /> $passphrase = '';<br /> $res = openssl_get_privatekey($priv_key,$passphrase);<br /> openssl_private_decrypt($crypttext,$newsource,$res);<br /> echo "3.String decrypt : $newsource";<br /> ?> <br /> <br />