我的源代码:

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

var httpOptions =  {
  pfx: fs.readFileSync('keys/1.pfx')
};

var server = https.createServer(httpOptions, app);
var io = require('socket.io')(server);

console.log("https server listens on port 8080...");

server.listen(8080);

执行之后遇到这个错误消息:

mac verify failure
at Object.createSecureContext (_tls_common.js:160:19)
at Server (_tls_wrap.js:805:25)
at new Server (https.js:54:14)
at Object.createServer (https.js:76:10)
at Object. (c:\Code\wechat\miniserver\httpsKey.js:9:20)
at Module._compile (module.js:652:30)
at Object.Module._extensions…js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)

使用node https module创建服务器遇到的mac verify failure错误消息

研究发现是因为我的1.pfx文件本身就需要密码才能访问:

使用node https module创建服务器遇到的mac verify failure错误消息

使用node https module创建服务器遇到的mac verify failure错误消息

把密码也传入代码后问题解决:

使用node https module创建服务器遇到的mac verify failure错误消息

要获取更多Jerry的原创文章,请关注公众号"汪子熙":
使用node https module创建服务器遇到的mac verify failure错误消息

相关文章:

  • 2021-11-24
  • 2022-12-23
  • 2022-12-23
  • 2021-06-08
  • 2021-07-01
  • 2021-11-18
  • 2021-11-05
猜你喜欢
  • 2022-12-23
  • 2021-08-09
  • 2021-08-26
  • 2022-12-23
  • 2021-08-09
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案