【发布时间】:2019-02-04 02:33:01
【问题描述】:
我有简单的 Node.js HTTPS 服务器
const https = require('https');
const fs = require('fs');
const config = {
key: fs.readFileSync('cert/server-key.pem'),
cert: fs.readFileSync('cert/server-crt.pem'),
ca: fs.readFileSync('cert/ca-crt.pem'),
};
const server = https.createServer(config, ((req, res) => {
console.log('Got request');
res.end();
}));
server.listen(3333);
我在嵌入式系统上使用curl。
# curl -V
curl 7.52.1 (arm-unknown-linux-gnu) libcurl/7.52.1 wolfSSL/3.9.8
Protocols: file ftp ftps http https smtp smtps telnet tftp
Features: IPv6 Largefile SSL UnixSockets
当我使用版本 10 以外的 Node.js 时 - 一切正常。
在 Node.js v8.2.1
上运行的 HTTPS 服务器# curl -k -v "https://10.43.11.128:3333/"
* Trying 10.43.11.128...
* TCP_NODELAY set
* Connected to 10.43.11.128 (10.43.11.128) port 3333 (#0)
* SSL connected
> GET / HTTP/1.1
> Host: 10.43.11.128:3333
> User-Agent: curl/7.52.1
> Accept: */*
在 Node.js v10.1.0
上运行的 HTTPS 服务器# curl -k -v "https://10.43.11.128:3333/"
* Trying 10.43.11.128...
* TCP_NODELAY set
* Connected to 10.43.11.128 (10.43.11.128) port 3333 (#0)
* SSL_connect failed with error -313: revcd alert fatal error
* Curl_http_done: called premature == 1
* Closing connection 0
curl: (35) SSL_connect failed with error -313: revcd alert fatal error
Node.js 10 在 HTTPS 方面发生了哪些变化?我怀疑我必须更改 SSL 设置,但我确定如何更改。
更新:
尝试访问 HTTP (Node.js v10.1.0)
# curl --insecure -v "10.43.11.128:3333/"
* Trying 10.43.11.128...
* TCP_NODELAY set
* Connected to 10.43.11.128 (10.43.11.128) port 3333 (#0)
> GET / HTTP/1.1
> Host: 10.43.11.128:3333
> User-Agent: curl/7.52.1
> Accept: */*
>
* Curl_http_done: called premature == 0
* Empty reply from server
* Connection #0 to host 10.43.11.128 left intact
curl: (52) Empty reply from server
Wireshark 捕获pcap file。
【问题讨论】:
-
你试过
Node.js v10.9.0吗? -
@ArifKhan 是和没有区别
-
很可能您的 TLS 库太旧,并且其中存在一些(现在希望已修复)错误导致此问题。 wolfSSL 版本 3.9.8 于 2016 年发布。尝试将 curl 更新为 2018 版本的 woflSSL,例如 3.15.3
-
@hanshenrik 谢谢,那将是理想的,但这是不可能的 - 设备有旧的固件和只读文件系统......即使我升级我仍然想让节点服务器与旧的一起工作设备。
-
@m1ch4ls 尝试使用旧的 2015-2016 版本的 NodeJS,例如 nodejs.org/download/release/v4.2.4,curl 可以与之通信吗?
标签: node.js ssl curl https openssl