2016-05-06 37 views
0

我們有兩個域(兩個都是https):一個是主域https://dev.project.com/,另一個是圖像https://dev-images.project.com/。首頁加載圖像很好,但我遇到了這個問題file_get_contentsfile_get_contents():無法找到證書CN

ErrorException in Collection.php line 228: 
file_get_contents(): Unable to locate certificate CN 
in Collection.php line 228 
at HandleExceptions->handleError('2', 'file_get_contents(): Unable to locate certificate CN', '') 
at file_get_contents('https://dev-images.project.com/images/12012_resized.jpg') in Collection.php line 228 

該文件本身存在並在瀏覽器中打開時打開。我檢查this solution,但所有的測試是肯定的:

openssl: yes 
http wrapper: yes 
https wrapper: yes 
wrappers: array (size=12) ... 

的php.ini

extension=php_openssl.dll 
allow_url_fopen = On 

證書在本地生成並在php.ini中設置

curl.cainfo = "D:\wamp64\cacert.pem" 

我的dev站有使用PHP 5.6的Window10上的wamp64服務器。網站基於Laravel5。

回答

1

嘗試將路徑傳遞到您的cafile文件。

$opts=array(
    "ssl"=>array(
     "cafile" => "D:\\wamp64\\cacert.pem", 
     "verify_peer"=> true, 
     "verify_peer_name"=> true 
    ) 
); 

file_get_contents($url,false,stream_context_create($opts)); 

編輯:如果失敗,只是在你的本地服務器,檢查是否有你加入cacert.pem您的本地創建的SSL證書在您的本地服務器,它不包含任何錯誤或多餘的線條。

+0

我有大約1500個這樣的條目..不知道這是否是正確的做法,尤其是,因爲這隻會在本地窗口開發環境中失敗,但在Linux生產中工作正常...... – Peon

+0

'file_get_contents()期望參數3是資源,數組給定' – Peon

+0

這隻會失敗,在您的本地服務器?您是否在cacert.pem中添加了本地創建的SSL證書?在你的本地服務器? –

相關問題