gpt4 book ai didi

node.js - NodeJS https请求中的证书问题

转载 作者:太空宇宙 更新时间:2023-11-04 03:17:42 25 4
gpt4 key购买 nike

我在发出 https get 请求时遇到以下错误

{ Error: write EPROTO 101057795:error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure:openssl\ssl\s23_clnt.c:802:
at _errnoException (util.js:992:11)
at WriteWrap.afterWrite [as oncomplete] (net.js:864:14) code: 'EPROTO', errno: 'EPROTO', syscall: 'write' }

我正在尝试向不需要代理的公司内部资源发出请求。

const request = require('request')
var token= myToken
request({
method: 'post',
url: 'https://myURL',
data: {
myData
},
headers: { 'Authorization': 'Bearer myToken' },
agentOptions: {
rejectUnauthorized: false,
},
}, function (error, response, body) {
if(error){
console.log('Error: ', error)
} else {
console.log(body)
}
})

我的 .npmrc 中也有 strict-ssl=false。

我注意到我可以毫无问题地进行相同的调用curl。

curl -k1 -XPOST -H "Authorization: Bearer %TOKEN%" "https://%URL% -d @data,json -H "content-type: application/json"
curl 中的

-k1 选项似乎解决了证书问题。

我在 JavaScript 中做错了什么?

最佳答案

原来是node版本8的一个bug,我终于在这里找到了解决方案-https://github.com/nodejs/node/issues/16196

需要将以下内容添加到她的代码中:

require("tls").DEFAULT_ECDH_CURVE = "自动"

关于node.js - NodeJS https请求中的证书问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54143381/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com