parse-server: Setting production to true with a Production APNS .p12 File crashes server
We use GitHub Issues for bugs.
If you have a non-bug question, ask on Stack Overflow or Server Fault:
You may also search through existing issues before opening a new one: https://github.com/ParsePlatform/Parse-Server/issues?utf8=✓&q=is%3Aissue
— Please use this template. If you don’t use this template, your issue may be closed without comment. —
Issue Description
Setting production property to true using a production APNS certificate crashes application. Setting to false does not.
Steps to reproduce
push: {
ios: [
//create and support both sandbox and production
{
pfx:sandboxDirectoryLocation,
passphrase: config.APNS_PASSPHRASE,
bundleId: config.APPLE_BUNDLE_ID,
production: false
},
{
pfx:productionDirectoryLocation,
passphrase: config.APNS_PASSPHRASE,
bundleId: config.APPLE_BUNDLE_ID,
production: true
}
]
}
- Go to dashboard and send a test push
- Server crashes with error
To fix:
- set both production to false
- push notifications succeed
- server does not crash
Expected Results
What I expect to happen is that the server detects the correct environment and doesn’t crash. For example, I know I have a sandbox certificate so I know I need to set production to false. If I know I have a production certificate then I know I need production to be set to true.
Actual Outcome
Server crashes with error:
Error: certificate does not support configured environment, production: true
at validateCredentials (/Volumes/Big Disk/Documents/Project/LP-Parse-Server-Template/node_modules/apn/lib/credentials/validate.js:19:10)
Environment Setup
-
Server
- parse-server version (Be specific! Don’t say ‘latest’.) : 2.4.2
- Operating System: macOS Sierra (10.12.5)
- Hardware: iMac Retina 5k, 27-inch late 2014
- Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): localhost
-
Database
- MongoDB version: 3.2.11
- Storage engine: Unknown
- Hardware: iMac Retina 5k, 27-inch late 2014
- Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): localhost
Logs/Trace
Error: certificate does not support configured environment, production: true at validateCredentials (/Volumes/Big Disk/Documents/Project/LP-Parse-Server-Template/node_modules/apn/lib/credentials/validate.js:19:10) at /Volumes/Big Disk/Documents/Project/LP-Parse-Server-Template/node_modules/apn/lib/connection.js:163:5 at _fulfilled (/Volumes/Big Disk/Documents/Project/LP-Parse-Server-Template/node_modules/q/q.js:854:54) at Promise.then.Q.nextTick.self.promiseDispatch.done (/Volumes/Big Disk/Documents/Project/LP-Parse-Server-Template/node_modules/q/q.js:883:30) at Promise.e.Promise.promise.promiseDispatch (/Volumes/Big Disk/Documents/Project/LP-Parse-Server-Template/node_modules/q/q.js:816:13) at /Volumes/Big Disk/Documents/Project/LP-Parse-Server-Template/node_modules/q/q.js:624:44 at runSingle (/Volumes/Big Disk/Documents/Project/LP-Parse-Server-Template/node_modules/q/q.js:137:13) at flush (/Volumes/Big Disk/Documents/Project/LP-Parse-Server-Template/node_modules/q/q.js:125:13) at _combinedTickCallback (internal/process/next_tick.js:67:7) at process._tickDomainCallback (internal/process/next_tick.js:122:9)
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 18 (10 by maintainers)
For reference I’m assuming the apn module mentioned you are referring too is https://github.com/node-apn/node-apn
See was that so hard? Thank you for your time
Issue solved: https://github.com/node-apn/node-apn/issues/410
This issue wasn’t related too Node-APN per say. Apple now allows switching with the same certificate. So I can use the same cert Production / Sandbox and use the production flag as the documentation stated.
However passing both certificates as the Parse documentation states, breaks things.
the solution to the issue was to use a single non-array value
This was most likely my fault for not interpreting the Parse documentation correctly. Although its sort of misleading when it states you can support both production and sandbox by passing in an array of certificates (sandbox and production certs) even though Apple generates an “omni cert” so to speak. Using the omni certificate and passing only a single certificate with either production true or false worked as expected.
This issue has been raised numerous times, over and over again. First, the apn modules is handled by parse-server-push-adapter, not Parse-server itself. Second a quick google search for ‘node apn’ would yield the answer you’re looking for. (https://encrypted.google.com/search?hl=en&q=node apn) Third, the error message look explicit enough: ‘Certificate don’t support specified environment’