Reputation: 285
I'm having issues with node.js sending push notifications, I think because I'm doing something wrong with my APN certificate thats generated in my apple developer account. Im getting this error from Node.js.
VError: Failed to generate token: error:0906D06C:PEM routines:PEM_read_bio:no start line
I'm not sure I've generated the right file in the apple developer account. See below screenshot, when i click download this gives me a "aps.cer" file which is what i'm putting in my node.js project and using with node-app module. Here is how im setting it in my code:
let options = {
token: {
key: "aps.cer",
keyId: "singlemeout.Single-Me-Out",
teamId: "Team Name"
},
production: false
};
Here is a screen shot of my certificate.
Upvotes: 1
Views: 3395
Reputation: 17710
You are providing node-apn
with a token-based configuration, while you are using certificates.
If you want to keep using certificates:
the certificate should be in PEM format.
You can do the conversion like this:
openssl x509 -inform DER -in aps.cer -out certificate.pem
you need to provide the key, either by adding it to the certificate, or by providing it as a separate file
you need to use the cert
, key
and or pfx
properties in your config object rather than token.key
etc.
let options = {
cert: "certificate.pem",
key: "privatekey.pem"
};
Alternatively, you can switch to using tokens.
See https://github.com/node-apn/node-apn/blob/master/doc/provider.markdown for full details.
Also your production
property is not consistent with the certificate used.
Upvotes: 2