我从我的服务器向其他服务器(http://example.com:8180)发送一个api请求,并得到这个错误
"cURL错误35: gnutls_handshake()失败:接收到意外的TLS数据包。“
奇怪的是,当我在本地和舞台服务器上测试它时,没有问题。
生产和阶段服务器的区别在于ssl的存在。
但会不会是问题所在?
我有点相信这是关于"php curl“的,因为在代码中不起作用,但是命令上的curl是起作用的
我用的是卷曲,代码中没有口香糖,但仍然没有效果。
我把CURLOPT_SSL_VERIFYPEER和CURLOPT_SSL_VERIFYHOST设为false
但还是没用。
而且,只要我知道SSL并不重要,因为我尝试连接到HTTP上的服务器,对吗?
这是我编译的php,curl,下面的服务器信息
PHP Version => 7.2.1
System => Linux ip-x-x-x-x 4.4.0-1060-aws #69-Ubuntu SMP Sun May 20 13:42:07 UTC 2018 x86_64
Build Date => Jan 31 2019 05:39:24
Configure Command => './configure' '--enable-fpm' '--with-openssl' '--with-pdo-mysql' '--enable-mbstring' '--with-libxml-dir' '--enable-intl' '--with-gettext' '--with-mhash' '--with-gd' '--with-pc
re-jit' '--with-zlib' '--enable-bcmath' '--enable-calendar' '--with-zlib-dir' '--with-curl' '--enable-zip'
curl
cURL support => enabled
cURL Information => 7.47.0
Age => 3
Features
AsynchDNS => Yes
CharConv => No
Debug => No
GSS-Negotiate => No
IDN => Yes
IPv6 => Yes
krb4 => No
Largefile => Yes
libz => Yes
NTLM => Yes
NTLMWB => Yes
SPNEGO => Yes
SSL => Yes
SSPI => No
TLS-SRP => Yes
HTTP2 => No
GSSAPI => Yes
KERBEROS5 => Yes
UNIX_SOCKETS => Yes
PSL => No
Protocols => dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3, pop3s, rtmp, rtsp, smb, smbs, smtp, smtps, telnet, tftp
Host => x86_64-pc-linux-gnu
SSL Version => GnuTLS/3.4.10
ZLib Version => 1.2.8echo | openssl s_client -connect x.x.x.x:8180
CONNECTED(00000003)
139662896404120:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:s23_clnt.c:794:
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 7 bytes and written 305 bytes
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
Protocol : TLSv1.2
Cipher : 0000
Session-ID:
Session-ID-ctx:
Master-Key:
Key-Arg : None
PSK identity: None
PSK identity hint: None
SRP username: None
Start Time: 1560955018
Timeout : 300 (sec)
Verify return code: 0 (ok)
---发布于 2019-06-20 02:33:26
问题解决了。
我使用laravel,有一个黑盒,它是sets ()助手功能,它根据服务器配置设置url http或https,而生产服务器被设置为https。
这就是它导致错误的原因。
发布于 2020-07-11 05:42:06
只是为了参考这个错误,这可能会对某个人有所帮助。在我的ubuntu机器上,apache服务器也遇到了类似的问题,我通过使用链接创建自签名证书来解决这个问题。
< HTTP/1.1 200 Connected
<
* Proxy replied OK to CONNECT request
* found 127 certificates in /etc/ssl/certs/ca-certificates.crt
* found 508 certificates in /etc/ssl/certs
* ALPN, offering http/1.1
* gnutls_handshake() failed: An unexpected TLS packet was received.
* Closing connection 0
curl: (35) gnutls_handshake() failed: An unexpected TLS packet was received.如果您正在使用curl并面对下面的错误,即使在创建证书并启用它之后,您也可以在curl命令中使用--cacert <certificate name>。
错误:curl: (60) server certificate verification failed.
试试这个:curl --cacert <certificate_name>.crt https://<your IP>:<Port>
https://stackoverflow.com/questions/56672701
复制相似问题