Skip to content

Instantly share code, notes, and snippets.

@endel
Created December 18, 2019 02:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save endel/fe5fcaf0ec16eb4b9002453e6c1e4c23 to your computer and use it in GitHub Desktop.
Save endel/fe5fcaf0ec16eb4b9002453e6c1e4c23 to your computer and use it in GitHub Desktop.
Manually generating and using SSL fullchain on Node.js (purchased from ssls.com - Comodo PositiveSSL)

Before purchasing the SSL certificate, you'll generate a CSR and PEM files:

  • STAR_domainname_com.csr
  • STAR_domainname_com.pem

When purchasing a SSL from ssls.com, they give you these files:

  • STAR_domainname_com.ca-bundle
  • STAR_domainname_com.crt

To generate the fullchain.pem

  • Copy the contents of STAR_domainname_com.crt into the beginning of the STAR_domainname_com.ca-bundle file, under the name of fullchain.pem.
  • Copy the STAR_domainname_com.pem into your server, under the name of privkey.pem

Now, in Node.js, you can create a SSL server by using:

https.createServer({
  key: fs.readFileSync('/path/to/privkey.pem'),
  cert: fs.readFileSync('/path/to/fullchain.pem')
}, app)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment