You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have created an HTTPS server with socket.io and a client with socket.io-client.
Problem is that apparently socket.io-client does not check validity of HTTPS connection by the given CA in it's option.
For clarification here's a sample code: In simple https request if I do not provide CA in client I get Error: unable to verify the first certificate, but with socket.io-client connection establishes, which is totally not what I want.
//Client
var https = require('https'),
socketClient = require('socket.io-client'),
fs = require('fs');
var options = {
// IT'S EXPECTED THAT I DON'T PROVIED CA, HTTPS CONNECTION FAILS
//ca: fs.readFileSync('cert/ca.crt'),
agent: false
};
var socket = socketClient('https://localhost', options);
socket.on('connect', function() {
console.log('Connected to hub');
socket.emit('msg', function(resp){
console.log('Response: ' + resp);
});
});
And server :
// Server
var https = require('https'),
socketIo = require('socket.io'),
fs = require('fs');
var options = {
// CERTIFICATE HAS BEEN SIGNED WITH CA
cert: fs.readFileSync('cert/signed.crt'),
key: fs.readFileSync('cert/signed.key'),
rejectUnauthorized: false
};
var app = https.createServer(options, function(req, res) {
res.end('Hi');
});
var io = socketIo(app);
io.on('connection', function(socket) {
console.log('Connected !');
socket.on('msg', function(cb) {
console.log('Msg recved');
cb('Client got it');
});
});
app.listen(443, function() {
console.log('Server Started ...');
});
The text was updated successfully, but these errors were encountered:
@zxc23 Unfortunately I no longer have access to the codes, but what I can remember is that I used a configured https agent in socket.io option. I'm not sure how's that gonna work now, consider that I was using socket.io 1.*
I have created an HTTPS server with socket.io and a client with socket.io-client.
Problem is that apparently socket.io-client does not check validity of HTTPS connection by the given CA in it's option.
For clarification here's a sample code: In simple https request if I do not provide CA in client I get
Error: unable to verify the first certificate
, but with socket.io-client connection establishes, which is totally not what I want.And server :
The text was updated successfully, but these errors were encountered: