ruby on rails - Apnotic gem OpenSSL issue when creating new session - Stack Overflow

I have a Rails 8 app that I am trying to send Apple push notification with using the Apnotic gem.def co

I have a Rails 8 app that I am trying to send Apple push notification with using the Apnotic gem.

  def connection
    @connection ||= Apnotic::Connection.new(
      cert_path: StringIO.new(credentials.apns_key),
      team_id: credentials.team_id,
      key_id: credentials.key_id
    )
  end

  def credentials
    @credentials ||= Rails.application.credentials.ios
  end

When it hits this code, it fails on Apnotic::Connection.new. I get:

OpenSSL::PKey::RSAError (incorrect pkey type: id-ecPublicKey) Caused by: OpenSSL::PKCS12::PKCS12Error (PKCS12_parse: invalid null pkcs12 pointer)

I've tried inspecting my credentials which begin with -----BEGIN PRIVATE KEY----- and includes new line characters. I tried using a hard coded string, and bringing the Apple certificate into the Rails project directly, and always get the same error. My cert was just generated today, and is a .p8 file

One thing I'm wondering about is if this is looking for a public, not private key, but I only got the one cert from Apple with the private key only.

I have a Rails 8 app that I am trying to send Apple push notification with using the Apnotic gem.

  def connection
    @connection ||= Apnotic::Connection.new(
      cert_path: StringIO.new(credentials.apns_key),
      team_id: credentials.team_id,
      key_id: credentials.key_id
    )
  end

  def credentials
    @credentials ||= Rails.application.credentials.ios
  end

When it hits this code, it fails on Apnotic::Connection.new. I get:

OpenSSL::PKey::RSAError (incorrect pkey type: id-ecPublicKey) Caused by: OpenSSL::PKCS12::PKCS12Error (PKCS12_parse: invalid null pkcs12 pointer)

I've tried inspecting my credentials which begin with -----BEGIN PRIVATE KEY----- and includes new line characters. I tried using a hard coded string, and bringing the Apple certificate into the Rails project directly, and always get the same error. My cert was just generated today, and is a .p8 file

One thing I'm wondering about is if this is looking for a public, not private key, but I only got the one cert from Apple with the private key only.

Share Improve this question edited Mar 26 at 22:04 Steve Schwedt asked Mar 26 at 21:53 Steve SchwedtSteve Schwedt 4403 silver badges14 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

It needed auth method :token
`

  def connection
    @connection ||= Apnotic::Connection.new(
      cert_path: StringIO.new(credentials.apns_key),
      auth_method: :token,
      team_id: credentials.team_id,
      key_id: credentials.key_id,
      bundle_identifier: credentials.bundle_identifier
    )
  end

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744124192a4559539.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信