A javascript library for parsing & validating APNS (Apple Push Notification Service) PKCS#12 certificates.
The purpose of the library is to handle changes to / addition of APNS certificates during runtime of services handling multiple certificates at once.
And throws understandable messages given erroneous certificates.
It can be used both client and server side.
const fs = require('fs');
const path = require('path');
const ApnsCertificate = require('../../build/src').ApnsCertificate;
const P12_BASE64 = fs.readFileSync('cert.p12').toString('base64');
const passphrase = 'passphrase if any';
const certificate = new ApnsCertificate(P12_BASE64, passphrase);
console.log(JSON.stringify(certificate, undefined, 4));
This will output
{
"key": "-----BEGIN RSA PRIVATE KEY----- ... -----END RSA PRIVATE KEY-----",
"cert": "-----BEGIN CERTIFICATE----- ... -----END CERTIFICATE-----",
"topic": "dk.discountrobot.push",
"environment": {
"sandbox": true,
"production": false
},
"expires": "2018-08-05T20:34:44.000Z"
}
Which can be used with the https module or more preferably the node-apn library
For client side use, the node-forge dependency must resolved during transpilation.
See the examples for more information