如何设置连接服务器(节点)以使用HTTPS?错误:错误:0906D06C:PEM例程:PEM_read_bio:无起始行

时间:2016-06-15 12:42:39

标签: node.js npm connect

我正在使用connect服务器,我需要在https下创建我的localhost(即使证书无效)。

目前我正在使用以下脚本在http://127.0.0.1:8080/

创建服务器列表

我需要将其设置为:https://127.0.0.1:8080/

如何配置连接服务器?

gulp.task('dev:connect', function () {
    // runs connect server for rapid development
    connect.server({
        root: ''
    });
});

我也在尝试这个,但没有成功:

var https = require('https');
var options = {
    key: fs.readFileSync('b.key'),
    cert: fs.readFileSync('a.crt')
};
var app = connect(); // error here object is not a function
https.createServer(options, app).listen(8080);

1 个答案:

答案 0 :(得分:1)

尝试运行以下命令,我认为密钥是受保护的:

  $ openssl rsa -in b.key -out b-unprotected.key
  $ cat b-unprotected.key a.crt > a.pem

让我知道这是否有效