pushmeup icon indicating copy to clipboard operation
pushmeup copied to clipboard

pem file without certificates blows up hard

Open grant-olson opened this issue 10 years ago • 0 comments

So I've been stumbling around the web trying to make APN keys. This involved running a lot of openssl commands by just cut-and-pasting things I saw on the web, without really understanding what I was doing. The fault is entirely mine, but I generated a .pem file that only had my encrypted RSA keys, and not my X509 certificates.

The retry logic in APNS.with_connection really flipped out here, and it got to the point where it even killed my db connection.

If would be nice if there was better handling of the error when it happened here:

context = OpenSSL::SSL::SSLContext.new
context.cert = OpenSSL::X509::Certificate.new(File.read(self.pem))
context.key = OpenSSL::PKey::RSA.new(File.read(self.pem), self.pass)

And instead of retrying when getting an error like:

2.1.4 :003 > OpenSSL::X509::Certificate.new(File.read("./radius-apn-production.pem.old"))
OpenSSL::X509::CertificateError: nested asn1 error
    from (irb):3:in `initialize'
    from (irb):3:in `new'
    from (irb):3
    from /Users/grant/.rvm/rubies/ruby-2.1.4/bin/irb:11:in `<main>'

pushmeup said that I had a bad/incomplete .pem file.

grant-olson avatar Jan 22 '15 20:01 grant-olson