簡體   English   中英

如何調試或修復cURL errno 35

[英]How to debug or fix cURL errno 35

我正在嘗試用PHP將cURL請求發送到URL。 無論我嘗試什么,我總是得到一個cURL errno 35 (針對特定的URI)。 curl文檔有如下說法:

你真的想要錯誤緩沖區並在那里閱讀消息,因為它會稍微查明問題。 可以是證書(文件格式,路徑,權限),密碼等。

但是,當試圖捕獲此信息時,似乎沒有返回任何內容。

$client = curl_init('https://dev.kelunik.com/css/all.min.css')

$log = fopen('/srv/www/Requestable/data/curl-log.txt', 'a+');

curl_setopt($client, CURLOPT_VERBOSE, 1);
curl_setopt($client, CURLOPT_STDERR, $log);
curl_setopt($client, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($client, CURLOPT_SSL_VERIFYHOST, 2)
curl_setopt($client, CURLOPT_CAINFO, __DIR__ . '/../../../../data/default.pem');
curl_setopt($client, CURLOPT_FAILONERROR, false);
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
curl_setopt($client, CURLOPT_HEADER, true);
curl_setopt($client, CURLINFO_HEADER_OUT, true);
curl_setopt($client, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($client, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($client, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);

if (!$response = curl_exec($client)) {
    throw new CurlException('Making request failed: ' . curl_error($client) . '(' . curl_errno($client) . ')');
}

fclose($log);

上面的代碼總是使用errno 35拋出CurlException ,但是定義的日志文件保持為空。

當嘗試不同的URI (使用來自同一CA的證書)時,它只能工作。 我還檢查了我的根CA捆綁,這是相當up2date:

來自Mozilla的證書數據下載日期:2014年9月3日星期三03:12:03

還有什么可以檢查以找出導致錯誤的具體內容?

注意:可以從瀏覽器以及本地開發環境中請求URI

注意2:我也嘗試了它而沒有手動設置自定義CA根捆綁導致相同的錯誤。

OpenSSL版本:

Installed Packages
Name        : openssl
Arch        : x86_64
Version     : 1.0.1e
Release     : 30.el6_6.5

cURL版本:

curl 7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.16.2.3 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
Protocols: tftp ftp telnet dict ldap ldaps http file https ftps scp sftp
Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz

問題與您的證書鏈無關,它是dev.kelunik.com上的服務器配置。 服務器只接受ECDHE密碼( ssllabs )。 另一台服務器接受更廣泛的密碼。 ssllabs )。 雖然您的OpenSSL支持ECDHE,但您使用的cURL版本是使用NSS編譯的,而NSS則沒有。

您可以將輸出與

curl https://dev.kelunik.com

openssl s_client -connect dev.kelunik.com:443 -servername dev.kelunik.com 

你有兩個解決方案在這里沒有改變你的發行版。 如果您可以訪問其他服務器的配置,則可以更改SSL密碼以使用DHE / RSA密碼。 確切的密碼列表將取決於服務器配置 - ssllabs有關於該主題的好博客文章

否則,您需要針對OpenSSL重新編譯cURL以訪問所有可用的密碼。 有關基本說明,請訪問http://curl.haxx.se/docs/install.html

我把你的代碼放在一個文件test.php中並在命令行php test.php上運行,它運行正常(在命令行上打印“完成”)。

以下是test.php的內容(代碼中的小修改)。 我的php有版本Zend Engine v2.4.0,它運行在Ubuntu 12.04上。

<?php>
$client = curl_init('https://dev.kelunik.com/css/all.min.css');
$log = fopen('/tmp/curl-log.txt', 'a+');

curl_setopt($client, CURLOPT_VERBOSE, 1);
curl_setopt($client, CURLOPT_STDERR, $log);
curl_setopt($client, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($client, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($client, CURLOPT_CAINFO, "/etc/ssl/certs/ssl-cert-snakeoil.pem");
curl_setopt($client, CURLOPT_FAILONERROR, false);
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
curl_setopt($client, CURLOPT_HEADER, true);
curl_setopt($client, CURLINFO_HEADER_OUT, true);
curl_setopt($client, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($client, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($client, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);

if (!$response = curl_exec($client)) {
    throw new CurlException('Making request failed: ' . curl_error($client) . '(' . curl_errno($client) . ')');
} else {
    echo "done!\n";
}

fclose($log);
?>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM