0

I have done instructions from this page: https://medium.com/@invingagan/an-express-https-server-with-a-self-signed-certificate-and-socket-io-42d1f02d4d1a

That is, I created a self signed certificate:

openssl req -nodes -new -x509 -keyout server.key -out server.cert 

Then I use this server code:

var express = require('express'); var app = express(); var fs = require('fs'); app.use(express.static('public')); const server = require('https').createServer({ key: fs.readFileSync('server.key'), cert: fs.readFileSync('server.cert') }, app); var io = require('socket.io')(server); server.listen(1437, function () { console.log('https and websocket listening on *:1437'); }); 

However, when I try to connect using socket.io client, I got this error:

index.js:83 GET https://localhost:1437/socket.io/?framespersecond=15&audioBitrate=22050&EIO=3&transport=polling&t=NJLEHQL net::ERR_CERT_AUTHORITY_INVALID 

If I just copy and paste the URL in the browser URL field, I received the same error, so this is not a problem of socket.io client but the server miss to configure something.

I tried by creating a CA file and specify it in the call to createServer but it did not work either.

Any help?

Jaime

2
  • I think you have to configured socket io with express not? 'const ios = require(‘socket.io’)(secureServer); seems like you're missing this from the tutorial. Commented Sep 28, 2020 at 23:16
  • @AvivLo sorry, I didn't know that code was important so I did not add it to the question. I already have this: var io = require('socket.io')(server); however, it is used only in io.on('connection', function (socket) { }. I don't think this has anything to do with the certificate problem. Commented Sep 29, 2020 at 10:45

1 Answer 1

1

It turned out there was a problem when generating the certificate using openssl.

I don't really know what happened, but since I have an already issued a self signed certificate (the one that is used by Visual Studio when developing sites to be debugged using IISEXPRESS), I have exported that certificate using Digicert utility and I could finally connect using socket.io.

Regards Jaime

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.