cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Go to solution
Highlighted

Using private key from GoDaddy on Nodejs

We purchased a domain name and SSL certificate on godaddy, but our server is not on GoDaddy. WE run Lampp and NodeJS in our server, and we are trying to set up SSL with both. There is no problem with Lampp. the private key and certificate from godaddy is working. but when i try the same files with NodeJS. it fails.

This is my js script:

var ssl = {
  key: fs.readFileSync("./key.pem",'utf8'),
  cert: fs.readFileSync("./cert.crt",'utf8'),
  ca: [fs.readFileSync('./g1.crt','utf8'), fs.readFileSync('./g2.crt','utf8'), fs.readFileSync('./g3.crt','utf8')]
};
server = require('https').createServer(ssl, app);

This is the Error

_tls_common.js:104
      c.context.setKey(options.key, options.passphrase);
                ^

Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
    at Object.createSecureContext (_tls_common.js:104:17)
    at Server (_tls_wrap.js:805:25)
    at new Server (https.js:54:14)
    at Object.createServer (https.js:76:10)
    at Object.<anonymous> (D:\Work\Infiniti_SH_CarShow_photobooth\server\app.js:49:27)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)

After some googling, i have tried several solution: adding "utf8", spliting gd bundle, using nodepad++ to fix code. None of them helped. 

However, nodejs can use my self-signed key and certificate files. So i would like to ask. Did i generate my key incorrectly? Should I manually generate private key/CSR locally and request a new certificate on GoDaddy? or there is something wrong in my code?

2 REPLIES 2

Re: Using private key from GoDaddy on Nodejs

Same issue here tried this:
https://stackoverflow.com/questions/16224064/running-ssl-node-js-server-with-godaddy-gd-bundle-crt

 

No success!

Some help would be nice.

 

 

Solution

Re: Using private key from GoDaddy on Nodejs

Hopefully not too late, but I was dealing with this for a few days and finally found a resolution.

Basically I rekey-ed my certificate.

Here's the steps I did:

 

Create a new CSR and Key with the following command on your server:

 

          openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr

 

Then log into Godaddy, go to SSL Certificates, select your cert and choose to 'rekey & manage'. There will be a few options, expand 'rekey certificate' and paste the contents of 'server.csr' into the field requesting for a CSR. Click 'Save' then scroll to the bottom of page and click submit all changes.

 

It will take a few minutes, but you'll receive an email with the option to download your new keyed cert. Download the cert for your platform (for nodejs, choose 'other'), along with the gd_bundle cert.

 

There are 3 things to configure for HTTPS nodejs server:

cert : the new cert you downloaded from GoDaddy

key: the server.key file you generated earlier

ca: the certificate authority chain. This is the gd_bundle cert that you got with your cert. Some places say you have to break this file up into separate files, but as of Node v10.16, I was able to use the file as is.

 

I hope this helps someone; it was maddening looking for an answer.