OpenSSL::PKey::RSAError(既不是 PUB 密钥也不是 PRIV 密钥:嵌套的 asn1 错误)在 RoR 应用程序上使用 Grocer gem
OpenSSL::PKey::RSAError (Neither PUB key nor PRIV key: nested asn1 error) while using Grocer gem on RoR app
我知道有很多关于这种情况的问题,但我已经尝试了所有解决方案,但我仍然卡住了。我正在使用杂货店 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
欢迎提出任何建议!
我不得不改变这两件事:
1) 在 apple 开发者帐户的推送通知选项卡下获取生产 SSL 证书
2) 把gateway.push.apple.com改成gateway.sandbox.push.apple.com因为我还在开发模式
我知道有很多关于这种情况的问题,但我已经尝试了所有解决方案,但我仍然卡住了。我正在使用杂货店 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
欢迎提出任何建议!
我不得不改变这两件事:
1) 在 apple 开发者帐户的推送通知选项卡下获取生产 SSL 证书
2) 把gateway.push.apple.com改成gateway.sandbox.push.apple.com因为我还在开发模式