sideshow / apns2

⚡ HTTP/2 Apple Push Notification Service (APNs) push provider for Go — Send push notifications to iOS, tvOS, Safari and OSX apps, using the APNs HTTP/2 protocol.
MIT License
3.01k stars 335 forks source link

Loading .p12 certificate: ans1: indefinite length found (not DER) #46

Closed gngeorgiev closed 7 years ago

gngeorgiev commented 8 years ago

Hello,

I am trying to use the apns2 module but when I try to load the p12 file I get the following error

ans1: indefinite length found (not DER)

I was able to convert the file to .pem using the command line openssl, and it worked but this is not an ideal solution, I need to be able to use the p12 file directly or convert it to pem at runtime. Sadly the openssl bindings do not offer this functionality as of now. Any suggestions?

sideshow commented 8 years ago

@gngeorgiev thanks for logging. I haven't seen this before, so are you able to share more info about your environment and your cert.

sideshow commented 8 years ago

@gngeorgiev did you manage to get any further on this?

gngeorgiev commented 8 years ago

@sideshow Yeah, I did.

Turns out my certificates were indeed a bit weird, since regenerating them fixed the problems. However, I needed the old ones to work, since I need to be able to handle arbitrary use cases. In the end I ended up using the openssl command line tool, passing certificates in stdin and getting the decoded certificate and private key from stdout. I don't think there is anything you can do except document this case.

sideshow commented 7 years ago

Thanks @gngeorgiev I have added a separate issue to add more docs around this. https://github.com/sideshow/apns2/issues/54