当我尝试读取网站中的某些 HTTPS 网址时遇到问题。
如果我使用“http”,则没有问题(使用file_get_contents和curl),但是当我用“https”替换“http”时,这些方法不起作用。
我收到一些错误:
failed to open stream: operation failed occured
Failed to enable crypto occured
SSL operation failed with code 1. OpenSSL Error messages: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
在我的浏览器中,所有方法都有效:https://ssl10.ovh.net/~fyprbqhq/_perso/facebook.myclimb/test.php https://ssl10.ovh.net/~fyprbqhq/_perso/facebook.myclimb/test.php(显示屏应显示“OK”)
在 phpinfo() 中我得到:
openssl
OpenSSL support enabled
OpenSSL Version OpenSSL 0.9.8c 05 Sep 2006
如果您有任何想法。
感谢帮助。
(PS:在我的例子中,get_headers() 也不适用于 https)
更多信息:
文件获取内容:
$data = file_get_contents("https://ssl10.ovh.net/~fyprbqhq/_perso/facebook.myclimb/test.php");
Curl:
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, "http://ssl10.ovh.net/~fyprbqhq/_perso/facebook.myclimb/test.php");
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT,2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, false);
$data = curl_exec($curl_handle);
curl_close($curl_handle);