OPENSSL的file_get_contents():失败,使加密 [英] OPENSSL file_get_contents(): Failed to enable crypto

查看:2860
本文介绍了OPENSSL的file_get_contents():失败,使加密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要建一个个人股票平台(未分配)。我想有一个组件是此页面上的EPS图:

I'm building a personal stock platform (not distributed). A component I would like to have is the EPS graph on this page:

<一个href=\"https://eresearch.fidelity.com/eresearch/evaluate/fundamentals/earnings.jhtml?stockspage=earnings&symbols=AAPL&showPriceLine=yes\">https://eresearch.fidelity.com/eresearch/evaluate/fundamentals/earnings.jhtml?stockspage=earnings&symbols=AAPL&showPriceLine=yes

正如你所看到的网页是 HTTPS ,所以锤击出来的东西天后,我启用的OpenSSL 现在看来,为使所有 HTTPS 页面,例如Facebook和Twitter的主页工作,但是它仍然是不工作的一个我所需要的。

As you can see, the page is https, so after days of hammering things out, I enabled openssl and now it seems to work for all https pages such as the homepages of facebook and twitter, however it is still not working for the one I need.

file_get_contents('https://facebook.com'); /* works */
file_get_contents('https://twittercom'); /* works */
file_get_contents('https://eresearch.fidelity.com/eresearch/evaluate/fundamentals/earnings.jhtml?stockspage=earnings&symbols=AAPL&showPriceLine=yes');

我收到警告:

Warning: file_get_contents(): SSL: crypto enabling timeout in C:\xampp\htdocs\index.php on line 3
Warning: file_get_contents(): Failed to enable crypto in C:\xampp\htdocs\index.php on line 3
Warning: file_get_contents(https://eresearch.fidelity.com/eresearch/evaluate/fundamentals/earnings.jhtml?stockspage=earnings&symbols=AAPL&showPriceLine=yes): failed to open stream: operation failed in C:\xampp\htdocs\index.php on line 3
Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\index.php on line 3

我能看到的唯一区别是,保真页面具有HTTPS标签附近的三角形。

The only difference I can see is that the fidelity page has a triangle near the https label.

推荐答案

好吧,我已经找到了解决方案。问题是,该网站使用SSL3。而且我知道,有OpenSSL的模块中的一些问题。前一段时间我有同样的问题与SSL版本。

Ok i have found a solution. The problem is that the site use SSL3. And i know that there are some problems in the openssl module. Some time ago i had the same problem with the SSL versions.

<?php
function getSSLPage($url) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_SSLVERSION,3); 
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}

var_dump(getSSLPage("https://eresearch.fidelity.com/eresearch/evaluate/analystsOpinionsReport.jhtml?symbols=api"));
?>

当您设置SSL版本与卷曲V3那么它的工作原理。

When you set the SSL Version with curl to v3 then it works.

编辑:

Windows下的另一个问题是,你还没有获得证书。所以,把根证书直接卷曲。

Another problem under Windows is that you haven't access to the certificates. So put the root certificates directly to curl.

http://curl.haxx.se/docs/caextract.html

在这里你可以下载根证书。

here you can download the root certificates.

curl_setopt($ch, CURLOPT_CAINFO, __DIR__ . "/certs/cacert.pem");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);

,那么你可以使用带有 CURLOPT_SSL_VERIFYPEER 选项真正,否则你会得到错误。

then you can use the CURLOPT_SSL_VERIFYPEER option with true otherwise you get an error.

这篇关于OPENSSL的file_get_contents():失败,使加密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆