php - Guzzle (35) gnutls_handshake() 失败 : An unexpected TLS packet was received over HTTP

标签 php ubuntu curl guzzle php-curl

我从我的服务器向其他服务器(http://example.com:8180)发送 api 请求
我得到这个错误

"cURL error 35: gnutls_handshake() failed : An unexpected TLS packet was received."



奇怪的是,当我在本地和舞台服务器上测试它时
没有问题。
生产服务器和舞台服务器的区别在于ssl的存在。
但是这可能是问题吗?

我有点相信这是关于“php curl”的,因为 guzzle 在代码中不起作用,但 curl on command 可以
我在代码中使用 curl 没有 guzzle 但仍然没有工作。
我设置CURLOPT_SSL_VERIFYPEERCURLOPT_SSL_VERIFYHOST错误但仍然没有工作。
只要我知道 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.8
echo | 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)
---

最佳答案

问题已经解决了。

我使用 laravel 并且有一个黑盒是 route() helper functiong
它根据服务器配置设置 url http 或 https
并且生产服务器设置为 https

这就是它导致错误的原因。

关于php - Guzzle (35) gnutls_handshake() 失败 : An unexpected TLS packet was received over HTTP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56672701/

相关文章:

ubuntu - saber sd 如何在没有 SPL 的情况下直接从 uboot 启动

c - 对 curl_global_init、curl_easy_init 和其他函数的 undefined reference (C)

xml - 尝试在Cocoa应用程序中发送curl POST命令

python-3.x - 如果错误代码为 404,如何在 wget 中获取准确的页面内容

postgresql - 如何重新启动特定版本的 PostgreSQL 数据库?

linux - sh\bash 脚本中的 PACKAGE 关键字到底意味着什么?

php - 从MySQL表中选择信息与PHP多查询?

php - mysql中用于不同查询的多个表

JAVASCRIPT 如何在选择选项中获得多个值

php - 根据 WooCommerce 中的自定义字段值将文本添加到订单摘要