7

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

Terry Windwalker
  • 1,343
  • 2
  • 16
  • 36
anestis
  • 931
  • 3
  • 9
  • 24

4 Answers4

17

If you're on a Mac you can use the base64 utility that comes with Mac.

base64 -i certificate.p12 -o outputfile
Nuno Gonçalves
  • 6,202
  • 7
  • 46
  • 66
1

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'))
Gdeglin
  • 12,432
  • 5
  • 49
  • 65
0
new Buffer(fs.readFileSync(__dirname + "/ios_push_certificate.p12")).toString('base64')

That is the correct script after all.

anestis
  • 931
  • 3
  • 9
  • 24
0

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