小编Jac*_*ill的帖子

我在我的node.js https服务器上使用.pfx认证,我不能在选项中使用'passphrase'

我目前正在使用node.js和https创建一个Web应用程序.所以我尝试使用我的.pfx(我从http://www.cert-depot.com/获取文件)获取https所需的认证,如下面的代码:

var https = require('https');
var fs = require('fs');

var options = {
    pfx: fs.readFileSync('./8ab20f7b-51b9-4c09-a2e0-1918bb9fb37f.pfx')
    passphrase: 'password'
};

var server = https.createServer(options, function (request, response) {
    fs.readFile('index.html', function (error, data) {
        response.writeHead(200, {'Content-Type': 'text/html'});
        response.end(data);
    });
}).listen(12345, function(){
    console.log('server running');
});
Run Code Online (Sandbox Code Playgroud)

但是当我使用node.js启动此代码时,我在Windows控制台中收到一条错误消息:

密码:'密码'

意外的标识符

我的代码非常类似于Node.js的官方指南页面(http://nodejs.org/api/https.html#https_https_createserver_options_requestlistener),但我无法启动我的https服务器.

我的密码有什么问题?(我在Windows 8 64bit中运行node.js.)

ssl https pfx node.js

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

标签 统计

https ×1

node.js ×1

pfx ×1

ssl ×1