我从服务器向其他服务器(http://example.com:8180)发送api请求 我得到这个错误
“ cURL错误35:gnutls_handshake()失败:接收到意外的TLS数据包。”
奇怪的是,当我在本地和舞台服务器上对其进行测试时
没问题。
生产服务器和阶段服务器之间的区别在于ssl的存在。
但这可能是问题吗?
我有点相信这是关于“ php curl”的,因为cuz guzzle在代码中不起作用,但是在命令中卷曲却可以
而且我在代码中使用了curl而没有花哨的地方,但是还是没用。
并且我将 Feed.aggregate([
{
$match: {
$expr: {
$and: [
{
$eq: ["$owner", req.body.authorId]
},
{
$anyElementTrue: {
$map: {
input: "$posts",
in: {
$and: [
{
$eq: ["$$this._id", req.body.postId]
},
{
$anyElementTrue: {
$map: {
input: "$$this.likes.likeList",
as: "like",
in: {
$eq: ["$$like.user", req.user._id]
}
}
}
}
]
}
}
}
}
]
}
}
}
]).then(checkedFeed => {
if (checkedFeed.length !== 0) {
return res.status(400).json({ Error: "User has already liked post" });
}
和CURLOPT_SSL_VERIFYPEER
设置为false
,但仍然无法正常工作。
只要我知道SSL没关系,因为我尝试通过HTTP连接到服务器,对吗?
下面是我编译的php,curl和服务器信息
CURLOPT_SSL_VERIFYHOST
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
答案 0 :(得分:0)
问题解决了。
我使用laravel,有一个黑箱,它是route()helper functiong 它根据服务器配置设置URL http或https 并将生产服务器设置为https
这就是导致错误的原因。
答案 1 :(得分:0)
仅此错误的参考,可能会对某些错误有所帮助。 我在使用apache服务器的ubuntu机器上遇到了类似的问题,该问题通过使用link
创建自签名证书来解决< 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>