mirror of
https://github.com/Lissy93/web-check.git
synced 2025-04-30 20:34:28 +02:00
Fixed SSL checking lambda function
This commit is contained in:
parent
c1ea5788c8
commit
397609e7bc
15
netlify.toml
15
netlify.toml
@ -5,9 +5,24 @@
|
||||
publish = "build"
|
||||
functions = "server/lambda"
|
||||
|
||||
# Environmental variables and optioanl secrets
|
||||
[build.environment]
|
||||
NODE_VERSION = "16.16.0"
|
||||
GOOGLE_CLOUD_API_KEY=''
|
||||
SHODAN_API_KEY=''
|
||||
REACT_APP_SHODAN_API_KEY=''
|
||||
WHO_API_KEY=''
|
||||
REACT_APP_WHO_API_KEY=''
|
||||
SECURITY_TRAILS_API_KEY=''
|
||||
BUILT_WITH_API_KEY=''
|
||||
CI=false
|
||||
|
||||
[dev]
|
||||
command = "yarn start"
|
||||
port = 8888
|
||||
targetPort = 3000
|
||||
publish = "dist"
|
||||
autoLaunch = false
|
||||
|
||||
# Site info, used for the 1-Click deploy page
|
||||
[template.environment]
|
||||
|
@ -1,5 +1,4 @@
|
||||
const https = require('https');
|
||||
const { stringify } = require('flatted');
|
||||
|
||||
exports.handler = async function (event, context) {
|
||||
const { url } = event.queryStringParameters;
|
||||
@ -12,10 +11,7 @@ exports.handler = async function (event, context) {
|
||||
};
|
||||
|
||||
if (!url) {
|
||||
return {
|
||||
statusCode: 400,
|
||||
body: errorResponse('url query parameter is required'),
|
||||
};
|
||||
return errorResponse('url query parameter is required');
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
@ -25,21 +21,22 @@ exports.handler = async function (event, context) {
|
||||
if (!res.socket.authorized) {
|
||||
resolve(errorResponse(`SSL handshake not authorized. Reason: ${res.socket.authorizationError}`));
|
||||
} else {
|
||||
const cert = res.socket.getPeerCertificate(true);
|
||||
let cert = res.socket.getPeerCertificate(true);
|
||||
if (!cert || Object.keys(cert).length === 0) {
|
||||
resolve(errorResponse("No certificate presented by the server."));
|
||||
} else {
|
||||
// omit the raw and issuerCertificate fields
|
||||
const { raw, issuerCertificate, ...certWithoutRaw } = cert;
|
||||
resolve({
|
||||
statusCode: 200,
|
||||
body: stringify(cert),
|
||||
body: JSON.stringify(certWithoutRaw),
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
req.on('error', (error) => {
|
||||
resolve(
|
||||
errorResponse(`Error fetching site certificate: ${error.message}`, 500));
|
||||
resolve(errorResponse(`Error fetching site certificate: ${error.message}`, 500));
|
||||
});
|
||||
|
||||
req.end();
|
||||
|
Loading…
Reference in New Issue
Block a user