2

I got the following code for apple push service:

  agent
.set('cert file', join(__dirname, 'cert.pem'))
.set('key file', join(__dirname, 'key.pem'))
.enable('sandbox');

When I run my server on localhost, I enter pem key, and server starts working.

How can I set it to be entered automatically, because I deploy it on heroku I do git push heroku master and server fails because I didn't enter pem key.

Slow Harry
  • 1,857
  • 3
  • 24
  • 42

2 Answers2

3

Does the library you use to send notifications support passing the string data of the certificate/key? You can try adding the contents as environment variables on heroku using the heroku config command. For instance:

heroku config:set CERT_DATA='content of the file'

You can then reference CERT_DATA in your code rather than reading the file. You will also need a way to set the environment variables during development, but I'm not familiar enough with the tools that are available to suggest how to do that.

Adam
  • 890
  • 4
  • 10
1

I used these commands:

openssl genrsa -out privatekey.pem 1024
openssl req -new -key privatekey.pem -x509 -days 7300 -out certificate.pem

I used them in Node.js HTTPS server.

See Enabling HTTPS on express.js

Community
  • 1
  • 1
leesei
  • 6,020
  • 2
  • 29
  • 51