我正在尝试用 PHP 向 URL 发出 cURL 请求。无论我尝试什么,我总是得到 cURL errno 35 (对于特定的 URI)。 curl 文档有以下内容:
You really want the error buffer and read the message there as it pinpoints the problem slightly more. Could be certificates (file formats, paths, permissions), passwords, and others.
然而,当 try catch 此信息时,似乎没有返回任何内容。
$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);
上面的代码总是抛出错误号为 35 的 CurlException
,但是定义的日志文件仍然是空的。
尝试时 a different URI (使用来自同一 CA 的证书)它可以正常工作 ™。我还检查了我的根 CA 包,它是最新的:
Certificate data from Mozilla downloaded on: Wed Sep 3 03:12:03 2014
我还可以检查什么来找出导致错误的具体原因?
注意:可以从浏览器和我的本地开发环境中请求 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 有一个很好的 blog post关于这个问题。
否则,您需要针对 OpenSSL 重新编译 cURL 才能访问所有可用的密码。基本说明可在 http://curl.haxx.se/docs/install.html 获得。 .
关于php - 如何调试或修复 cURL errno 35,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28419197/