OPENSSL file_get_contents(): Failed to enable crypto

前端 未结 2 840
渐次进展
渐次进展 2020-11-27 04:46

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

https://eresearch.fidelity.com/eresearch/e

2条回答
  •  一整个雨季
    2020-11-27 05:44

    Had same problem - it was somewhere in the ca certificate, so I used the ca bundle used for curl, and it worked. You can download the curl ca bundle here: https://curl.haxx.se/docs/caextract.html

    For encryption and security issues see this helpful article:
    https://www.venditan.com/labs/2014/06/26/ssl-and-php-streams-part-1-you-are-doing-it-wrongtm/432

    Here is the example:

        $url = 'https://www.example.com/api/list';
        $cn_match = 'www.example.com';
    
        $data = array (     
            'apikey' => '[example api key here]',               
            'limit' => intval($limit),
            'offset' => intval($offset)
            );
    
        // use key 'http' even if you send the request to https://...
        $options = array(
            'http' => array(
                'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
                'method'  => 'POST',                
                'content' => http_build_query($data)                
                )
            , 'ssl' => array(
                'verify_peer' => true,
                'cafile' => [path to file] . "cacert.pem",
                'ciphers' => 'HIGH:TLSv1.2:TLSv1.1:TLSv1.0:!SSLv3:!SSLv2',
                'CN_match' => $cn_match,
                'disable_compression' => true,
                )
            );
    
        $context  = stream_context_create($options);
        $response = file_get_contents($url, false, $context);
    

    Hope that helps

提交回复
热议问题