最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Node.js + Express.js | Trying to set up a HTTPS server - Stack Overflow

programmeradmin3浏览0评论

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
Add a comment  | 

1 Answer 1

Reset to default 24 +400

Try mention you key's passphrase in this line or provide an empty string '':

const credentials = {key: privateKey, cert: certificate, passphrase: '??'};
发布评论

评论列表(0)

  1. 暂无评论