Node.js + Express.js |尝试设置HTTPS服务器

时间:2019-01-13 17:07:47

标签: javascript node.js express

我正在尝试使用Node.js和Express.js设置HTTPS服务器。

我正在尝试:

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'));

但是,出现此错误:

_tls_common.js:134
      c.context.setKey(key, passphrase);
                ^

Error: error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt

我在这里做什么错了?

1 个答案:

答案 0 :(得分:0)

请尝试在此行中提及您密钥的 var rootRef1 = firebase.database().ref().child("Users").orderByChild('type') .startAt("2019-01-05").endat("2019-01-10"); rootRef1.on("child_added",snap => { var name=snap.child("fullname").val(); var email= snap.child("email").val(); var address= snap.child("address").val(); var contact= snap.child("contact").val(); var status=snap.child("status").val(); var type=snap.child("type").val(); var date=snap.child("regdate").val(); console.log(name); }); 或提供一个空字符串passphrase

''