Reputation: 1021
I want to send the .p12 file of APNS certificate to One Signal API, but I need first to convert the .p12 file to base64 string. How do I do that? The API documentation is below: https://documentation.onesignal.com/reference#create-an-app
Upvotes: 11
Views: 21528
Reputation: 386
You can use this on Linux
base64 file.p12
To write the base64 output to any file, you can use this
base64 file.p12 > output.base64
Note: This works for any files not only .p12
Upvotes: 2
Reputation: 6795
If you're on a Mac you can use the base64 utility that comes with Mac.
base64 -i certificate.p12 -o outputfile
Upvotes: 22
Reputation: 1021
new Buffer(fs.readFileSync(__dirname + "/ios_push_certificate.p12")).toString('base64')
That is the correct script after all.
Upvotes: 1
Reputation: 12618
This depends on the programming language you are using.
For example, here's how to do it in Ruby:
base64_encoded_p12 = Base64.encode64(File.read('/path/to/your/file.p12'))
Upvotes: 1