mirror of
https://github.com/Lissy93/web-check.git
synced 2025-01-10 16:28:18 +01:00
31 lines
637 B
JavaScript
31 lines
637 B
JavaScript
|
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();
|
||
|
});
|
||
|
};
|