Search code examples
ruby-on-railsopensslapple-push-notifications

Rails Apnotic OpenSSL alert certificate expired error


I'm trying to send Apple Push Notifications from a Rails app using the Apnotic gem.

I get the following error when I run @ios_client.push(note).

Traceback (most recent call last):
    5: from /app/vendor/bundle/ruby/2.6.0/gems/net-http2-0.18.4/lib/net-http2/client.rb:114:in `block (2 levels) in ensure_open'
    4: from /app/vendor/bundle/ruby/2.6.0/gems/net-http2-0.18.4/lib/net-http2/client.rb:142:in `socket_loop'
    3: from /app/vendor/bundle/ruby/2.6.0/gems/net-http2-0.18.4/lib/net-http2/client.rb:142:in `loop'
    2: from /app/vendor/bundle/ruby/2.6.0/gems/net-http2-0.18.4/lib/net-http2/client.rb:145:in `block in socket_loop'
    1: from /app/vendor/ruby-2.6.5/lib/ruby/2.6.0/openssl/buffering.rb:182:in `read_nonblock'
/app/vendor/ruby-2.6.5/lib/ruby/2.6.0/openssl/buffering.rb:182:in `sysread_nonblock': SSL_read: sslv3 alert certificate expired (OpenSSL::SSL::SSLError)

I believe my certificate that I obtained from the Apple Developer account is not expired (I tested by creating a new one), so is there something wrong with my OpenSSL installation?

I get the same error locally and on Heroku. How can I fix this?


Solution

  • Check your certificate, open it by your desktop environment and see if the date is between not valid before and not valid after.

    paste key to file and save with .pem

    First save your key with .pem

    key detail If you are using mac, click the file just saved and press space bar to check valid date