Skip to content

Instantly share code, notes, and snippets.

@uvshah
Last active August 29, 2015 14:01
Show Gist options
  • Save uvshah/48a01014230f27c9c5f6 to your computer and use it in GitHub Desktop.
Save uvshah/48a01014230f27c9c5f6 to your computer and use it in GitHub Desktop.
Issue in SSL node.js
I have created self signed certificate using openssl and used in node.js ssl.But i can not connect from client to server.
My server side code is
var express = require('express');
var app = express();
var file = require("fs");
var http = require('https');
var sslOptions = {
key: file.readFileSync('./cert/server.key'),
cert: file.readFileSync('./cert/server.crt'),
ca: [ file.readFileSync('./cert/ca.crt')],
};
var server = http.createServer(sslOptions,app);
var io = require('socket.io').listen(server);
io.sockets.on('connection', function (socket) {
console.log("on connect");
}
server.listen(8088);
And my client side code is
<script src="https://localhost:8088/socket.io/socket.io.js" type="text/javascript"></script>
var socket = io.connect('https://localhost:8088/', { secure: true });
socket.on('connect', function () {
console.log("connect");
});
socket.on('error', function (data) {
console.log('error');
});
Now I can not connect from client to server.I guess its ssl certificate load issue from client side.Do I need to add anything in client side as well?
Also while creating self signed certificate using openssl,Do i need to mention about "common name"?I have tried with "localhost" and blank name.
Thanks,
Urmik
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment