我已经在 ubuntu 14.04 上成功编译了 php7.1.30。当我测试代码的和平时
/ Get cURL resource
$curl = curl_init();
// Set some options - we are passing in a useragent too here
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => 'https://buy.itunes.apple.com',
CURLOPT_USERAGENT => 'Codular Sample cURL Request',
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => [
'item1' => 'value',
'item2' => 'value2'
]
]);
curl_setopt($curl, CURLOPT_VERBOSE, true);
// Send the request & save response to $resp
$resp = curl_exec($curl);
// Close request to clear up some resources
if (!$resp) {
echo('Error: "' . curl_error($curl) . '" - Code: ' . curl_errno($curl));
echo "\n";
}
curl_close($curl);
我有错误 Error: "gnutls_handshake() failed: Illegal parameter" - Code: 35
详细的输出是:
Rebuilt URL to: https://buy.itunes.apple.com/
* Hostname was NOT found in DNS cache
* Trying 17.173.66.180...
* Connected to buy.itunes.apple.com (17.173.66.180) port 443 (#0)
* found 148 certificates in /etc/ssl/certs/ca-certificates.crt
* gnutls_handshake() failed: Illegal parameter
* Closing connection 0
有时这会成功,似乎苹果 TLS 支持不一致。
但是,如果我在 Ubuntu 18.04 上构建相同的代码,它可以 100% 工作,如果我再次使用 php 5.5.9(dist 版本)运行相同的代码,则 100% 工作。
到目前为止,我计划升级到 ubuntu 18.04 以使其正常工作,因为我未能克服上述问题。我尝试了不同的 /etc/ssl/cert ca 文件但没有成功。
尚方宝剑之说