Skip to content

Commit

Permalink
⬆️ client-certificate.
Browse files Browse the repository at this point in the history
  • Loading branch information
hokein committed May 22, 2016
1 parent 3912646 commit 057c924
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 47 deletions.
41 changes: 20 additions & 21 deletions client-certificate/main.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
var app = require('app');
var BrowserWindow = require('browser-window');

var mainWindow = null;

app.on('window-all-closed', function() {
if (process.platform != 'darwin')
app.quit();
});

//app.commandLine.appendSwitch('client-certificate',
//'X:\\workspace\\client-certificates\\ssl\\client.crt');

app.on('ready', function() {
mainWindow = new BrowserWindow({
'width': 800,
'height': 600,
});

mainWindow.loadUrl('https://localhost:5000');
});
const {app, BrowserWindow} = require('electron');

let mainWindow;

app.on('window-all-closed', function() {
if (process.platform != 'darwin')
app.quit();
});

//app.commandLine.appendSwitch('client-certificate',
//'path/to/client-certificates/ssl/client.crt');

app.on('ready', function() {
mainWindow = new BrowserWindow({
'width': 800,
'height': 600,
});

mainWindow.loadURL('https://localhost:5000');
});
10 changes: 5 additions & 5 deletions client-certificate/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name" : "client-certificate-demo",
"version" : "0.1.0",
"main" : "main.js"
}
{
"name" : "client-certificate-demo",
"version" : "1.1.0",
"main" : "main.js"
}
42 changes: 21 additions & 21 deletions client-certificate/server.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
var https = require('https');
var fs = require('fs');

var options = {
key: fs.readFileSync('ssl/server.key'),
cert: fs.readFileSync('ssl/server.crt'),
ca: fs.readFileSync('ssl/rootCA.crt'),
requestCert: true,
rejectUnauthorized: false
};

https.createServer(options, function (req, res) {
console.log('Receive a request.');
if (req.client.authorized) {
res.writeHead(200);
res.end('approved\n');
} else {
res.writeHead(401);
res.end('denied\n');
}
}).listen(5000);
const https = require('https');
const fs = require('fs');

const options = {
key: fs.readFileSync('ssl/server.key'),
cert: fs.readFileSync('ssl/server.crt'),
ca: fs.readFileSync('ssl/rootCA.crt'),
requestCert: true,
rejectUnauthorized: false
};

https.createServer(options, function (req, res) {
console.log('Receive a request.');
if (req.client.authorized) {
res.writeHead(200);
res.end('approved\n');
} else {
res.writeHead(401);
res.end('denied\n');
}
}).listen(5000);

0 comments on commit 057c924

Please sign in to comment.