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 badges1 Answer
Reset to default 1It 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条)