node.js 节点请求 - 出现错误“SSL23_GET_SERVER_HELLO:未知协议”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15421050/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 13:52:17  来源:igfitidea点击:

node-request - Getting error "SSL23_GET_SERVER_HELLO:unknown protocol"

javascriptnode.jssslrequest

提问by umutm

I'm using the node-requestmodule, regularly sending GET requests to a set of URLs and, sometimes, getting the error below on some sites.

我正在使用节点请求模块,定期向一组 URL 发送 GET 请求,有时,在某些站点上会收到以下错误。

Error: 29472:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:openssl\ssl\s23_clnt.c:683

Error: 29472:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:openssl\ssl\s23_clnt.c:683

The problem is that I don't get this error always or always on the some URLs, just sometimes. Also, it can't be ignored with "strictSSL: false".

问题是我不会总是或总是在某些 URL 上收到此错误,只是有时。此外,它不能被“ strictSSL: false”忽略。

I have read that this can be related to me sending SSL requests with the wrong protocol (SSLv2, SSLv3, TLS..). But this doesn't explain why it happens irregularly.

我读到这可能与我使用错误的协议(SSLv2、SSLv3、TLS ..)发送 SSL 请求有关。但这并不能解释为什么它会不规则地发生。

Btw, I'm running nodejs on a Win 2008 server.

顺便说一句,我在 Win 2008 服务器上运行 nodejs。

Any help is appreciated.

任何帮助表示赞赏。

采纳答案by umutm

This was totally my bad.

这完全是我的错。

I was using standard node http.request on a part of the code which should be sending requests to only http adresses. Seems like the db had a single https address which was queried with a random interval.

我在代码的一部分上使用了标准节点 http.request,该代码应该只向 http 地址发送请求。似乎数据库有一个 https 地址,该地址以随机间隔进行查询。

Simply, I was trying to send a http request to https.

简单地说,我试图向 https 发送 http 请求。

回答by Gaf King

You will get such error message when you request HTTPS resource via wrong port, such as 80. So please make sure you specified right port, 443, in the Request options.

当您通过错误的端口(例如 80)请求 HTTPS 资源时,您将收到此类错误消息。因此请确保您在请求选项中指定了正确的端口 443。

回答by Ben

I got this error because I was using require('https')where I should have been using require('http').

我收到此错误是因为我require('https')在本应使用的地方使用require('http').

回答by user207421

Some of the sites are speaking SSLv2, or at least sending an SSLv2 server-hello, and your client doesn't speak, or isn't configured to speak, SSLv2. You need to make a policy decision here. SSLv2 should have vanished from the face of the earth years ago, and sites that still use it are insecure. However, if you gotta talk to them, you just have to enable it at your end, if you can. I would complain to the site owners though if you can.

一些站点使用 SSLv2,或者至少发送 SSLv2 server-hello,而您的客户端不使用或未配置为使用 SSLv2。您需要在此处做出政策决定。SSLv2 早在几年前就应该从地球上消失了,仍然使用它的网站是不安全的。但是,如果您必须与他们交谈,则只需在最后启用它(如果可以)。如果可以的话,我会向网站所有者投​​诉。

回答by Flament Micka?l

I had this problem (403 error for each package) and I found nothing great in the internet to solve it. My .npmrcfile inside my user folder was wrong and misunderstood.I changed this npmrc line from

我遇到了这个问题(每个包都有 403 错误),我在互联网上找不到什么好的解决方法。 我的.npmrc我的用户文件夹内的文件是错误和误解。我改变了这个 npmrc 行

proxy=http://XX.XX.XXX.XXX:XXX/

to :

到 :

proxy = XX.XX.XXX.XXX:XXXX

回答by user3180229

var https = require('https');
https.globalAgent.options.secureProtocol = 'SSLv3_method';

回答by Prateek Mishra

So in Short,

所以简而言之,

vi ~/.proxy_info

export http_proxy=<username>:<password>@<proxy>:8080
export https_proxy=<username>:<password>@<proxy>:8080

source ~/.proxy_info

Hope this helps someone in hurry :)

希望这可以帮助匆忙的人:)

回答by Denisix

in my case (the website SSL uses ev curves) the issue with the SSL was solved by adding this option ecdhCurve: 'P-521:P-384:P-256'

在我的情况下(网站 SSL 使用 ev 曲线),通过添加此选项ecdhCurve: 'P-521:P-384:P-256'解决了 SSL 的问题

request({ url, 
   agentOptions: { ecdhCurve: 'P-521:P-384:P-256', }
}, (err,res,body) => {
...

JFYI, maybe this will help someone

JFYI,也许这会帮助某人

回答by MohanBabu

I got this error, while using it on my rocketchat to communicate with my gitlab via enterprise proxy,

我收到此错误,在我的火箭聊天中使用它通过企业代理与我的 gitlab 通信时,

Because, was using the https://:8080 but actually, it worked for http://:8080

因为,使用的是 https://:8080 但实际上,它适用于 http://:8080

回答by Diaa Kasem

I got this error while connecting to Amazon RDS. I checked the server status 50% of CPU usage while it was a development server and no one is using it.

连接到 Amazon RDS 时出现此错误。当它是开发服务器时,我检查了服务器状态 50% 的 CPU 使用率,但没有人使用它。

It was working before, and nothing in the connection configuration has changed. Rebooting the server fixed the issue for me.

它之前可以工作,并且连接配置中没有任何变化。重新启动服务器为我解决了这个问题。