无法使用 cURL 连接到 HTTPS 站点.而是返回 0 长度的内容.我能做什么? [英] Can't connect to HTTPS site using cURL. Returns 0 length content instead. What can I do?
问题描述
我有一个使用 cURL(最新版本)连接到安全网关进行支付的站点.
I have a site that connects using cURL (latest version) to a secure gateway for payment.
问题是 cURL 总是返回 0 长度的内容.我只得到标题.并且仅当我设置 cURL 以返回标头时.我有以下标志.
The problem is cURL always returns 0 length content. I get headers only. And only when I set cURL to return headers. I have the following flags in place.
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_URL, $gatewayURI);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_POST, 1);
返回的头是
HTTP/1.1 100 Continue
HTTP/1.1 200 OK
Date: Tue, 25 Nov 2008 01:08:34 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
Content-Length: 0
Content-Type: text/html
Set-Cookie: ASPSESSIONIDxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; path=/
Cache-control: private
我也尝试过对不同网站进行 cURL 访问,它们返回的内容很好.我认为问题可能与 https 连接有关.
I have also tried cURL'ing different sites and they return content fine. I think the problem might have something to do with the https connection.
我已经和公司谈过了,他们没有帮助.
I have spoken with the company and they are unhelpful.
有没有其他人遇到过这个错误并知道解决方法?我应该放弃 cURL 并尝试使用 fsockopen()
吗?
Has anyone else experienced this error and know a work around? Should I ditch cURL and try and use fsockopen()
?
谢谢.:)
推荐答案
您还应该尝试检查 curl_error() 中的错误消息.您可能需要在每个 curl_* 函数之后执行一次此操作.
You should also try checking the error messages in curl_error(). You might need to do this once after each curl_* function.
这篇关于无法使用 cURL 连接到 HTTPS 站点.而是返回 0 长度的内容.我能做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!