I'm trying to setup a HTTPS server with Node.js and Express.js.
I'm currently trying:
const filesystem = require('fs');
const express = require('express');
const server = express();
const http = require('http').Server(server);
const https = require('https');
const io = require('socket.io')(http);
require('./routes')(server);
require('./chat-logic')(io);
// Dummy cert
const privateKey = filesystem.readFileSync('cert/key.pem', 'utf8');
const certificate = filesystem.readFileSync('cert/cert.pem', 'utf8');
const credentials = {key: privateKey, cert: certificate};
const httpsServer = https.createServer(credentials, server);
server.use(express.static(__dirname + '/src'));
http.listen(3000, () => console.log('Listening on *3000'));
httpsServer.listen(3443, () => console.log('HTTPS on *3443'));
However, I get this error:
_tls_common.js:134
c.context.setKey(key, passphrase);
^
Error: error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt
What am I doing wrong here?
I'm trying to setup a HTTPS server with Node.js and Express.js.
I'm currently trying:
const filesystem = require('fs');
const express = require('express');
const server = express();
const http = require('http').Server(server);
const https = require('https');
const io = require('socket.io')(http);
require('./routes')(server);
require('./chat-logic')(io);
// Dummy cert
const privateKey = filesystem.readFileSync('cert/key.pem', 'utf8');
const certificate = filesystem.readFileSync('cert/cert.pem', 'utf8');
const credentials = {key: privateKey, cert: certificate};
const httpsServer = https.createServer(credentials, server);
server.use(express.static(__dirname + '/src'));
http.listen(3000, () => console.log('Listening on *3000'));
httpsServer.listen(3443, () => console.log('HTTPS on *3443'));
However, I get this error:
_tls_common.js:134
c.context.setKey(key, passphrase);
^
Error: error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt
What am I doing wrong here?
Share Improve this question asked Jan 13, 2019 at 17:07 CodeF0xCodeF0x 2,6826 gold badges19 silver badges28 bronze badges 3- I guess the certificate is incorrect. – Prasheel Commented Jan 13, 2019 at 17:20
- @Prasheel How can I very the certificate? – CodeF0x Commented Jan 13, 2019 at 17:54
- sslshopper.com/ssl-checker.html – Prasheel Commented Jan 13, 2019 at 17:57
1 Answer
Reset to default 24 +400Try mention you key's passphrase
in this line or provide an empty string ''
:
const credentials = {key: privateKey, cert: certificate, passphrase: '??'};