mirror of
https://github.com/Lissy93/web-check.git
synced 2025-04-11 02:58:33 +02:00
Adds endpoint for fetching SSL info
This commit is contained in:
parent
f139256736
commit
73d7b56401
@ -44,6 +44,11 @@
|
|||||||
to = "/.netlify/functions/lighthouse-report"
|
to = "/.netlify/functions/lighthouse-report"
|
||||||
status = 301
|
status = 301
|
||||||
force = true
|
force = true
|
||||||
|
[[redirects]]
|
||||||
|
from = "/ssl-check"
|
||||||
|
to = "/.netlify/functions/ssl-check"
|
||||||
|
status = 301
|
||||||
|
force = true
|
||||||
|
|
||||||
# For router history mode, ensure pages land on index
|
# For router history mode, ensure pages land on index
|
||||||
[[redirects]]
|
[[redirects]]
|
||||||
|
30
server/lambda/ssl-check.js
Normal file
30
server/lambda/ssl-check.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
const https = require('https');
|
||||||
|
|
||||||
|
exports.handler = async function (event, context) {
|
||||||
|
const { url } = event.queryStringParameters;
|
||||||
|
|
||||||
|
if (!url) {
|
||||||
|
return {
|
||||||
|
statusCode: 400,
|
||||||
|
body: 'url query parameter is required',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const req = https.request(url, res => {
|
||||||
|
resolve({
|
||||||
|
statusCode: 200,
|
||||||
|
body: JSON.stringify(res.socket.getPeerCertificate()),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
req.on('error', (error) => {
|
||||||
|
resolve({
|
||||||
|
statusCode: 500,
|
||||||
|
body: `Error fetching site certificate: ${error.message}`,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
req.end();
|
||||||
|
});
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user