php cURL 错误 35 - 与 api.rkd.reuters.com:443 相关的未知 SSL 协议错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19384161/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
cURL error 35 - Unknown SSL protocol error in connection to api.rkd.reuters.com:443
提问by ThePHPUnicorn
From development machine (mac) there is no problem connecting via cURL in PHP to this, but in Ubuntu, I get this error. I've tried on a local machine and on an Amazon AWS instance. I've googled and googled and keep coming up to brick walls. There's no firewall restrictions in place, its a complete mystery. php5-curl IS installed in ubuntu, I just don't have any ideas. I ran this command:
从开发机器(mac)通过 PHP 中的 cURL 连接到此没有问题,但在 Ubuntu 中,我收到此错误。我已经在本地机器和 Amazon AWS 实例上尝试过。我用谷歌搜索和谷歌搜索,并不断来到砖墙。没有防火墙限制,这完全是个谜。php5-curl IS安装在ubuntu中,我只是没有任何想法。我运行了这个命令:
curl -v https://api.rkd.reuters.com/api/2006/05/01/TokenManagement_1.svc/Anonymous
and got this output, no clues whatsoever to a solution. OpenSSL is also installed.
并得到了这个输出,没有任何解决方案的线索。还安装了 OpenSSL。
* About to connect() to api.rkd.reuters.com port 443 (#0)
* Trying 159.220.40.240... connected
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* Unknown SSL protocol error in connection to api.rkd.reuters.com:443
* Closing connection #0
curl: (35) Unknown SSL protocol error in connection to api.rkd.reuters.com:443
Any ideas welcomed on this
欢迎对此提出任何想法
采纳答案by tripper54
I had the same problem, unfortunately with a host unwilling to upgrade to php 5.5.
我遇到了同样的问题,不幸的是,主机不愿意升级到 php 5.5。
I solved it by creating a new class extending php's SoapClient to use cURL:
我通过创建一个扩展 php 的 SoapClient 以使用 cURL 的新类来解决它:
/**
* New SoapClient class.
* This extends php's SoapClient,
* overriding __doRequest to use cURL to send the SOAP request.
*/
class SoapClientCurl extends SoapClient {
public function __doRequest($request, $location, $action, $version, $one_way = NULL) {
$soap_request = $request;
$header = array(
'Content-type: application/soap+xml; charset=utf-8',
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: \"$action\"",
"Content-length: " . strlen($soap_request),
);
$soap_do = curl_init();
$url = $location;
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => FALSE,
//CURLOPT_FOLLOWLOCATION => true,
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_RETURNTRANSFER => TRUE,
//CURLOPT_USERAGENT => 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)',
CURLOPT_VERBOSE => true,
CURLOPT_POST => TRUE,
CURLOPT_URL => $url,
CURLOPT_POSTFIELDS => $soap_request,
CURLOPT_HTTPHEADER => $header,
CURLOPT_FAILONERROR => TRUE,
CURLOPT_SSLVERSION => 3,
);
curl_setopt_array($soap_do, $options);
$output = curl_exec($soap_do);
if ($output === FALSE) {
$err = 'Curl error: ' . curl_error($soap_do);
}
else {
///Operation completed successfully
}
curl_close($soap_do);
// Uncomment the following line to let the parent handle the request.
//return parent::__doRequest($request, $location, $action, $version);
return $output;
}
}
回答by steampowered
I had this problem, and I fixed it by setting the curl SSL version to version 3
我遇到了这个问题,我通过将 curl SSL 版本设置为版本 3 来修复它
curl_setopt($ch, CURLOPT_SSLVERSION,3);
Apparently the server started requiring SSL version 3, and this setting caused cURL with SSL to start working again.
显然,服务器开始需要 SSL 版本 3,此设置导致带有 SSL 的 cURL 再次开始工作。
回答by ThePHPUnicorn
Fixed it! It's a known problem with Ubuntu 12.04
修复!这是 Ubuntu 12.04 的一个已知问题
These instructions
这些说明
-- Cancel that, it just disabled exceptions, this is still not working! HELP!
-- 取消那个,它只是禁用了异常,这仍然不起作用!帮助!
-- EDIT - HERES HOW I FIXED IT IN THE END!
-编辑 - 这是我最终修复它的方式!
I upgraded to PHP 5.5 from 5.4.3 and set the following options in my call, which fixed it:
我从 5.4.3 升级到 PHP 5.5 并在我的调用中设置了以下选项,修复了它:
$options = array('ssl_method' => SOAP_SSL_METHOD_SSLv3,'soap_version' => SOAP_1_2);
$sc = new SoapClient('https://my-url.com/call/', $options);
The upgrade was necessary because the constant SOAP_SSL_METHOD_SSLv3 isn't present in PHP versions < 5.5, and unfortunately Ubuntu Server at the time would only allow an upgrade to 5.4.3 through apt-get update php5. I manually installed the later version, and it works fine now.
升级是必要的,因为 PHP 版本 < 5.5 中不存在常量 SOAP_SSL_METHOD_SSLv3,不幸的是,当时的 Ubuntu Server 只允许通过 apt-get update php5 升级到 5.4.3。我手动安装了更高版本,现在工作正常。
回答by Arun Krish
Error : CURL Error: 35 - OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to httpapi.com:443 (IP: 162.x.x.x & 204.x.x.x)
错误:CURL 错误:35 - OpenSSL SSL_connect:SSL_ERROR_SYSCALL 连接到 httpapi.com:443(IP:162.xxx 和 204.xxx)
Incase of WHMCS:
WHMCS 的情况:
You can contact your host to whitelist the IP address at their end to use their API.
您可以联系您的主机将 IP 地址列入白名单以使用他们的 API。
回答by cnmuc
Fixed by adding curl-ca-bundle.crt to the folder next to curl.exe
通过将 curl-ca-bundle.crt 添加到 curl.exe 旁边的文件夹来修复