m1c*_*4ls 14 ssl https curl openssl node.js
我有简单的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);
Run Code Online (Sandbox Code Playgroud)
我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
Run Code Online (Sandbox Code Playgroud)
当我使用其他版本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: */*
Run Code Online (Sandbox Code Playgroud)
在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
Run Code Online (Sandbox Code Playgroud)
有关HTTPS的Node.js 10有哪些变化?我怀疑我必须更改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
Run Code Online (Sandbox Code Playgroud)
Wireshark捕获了pcap文件.
验证curl 发送哪些标头,您可以使用 -v 参数。
卷曲-vIX“ https://10.43.11.128:3333/ ”
也在节点中,
只需在 req.end() 之后使用 console.log(req._headers) 并比较您的标头以进一步解决问题。我还请求尝试使用wireshark(http://www.wireshark.org/)进行ssl连接测试。
因为它是通过 --insecure 工作的,但你需要知道原因。
--不安全
你也可以试试这个吗
const https = require("https"),
fs = require("fs");
const options = {
key: fs.readFileSync("/cert/server-key.pem"),
cert: fs.readFileSync("/cert/server-cert.pem")
};
const app = express();
app.use((req, res) => {
res.writeHead(200);
res.end("hello world\n");
});
app.listen(8000);
https.createServer(options, app).listen(8080);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
424 次 |
| 最近记录: |