Can you connect with apnagent only using a single .pem and passphrase? Or do I need a separate key .pem too?
I'm a little ignorant of the different cert files and their uses so I am not sure if my mistake is trying to only use the .pem file and a passphrase or if I am making some other mistake.
When I run the following code, I get no error or successful response. Only my "waiting for events...."
'use strict'
const apnagent = require('apnagent')
const join = require('path').join
const certFile = join(__dirname,'/../certs/mint-APN-dev.pem')
const deviceToken = '<token>'
const passphrase = '<passphrase>'
let agent = module.exports = new apnagent.Agent()
agent
.set('cert file',certFile)
.set('passphrase',passphrase)
.enable('sandbox')
agent.connect(function (err) {
if (err && err.name === 'GatewayAuthorizationError') {
console.log('Authentication Error: %s', err.message)
process.exit(1)
}
else if (err) {
throw err
}
var env = agent.enabled('sandbox')
? 'sandbox'
: 'production'
console.log('apnagent [%s] gateway connected', env)
})
// keep it running for a bit to give it time to succeed or fail
let id = setInterval(function() {
console.log('Waiting for events...')
count++
if (count > 18) clearInterval(id)
}, 5000)
nevermind. I answered my own question after more testing. with a .pem file, you have to have both key and cert. but with a .p12 file, you can have only one file