Jac*_*ill 9 ssl https pfx node.js
我目前正在使用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.)
小智 10
我猜你和属性之间缺少的逗号是导致错误的原因.在这里我添加了逗号:pfxpassphrase
var options = {
pfx: fs.readFileSync('./8ab20f7b-51b9-4c09-a2e0-1918bb9fb37f.pfx'),
passphrase: 'password'
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12305 次 |
| 最近记录: |