PHP "Unknown SSL protocol error in connection to"即使我强制使用 SSL V3

标签 php ssl curl

从今天早上开始,我的一个使用 Curl 的脚本出现了问题。错误是“连接到 example.com:443 时发生未知 SSL 协议(protocol)错误”。

我尝试强制使用 SSL VERSION 3,但结果是一样的。

curl_setopt($curl, CURLOPT_SSLVERSION,3); 

这是我的代码:

$url = "https://example.com/abc/abc";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE );
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($curl, CURLOPT_ENCODING, 'UTF-8');
curl_setopt($curl, CURLOPT_SSLVERSION,3);
curl_setopt($curl, CURLOPT_POST, TRUE);
curl_setopt($curl, CURLOPT_POSTFIELDS, $json2send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
$part4 = curl_exec($curl);

我尝试了一个命令,它是一样的:

curl -I -v --sslv3 https://example.com/abc/abc
* About to connect() to example.com port 443 (#0)
*   Trying X.X.X.X...
* connected
* Connected to example.com (X.X.X.X) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: none
  CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* Unknown SSL protocol error in connection to example.com:443
* Closing connection #0
curl: (35) Unknown SSL protocol error in connection to example.com:443

我不知道现在该怎么办......或者如何以更好的方式跟踪这个错误

curl 版本

curl 7.26.0 (x86_64-pc-linux-gnu) libcurl/7.26.0 OpenSSL/1.0.1e zlib/1.2.7 libidn/1.25 libssh2/1.4.2 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap pop3 pop3s rtmp rtsp scp sftp smtp smtps telnet tftp
Features: Debug GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP

PHP 版本

PHP 5.4.36-0+deb7u3 (cli) (built: Jan  9 2015 08:07:06)

OpenSSL 版本

OpenSSL 1.0.1e 11 Feb 2013

我尝试了太多使用 Curl 7.36 和 7.37 的服务器并遇到了同样的问题。我没有找到解决方案...

谢谢

最佳答案

也许您尝试连接的服务器不支持 SSL(很可能是这种情况)
您是否尝试过改用 TLS 1/1.1/1.2?

另外请发布
的输出 openssl 版本

关于PHP "Unknown SSL protocol error in connection to"即使我强制使用 SSL V3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28168860/

相关文章:

php - 从 php 运行 csf 命令而不是 root

php - 如何在 2 个独立服务器之间创建共享 secret 凭证代码系统?

php - 创建用户角色 Symfony2 的问题

ssl - openssl的不同输出

php - 在 php 中使用 Curl 时读取 Cookie,如何?

php - 使用 CodeIgniter 将图像上传到我的数据库

ssl - curl 命令有效,但 C 程序失败 NSS : client certificate not found (nickname not specified)

Facebook Canvas 不加载 Url,即使它有 SSL

cURL: (7) 连接失败; Openstack Swift 上的连接被拒绝

json - 在 jq 中使用 curl/bash 命令