Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

it wont work on insecure ports anymore this whole thing needs updating to use secure #74

Open
jamieduk opened this issue Jan 24, 2022 · 7 comments

Comments

@jamieduk
Copy link

it wont work on insecure ports any,opre this whoole thing needs updating to use secure with self signed cert, reply when fixed and il re test again!

@jamieduk jamieduk changed the title it wont work on insecure ports any,opre this whoole thing needs updating to use secure it wont work on insecure ports any,opre this whole thing needs updating to use secure Jan 24, 2022
@jamieduk jamieduk changed the title it wont work on insecure ports any,opre this whole thing needs updating to use secure it wont work on insecure ports anymore this whole thing needs updating to use secure Jan 27, 2022
@jamieduk
Copy link
Author

The problem is this line
const server = require('http').Server(app)

it is not secure therefore will not work, fixit!!!

@jamieduk
Copy link
Author

IM confused trying to make this project secure
https://stackoverflow.com/questions/6599470/node-js-socket-io-with-ssl
isnt much help but shows some examples that may help you make this secure so that it works!

fixit!!!

@jamieduk
Copy link
Author

const express=require('express')
const app=express()
const https=require('https')
const server=https.createServer(https_options, app);
const io=require('socket.io')(server)
const { v4: uuidV4 }=require('uuid')
const fs=require('fs');
const https_options={
    cert: fs.readFileSync('/var/www/html/apps/chat/video-chat/cert/cert.pem'),
    ca: fs.readFileSync('/var/www/html/apps/chat/video-chat/cert/csr.pem'),
    key: fs.readFileSync('/var/www/html/apps/chat/video-chat/cert/private/key.pem'),
    requestCert: false,
    rejectUnauthorized: false
}

server.listen(3009, () => {
    console.log('server started ok');
});

app.set('view engine', 'ejs')
app.use(express.static('public'))

app.get('/', (req, res) => {
  res.redirect(`/${uuidV4()}`)
})

app.get('/:room', (req, res) => {
  res.render('room', { roomId: req.params.room })
})

io.on('connection', socket => {
  socket.on('join-room', (roomId, userId) => {
    socket.join(roomId)
    socket.to(roomId).broadcast.emit('user-connected', userId)

    socket.on('disconnect', () => {
      socket.to(roomId).broadcast.emit('user-disconnected', userId)
    })
  })
})

//server.listen(3009)

/var/www/html/apps/chat/video-chat/server.js:4
const server=https.createServer(https_options, app);
                                ^

ReferenceError: Cannot access 'https_options' before initialization


What am I doing wrong?? help me fix your mistake will you!!!

never release an insecure product assiume ppl want security for things to work ok!

@jamieduk
Copy link
Author

jamieduk commented Jan 27, 2022

May of fixed by changing the order as follows:

const express=require('express')
const app=express()
const https=require('https')


const { v4: uuidV4 }=require('uuid')
const fs=require('fs');

const https_options={
    cert: fs.readFileSync('/var/www/html/apps/chat/video-chat/cert/cert.pem'),
    ca: fs.readFileSync('/var/www/html/apps/chat/video-chat/cert/csr.pem'),
    key: fs.readFileSync('/var/www/html/apps/chat/video-chat/cert/private/key.pem'),
    requestCert: false,
    rejectUnauthorized: false
}
let server=https.createServer(https_options, app);
const io=require('socket.io')(server)

server.listen(3009, () => {
    console.log('server started ok');
});

app.set('view engine', 'ejs')
app.use(express.static('public'))

app.get('/', (req, res) => {
  res.redirect(`/${uuidV4()}`)
})

app.get('/:room', (req, res) => {
  res.render('room', { roomId: req.params.room })
})

io.on('connection', socket => {
  socket.on('join-room', (roomId, userId) => {
    socket.join(roomId)
    socket.to(roomId).broadcast.emit('user-connected', userId)

    socket.on('disconnect', () => {
      socket.to(roomId).broadcast.emit('user-disconnected', userId)
    })
  })
})

//server.listen(3009)

It runs ok but when i navigate to https://localhost:3009
i accept self signed cert security risk and then get blank page!
https://localhost:3009/94e6319d-3fc5-4aae-8a04-d7359b56ed82

any ideas whats up with it?
it displays the permissions for cam and audio ok but blank page after i accept, i tried different browsers aswell.

Also is script.js

const myPeer=new Peer(undefined, { host: '/', secure: true, port: 3009, });

@jamieduk
Copy link
Author

Its deffo not cert error as also tried using letsencrypt certs and still get blank pages!

@sahilrajput03
Copy link

sahilrajput03 commented Apr 20, 2022

I got my project working with ssl as well and I documented well this in my repository.

Its deployed on heroku(backend) and github (frontend)-> https://letsjoin.ml

you can find code for all of my project(backend + frontend) @ https://github.com/sahilrajput03/video-chat-app-webrtc/tree/hash-router.

To test my app, join room1 from different devices!

@maverickreal
Copy link

I got my project working with ssl as well and I documented well this in my repository.

Its deployed on heroku(backend) and github (frontend)-> https://letsjoin.ml

you can find code for all of my project(backend + frontend) @ https://github.com/sahilrajput03/video-chat-app-webrtc/tree/hash-router.

To test my app, join room1 from different devices!

Not working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants