aioapns icon indicating copy to clipboard operation
aioapns copied to clipboard

Support string value for APNs private key

Open cat-bro opened this issue 5 years ago • 4 comments

Would be possible in future versions to allow the private key (key argument to APNs) to be a string instead of a file path, or to have a separate argument (e.g. key_string) for this purpose?

The use case for this is an application that keeps all of its private keys in an encrypted file in an external package. We don't want to keep a file containing the private key in the code base, or write temp files.

cat-bro avatar Oct 27 '19 23:10 cat-bro

@Fatal1ty just wondering are there any plans to get it done?

akalex avatar Mar 09 '21 16:03 akalex

I'll try my best to implement this soon. If you want this done asap, pull requests are welcome.

Fatal1ty avatar Mar 10 '21 11:03 Fatal1ty

Please add option to pass APNs certificate(containing private key) as bytes instead of file path.

arunrejimitsogo avatar May 06 '22 16:05 arunrejimitsogo

This would be nice to have. I have implemented something like the following in my own project, but it's not ideal:

import tempfile

from aioapns import APNs

keyfile = tempfile.NamedTemporaryFile()
keyfile.write(b"APNS_KEY")
keyfile.seek(0)
client = APNs(
    key=keyfile.name,
    # ...other config
)
keyfile.close()

rnevius avatar May 06 '22 16:05 rnevius