ostinelli / apnotic

A Ruby APNs HTTP/2 gem able to provide instant feedback.
MIT License
480 stars 96 forks source link

Enable initialisation of Connection with the cert data #53

Closed ky1ejs closed 7 years ago

ky1ejs commented 7 years ago

I have a use case where our token for APNS is stored in an ENV var, which of course means a file path can't be passed to Apnotic.

This change simply allows initialisation of Connection with a :cert string.

ostinelli commented 7 years ago

Thank you for your input. From the docs:

:cert_path: The path to a valid APNS push certificate in .pem or .p12 format, or any object that responds to :read.

Further down:

Note that since :cert_path can be any object that responds to :read, it is possible to pass in a certificate string directly by wrapping it up in a StringIO object:

Apnotic::Connection.new(cert_path: StringIO.new("pem cert as string"))

I understand that adding a little wrapper might be thought as unnecessary, but to me having an additional :cert option can bring more confusion than benefits.

ky1ejs commented 7 years ago

ahhhh, sorry, should have rtfm 😄.

Cheers!