Closed
Description
Version: v11.2.0
Platform: Linux xps15 4.19.2-arch1-1-ARCH #1 SMP PREEMPT Tue Nov 13 21:16:19 UTC 2018 x86_64 GNU/Linux
Subsystem: https, tls
I am trying to get https client certificate authentication to work but I get the following error:
_tls_wrap.js:620
this.alpnProtocol = this._handle.getALPNNegotiatedProtocol();
^
TypeError: Cannot read property 'getALPNNegotiatedProtocol' of null
at TLSSocket._finishInit (_tls_wrap.js:620:36)
at TLSWrap.onhandshakedone (_tls_wrap.js:101:9)
code:
const https = require('https');
const fs = require('fs');
// Some valid paths to CA files
const crtPath = process.env.CA_CERT_PATH || "/var/run/secrets/certs/ca.crt";
const keyPath = process.env.CA_CERT_KEY || "/var/run/secrets/certs/ca.key";
const options = {
key: fs.readFileSync(keyPath),
cert: fs.readFileSync(crtPath),
requestCert: true,
};
https.createServer(options, (req, res) => {
res.writeHead(200);
res.end("hello world\n");
}).listen(8443);
when I set requestCert: false
in the options it works fine, but I need the client to present a certificate, thus need the requestCert: true
.
Edit:
Adding rejectUnauthorized: false
makes it work. But I still think that it should not throw an error when rejecting unauthorized clients.