Search code examples
node.jsssllaravel-forge

How do I install GoDaddy SSL certificate in NodeJS?


I'm using NodeJS 0.10.x

I purchased an SSL from GoDaddy, and downloaded two .crt files. One .crt file appears to be the certificate, and the other one appears to be a bundle of certificates.

In my NodeJS application, I need to provide it a key and cert file like below:

var server = useHttps ? https.Server({
  key: fs.readFileSync(__dirname + '/certs/server.key'),
  cert: fs.readFileSync(__dirname + '/certs/server.crt'),
}, app) : http.Server(app);

Do I need to convert one of the GoDaddy SSL files to .key?

Can I use the files GoDaddy provided as-is? If so, which one is the key?

EDIT:

I'm having the same problem as this question:

Generating an SSL Key to work with node.js

However, the answer brushes over how to obtain a .key file. I looked into the NodeJS documentation and it doesn't say anything about this.


Solution

  • You already have the key: if is used to generate the CSR (certificate signing request) you sent to godaddy.

    The key is either an input to the openssl req -new command or you can ask it to generate a key for you (In which case the -keyout option controls where it is saved).

    No one other than you should have access to the private key, so if you no longer have the key, you can't use the certificate. It looks like godaddy will let you rekey the certificate. Effectively this is just a repeat of the process you originally went through to get the certificate.