cURL和SSL,connect()超时
我使用cURL连接到SSL服务器以回收和发送XML文件,但我一直收到
I'm using cURL to connect to a SSL server to recive and send XML-files but I keep getting
connect ) 时间到!
"connect() time out!"
当我尝试连接到服务器时。
when I try to connect to the server.
一种新的cURL,所以我不知道是否是错误的服务器配置,一些证书或什么。
I'm kind of new to cURL so I don't know if it's something wrong with the servers configuration, some certificate, or what.
我试图运行的代码由SSL服务器的所有者向我提供):
The code i'm trying to run (given to me by the owner of the SSL server):
function post($url, $post)
{
$ch = curl_init();
if($ch)
{
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT,60);
curl_setopt($ch, CURLOPT_VERBOSE,0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec($ch);
echo '<pre>', curl_error($ch);
curl_close($ch);
if(!empty($result))
return $result;
}
}
cURL版本信息:
[version_number] => 463362
[age] => 3
[features] => 1597
[ssl_version_number] => 0
[version] => 7.18.2
[host] => i486-pc-linux-gnu
[ssl_version] => OpenSSL/0.9.8g
[libz_version] => 1.2.3.3
[protocols] => Array
(
[0] => tftp
[1] => ftp
[2] => telnet
[3] => dict
[4] => ldap
[5] => ldaps
[6] => http
[7] => file
[8] => https
[9] => ftps
[10] => scp
[11] => sftp
)
消息只是意味着TCP连接过程没有完成,
The message simply means that the TCP connect procedure hasn't completed without the time allowed for the operation.
如果您尝试连接到一个应该通过TCP在给定端口可用的网站,那么您可以怀疑有防火墙,代理,NAT,路由器或其他设备,使它不适合你。
If you try to connect to a site that should be available over TCP on the given port then you can suspect that there's a firewall, proxy, NAT, router or other equipment in the way that makes it not work for you.
这不是一个真正的curl相关的问题,你应该能够验证这个例如运行telnet到同一主机+端口:telnet [host] [port],因为那也应该失败。
This is not really a curl related problem and you should be able to verify this by for example running telnet to the same host + port: "telnet [host] [port]" as that should also fail.