xmtp / example-notification-server-go

Example push notification server, written in Golang
MIT License
14 stars 9 forks source link

Allow users to escape newlines in p8 certs #36

Open peterferguson opened 6 months ago

peterferguson commented 6 months ago

When trying to deploy on fly I was facing an issue with the reading of the apns .p8 cert.

I couldn't find a good way to securely store the cert so it could be read in the application so that just leaves an env var.

However when you do the naive thing setting APNS_P8_CERTIFICATE to the .p8 file contents the server will fail with an error initing client.Production()

This pr allows the user to set the env by explicitly escaping the newlines:

If the .p8 cert is

"-----BEGIN PRIVATE KEY-----
flkdflkdf...
-----END PRIVATE KEY-----"

then you can set the env var as follows

APNS_P8_CERTIFICATE="-----BEGIN PRIVATE KEY-----\nflkdflkdf...\n-----END PRIVATE KEY-----"

If I am just missing a better way to do this please let me know 🙏