php cURL Unknown SSL protocol error in connection to vendor.tanga.com:443
来源:互联网 发布:网络通信介质 编辑:程序博客网 时间:2024/06/06 04:00
最近在对接国外的Tanga电商平台,代码在本地已经开发完毕,本地测试OK,已经把店铺的订单导入到本地测试环境了。心情满满的高兴,但是没想到部署到生产环境,就出现问题了。
环境对比:
服务器环境:Windows Server 2003 PHP 5.2.17 / OpenSSL 0.9.8
本地环境:Window 7 PHP 5.4.45 / OopenSSL 1.0.2j
接口调用的公共方法:
注意 CURLOPT_SSLVERSION 设置为1
public function curlGet($url,$parameters = array(),$header = array()){ if($parameters){ $url .= '?'.http_build_query($parameters); } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSLVERSION, 1); if($header) curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 300); curl_setopt($ch, CURLOPT_TIMEOUT, 100); $result = curl_exec($ch); $error = curl_error($ch); return json_decode($result,true); }
服务器访问API对接方法,提示错误:
Unknown SSL protocol error in connection to vendor.tanga.com:443
首先怀疑是产生服务器SSL协议版本过低,把本地环境切换到 PHP 5.2.17,果然出现与服务器一样的错误。
升级服务器版本到 PHP 5.4.45后,配置计划任务调用API方法,运行计划任务发现问题依然存在。
但是在浏览器直接运行API文件却调用无异常出现。
分析:浏览器调用和计划任务调用可能运行的环境不一样
方案:计划任务运行时通过cURL HTTP方式运行API文件(https://127.0.0.1/testapi.php)
结果:计划任务运行正常。
$ch = curl_init();curl_setopt($ch, CURLOPT_POST, 0);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_HEADER, 0);curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);curl_setopt($ch, CURLOPT_TIMEOUT, 5);curl_setopt($ch, CURLOPT_URL,'http://localhost/testapi.php');curl_exec($ch);curl_close($ch);
这里通过 cURL调用 testapi.php文件,是通过HTTP协议调用,而不是通过计划任务 php 命令直接调用testapi.php文件,这两者可能有一些区别,可能只SSL证书的问题?
阅读全文
0 0
- php cURL Unknown SSL protocol error in connection to vendor.tanga.com:443
- curl: <35> Unknown SSL protocol error in connection to developer.apple.com:443
- Unknown SSL protocol error in connection to github.com:443
- Unknown SSL protocol error in connection to github.com:-9800
- 设置git代理:转:解决Unknown SSL protocol error in connection to code.google.com:443
- Py第十八问Unknown SSL protocol error in connection to github.com:443
- Unknown SSL protocol error in connection to xxx:443
- Git Unknown SSL protocol error in connection to git.oschina.net:44
- IntelliJ IDEA中Push failed: Failed with error: unable to access xx:Unknown SSL protocol error in
- PHP出现 cURL error 60: SSL certificate: unable to get local issuer certificate.的解决办法。
- Error:Unknown host 'android.oa.com'. You may need to adjust the proxy settings in Gradle.
- Error: unknown host ‘android.oa.com'.You may need to adjust the proxy setting in Gradle.
- Caused by: com.rabbitmq.client.ShutdownSignalException: connection error; protocol method:
- PHP连接错误ldap_bind(): Unable to bind to server: Protocol error in
- @ERROR: Unknown module 'cookie.com' rsync error: error starting client-server protocol (code 5) at m
- PHP Warning: File upload error - unable to create a temporary file in Unknown on line 0
- Connection to http://dl-ssl.google.com refused 的解决方法
- 解决“Connection to https://dl-ssl.google.com refused”问题
- 在XFire中创建WebService客户端的三种常用方式(转)
- linux 监测进程运行,如果没在运行就重启
- delphi连接数据库程序 报ORA-06413: 连接未打开
- iOS开发移除子视图控制器
- 关于VS2013中scanf不能使用的原因
- php cURL Unknown SSL protocol error in connection to vendor.tanga.com:443
- Vue-cli proxyTable 解决开发环境的跨域问题(转)
- Java获取客户端IP地址、MAC地址,根据IP获取地理位置信息代码
- hdu5512
- 使用mina框架内存溢出的问题
- 注册页面
- 标题の我也不知道该叫什么
- raw socket in linux
- 1M带宽、1Mbps、1Mb/s 区分