Closed
Description
- Version: 6.10.1
- Platform:
- Subsystem:
This code runs well:
let options = {
key: fs.readFileSync("key.pem"),
cert: fs.readFileSync("cert.pem")
};
https.createServer(options, (req, res) => {
console.log("Request received");
res.writeHead(200);
res.end("hello world\n");
}).listen(50000, "127.0.0.1");
console.log("HTTPS server started.");
setTimeout(() => {
https.request({
host: "127.0.0.1",
port: 50000,
rejectUnauthorized: false
}).end();
}, 1000);
But if I use Unix socket, then it will fail, saying self signed cert error:
let options = {
key: fs.readFileSync("key.pem"),
cert: fs.readFileSync("cert.pem")
};
https.createServer(options, (req, res) => {
console.log("Request received");
res.writeHead(200);
res.end("hello world\n");
}).listen("/Users/zzz/test-unix-socket/socket.sock");
console.log("HTTPS server started.");
setTimeout(() => {
https.request({
socketPath: "/Users/zzz/test-unix-socket/socket.sock",
rejectUnauthorized: false
}).end();
}, 1000);
key.pem
and cert.pem
is a self-signed certificate generated using OpenSSL:
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 7300 -nodes
Is this a bug, or am I missing something?