【问题标题】:OpenSSL::PKey::RSAError (Neither PUB key nor PRIV key: nested asn1 error) while using Grocer gem on RoR app在 RoR 应用程序上使用 Grocer gem 时出现 OpenSSL::PKey::RSAError(PUB 密钥和 PRIV 密钥都没有:嵌套的 asn1 错误)
【发布时间】:2017-02-15 08:26:52
【问题描述】:

我知道在这种情况下有很多问题,但我已经尝试了所有解决方案,但我仍然陷入困境。我正在使用 grocer gem 向 APN 服务发送推送通知。我被证书问题困住了。

这是代码

pusher = Grocer.pusher(
  certificate: "#{Rails.root}/public/certificate1.pem",      # required
  passphrase:  "",                       # optional
  gateway:     "gateway.push.apple.com", # optional; See note below.
  port:        2195,                     # optional
  retries:     3                         # optional
) 


notification = Grocer::Notification.new(
  device_token: token,
  alert: "#{uname} liked your post",
  sound: 'default',
  badge:  0
)

pusher.push(notification)

我在一个生产环境中,我在 Heroku 上托管应用程序。 Heroku 日志告诉我这个

OpenSSL::PKey::RSAError (Neither PUB key nor PRIV key: nested asn1 error):
app/controllers/api/v1/feeds_controller.rb:49:in `likeit'

第 49 行是推送通知的行。

我确定我使用的证书是正确的,因为我已经使用它测试了推送通知。此外,在生成 pem 文件时,我已经导出了证书和私钥。

参考:grocer gem

欢迎提出任何建议!

【问题讨论】:

    标签: ios ruby-on-rails ssl heroku apple-push-notifications


    【解决方案1】:

    我不得不改变这两件事:

    1) 在苹果开发者账户的推送通知选项卡下获取生产 SSL 证书

    2) 将 gateway.push.apple.com 更改为 gateway.sandbox.push.apple.com,因为我仍处于开发模式。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-23
      • 2020-12-10
      • 2013-08-17
      • 2019-07-03
      相关资源
      最近更新 更多