无法使用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'ing不同的网站他们返回内容很好。我认为问题可能与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屋!