The*_*orn 8 php ssl curl amazon-web-services
从开发机器(mac)可以通过PHP中的cURL连接到此,但在Ubuntu中,我收到此错误.我已尝试在本地计算机和Amazon AWS实例上.我用Google搜索并用Google搜索并继续前往砖墙.没有防火墙限制,这是一个完整的谜.php5-curl IS安装在ubuntu中,我只是没有任何想法.我运行了这个命令:
curl -v https://api.rkd.reuters.com/api/2006/05/01/TokenManagement_1.svc/Anonymous
Run Code Online (Sandbox Code Playgroud)
得到这个输出,没有任何解决方案的线索.还安装了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
Run Code Online (Sandbox Code Playgroud)
任何想法都欢迎这一点
我有这个问题,我通过将curl SSL版本设置为版本3来修复它
curl_setopt($ch, CURLOPT_SSLVERSION,3);
Run Code Online (Sandbox Code Playgroud)
显然,服务器开始要求SSL版本3,此设置导致cURL与SSL重新开始工作.
小智 2
我也遇到了同样的问题,不幸的是主机不愿意升级到 php 5.5。
我通过创建一个新类来扩展 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;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
61050 次 |
| 最近记录: |