Wednesday, 10 May 2017

WebRTC over HTTPs

I have created a simple WebRTC application that works fine in testing overlocal host; However, WEBRTC isn't much use unless you have a secure connection, as browsers now will not run GetUserMedia unless you have HTTPs. Below is a screen shot of my two applications side by side, one secure (not working) the other non secure (works)

enter image description here

As you can see above, localhost 'connects' while HTTPs 'can't establish connection'. I am new to SSL, so this may be a simple one. Just would appreciate some more eyes on this.

I do know my HTTPS server for the the Javascript is connecting securely, see image belowenter image description here

Below are my code snippets. Any help would be greatly appreciated:

SSL Client - Client.JS

var connection = new WebSocket('wss://localhost:8443'),

name = "";

Non Secure Client - Client.JS

var connection = new WebSocket('ws://localhost:8888'),

    name = "";

Non Secure JS Server - index.JS

var WebSocketServer = require('ws').Server,

wss = new WebSocketServer({ port: 8888 }),

users = {};
wss.on('connection', function (connection) {
connection.on('message', function (message) .....

Secure JS Server - SSLindex.JS

 Var https = require('https'),

fs = require('fs'),

 express = require('express'),

  app = express();


var wss = https.createServer({
key: fs.readFileSync('server.key'),

cert: fs.readFileSync('server.crt'),

ca: fs.readFileSync('ca.crt'),

requestCert: true,

rejectUnauthorized: false
 }, app).listen('8443', function() {
console.log("Secure Express server listening on port 8443");
});

 app.use("/", function(req, res, next) 
{
 res.send("index.js is working!");

  });



via eltel2910

No comments:

Post a Comment