相关疑难解决方法(0)

Node.js https pem错误:错误:0906D06C:PEM例程:PEM_read_bio:无起始行

我从证书颁发机构获得了这些文件:

  • domain.com.p7b
  • domain.com.crt
  • domain.com.ca束

我尝试了这个小代码:

var express = require('express');
var app = express();
var fs = require("fs");
var https = require('https');

var privateKey = fs.readFileSync('domain.com.p7b').toString();
var certificate = fs.readFileSync('domain.com.crt').toString();
var ca_bundle = fs.readFileSync('domain.com.ca-bundle').toString();

var credentials = { key: privateKey, 
                    ca : ca_bundle,
                    cert: certificate};


https.createServer(credentials,app).listen(8080, function () {
    console.log('Example app listening on port 8080!');
});
Run Code Online (Sandbox Code Playgroud)

启动脚本后,我收到以下错误:

(err):     at Object.createSecureContext (_tls_common.js:87:19)
(err):     at Server (_tls_wrap.js:721:25)
(err):     at new Server (https.js:17:14)
(err):     at Object.exports.createServer (https.js:37:10)
(err):     at Object.<anonymous> (/utec_temp/https/web.js:27:7)
(err):     at Module._compile …
Run Code Online (Sandbox Code Playgroud)

ssl https ssl-certificate node.js express

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

express ×1

https ×1

node.js ×1

ssl ×1

ssl-certificate ×1