【问题标题】:Node.js web-push libraryNode.js 网络推送库
【发布时间】:2016-09-27 13:33:39
【问题描述】:

我正在尝试使用 web-push node.js 库向 chrome 浏览器发送推送通知。

发射后

webpush.sendNotification(pushSubscription,payload)

我得到这个响应的方法 -

{ Error: unable to verify the first certificate
at Error (native)
at TLSSocket.<anonymous> (_tls_wrap.js:1060:38)
at emitNone (events.js:86:13)
at TLSSocket.emit (events.js:185:7)
at TLSSocket._finishInit (_tls_wrap.js:584:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:416:38) code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' }

我猜这是 SSL 问题?我如何通过 localhost 测试这个库?

谢谢

【问题讨论】:

标签: node.js push-notification google-cloud-messaging web-push


【解决方案1】:

我通过使用 https 和正确的密钥创建 nodejs 服务器使其工作。

不确定这是否是正确的实现,但它为我们启动并运行。

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

const options = {
  pfx: fs.readFileSync('server.pfx')
};

https.createServer(options, (req, res) => {
    //Do push things
}).listen(443);

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2019-05-13
  • 1970-01-01
  • 2017-12-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多