我准备使用PHP自带的SSL函数完成公钥的加密工作。但是访问这个test.php文件时,网页会一直加载,然后IE会提示网页无法显示。请各位大神看看,是不是我代码写错,或者是其他什么问题。因为PHP编辑器没有报错,我怀疑是我的Apache服务器配置的问题。
代码如下:<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>RSA</title>
</head>
<body>
<?php
$source="Test";
echo "<p>".$source."</p>";$fp=fopen("ca.crt","r");//ca.crt是X509证书文件
$pub_key=fread($fp,8192);
fclose($fp);
openssl_get_publickey($pub_key);
openssl_public_encrypt($source,$crypttext,$pub_key);
echo "String crypted: $crypttext";
?>
</body>
</html>
代码如下:<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>RSA</title>
</head>
<body>
<?php
$source="Test";
echo "<p>".$source."</p>";$fp=fopen("ca.crt","r");//ca.crt是X509证书文件
$pub_key=fread($fp,8192);
fclose($fp);
openssl_get_publickey($pub_key);
openssl_public_encrypt($source,$crypttext,$pub_key);
echo "String crypted: $crypttext";
?>
</body>
</html>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货