Skip to content

Commit 485aab0

Browse files
committed
[integrity][vulnerability] Issue #310 Client certificate authentication for all Validation Service/Console requests (Note: Validation Service/Coneole is still a skeleton and non-functional)
1 parent 1e47ff5 commit 485aab0

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

demo-backend/validationService.js

+13-9
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,12 @@ if (isCLI) {
7676

7777
app
7878
.use(bodyParser.json())
79-
.all(updateAPIPath, (req, res, next) => {
79+
.use((req, res, next) => {
8080
if (req.client.authorized) {
8181
const peerCert = req.socket.getPeerCertificate();
8282
if (peerCert.fingerprint256 === fingerprint256) { // only a single client certificate is authenticated
83-
let body = req.method === 'POST' ? req.body : null;
84-
//console.log('request body: ', JSON.stringify(body, null, 2));
85-
updateBrowsers(req, body);
86-
let result = {
87-
browsers: browsers || {},
88-
};
89-
res.setHeader('content-type', 'application/json');
90-
res.status(200).send(JSON.stringify(result, null, 2));
83+
//console.log('client certificate authentication passed for ' + req.url);
84+
next();
9185
}
9286
else {
9387
console.error('fingerprints not matched', peerCert.fingerprint256, fingerprint256);
@@ -99,6 +93,16 @@ if (isCLI) {
9993
res.sendStatus(403);
10094
}
10195
})
96+
.all(updateAPIPath, (req, res, next) => {
97+
let body = req.method === 'POST' ? req.body : null;
98+
//console.log('request body: ', JSON.stringify(body, null, 2));
99+
updateBrowsers(req, body);
100+
let result = {
101+
browsers: browsers || {},
102+
};
103+
res.setHeader('content-type', 'application/json');
104+
res.status(200).send(JSON.stringify(result, null, 2));
105+
})
102106
.get('*', express.static(path.resolve(path.join(__dirname, 'validation-console', 'dist')), {}));
103107

104108
switch (mode) {

0 commit comments

Comments
 (0)