NodeJSNode JS Windows Server 

how to add SSL certificate in node server for webRTC app

I have gone through this problem when I was implementing webRTC signaling server in node.js using muaz khan webRTC experiments. I was running trying to run node on windows server 2012 R2 platform where I already hade a wildcard SSL certificate  (Wildcard SSL Certificate saves you money and time by securing your domain and unlimited sub-domains on a single certificate.) with my main domain so I was trying to implement using that certificate only, here is what I did to solve it.

This process is for windows server:

First, get .crt(certificate file extension) file from your SSL provider then install in your windows server.

Then go to https://www.digicert.com/util/  and download the app and run.

After running if your SSL was installed properly it will give you the list of SSL present in the server, select the proper one and click export certificate.

Next in Export certificate select as shown below and click next.

 

Then Select any path to output your key files as shown below

 

The final output files will be as shown below.

Next copy the .crt and .key file (here there will be 2 .crt files but you have to copy the .crt file one you have given a name while exporting not the CAcert.crt file) to you node.js application server folder and link the two files as below. find this line in the code and replace the files in key and cert 

Note: it’s not mandatory to have a .pem file only

// Please use HTTPs on non-localhost domains.
var isUseHTTPs = true;

var port = 443;
//var port = process.env.PORT || 9001;

var sslOptions = {
    key: fs.readFileSync('keys/wildcard.key'),
    cert: fs.readFileSync('keys/wildcard.crt')
};
Adding SSL in Nodejs

Related posts