mirror of
https://codeberg.org/alicia/web-check.git
synced 2026-03-14 14:45:48 +01:00
Makes SSL check much more comprehensive
This commit is contained in:
parent
9b9c31674d
commit
a8eadf40b0
1 changed files with 12 additions and 3 deletions
15
api/ssl.js
15
api/ssl.js
|
|
@ -1,10 +1,20 @@
|
|||
const https = require('https');
|
||||
const middleware = require('./_common/middleware');
|
||||
const urlModule = require('url');
|
||||
|
||||
const fetchSiteCertificateHandler = async (url) => {
|
||||
const fetchSiteCertificateHandler = async (urlString) => {
|
||||
try {
|
||||
const parsedUrl = urlModule.parse(urlString);
|
||||
const options = {
|
||||
host: parsedUrl.hostname,
|
||||
port: parsedUrl.port || 443, // Default port for HTTPS
|
||||
method: 'GET',
|
||||
servername: parsedUrl.hostname, // For SNI
|
||||
rejectUnauthorized: false // Disable strict SSL verification (use with caution)
|
||||
};
|
||||
|
||||
const response = await new Promise((resolve, reject) => {
|
||||
const req = https.request(url, res => {
|
||||
const req = https.request(options, res => {
|
||||
|
||||
// Check if the SSL handshake was authorized
|
||||
if (!res.socket.authorized) {
|
||||
|
|
@ -14,7 +24,6 @@ const fetchSiteCertificateHandler = async (url) => {
|
|||
if (!cert || Object.keys(cert).length === 0) {
|
||||
reject(new Error("No certificate presented by the server."));
|
||||
} else {
|
||||
// omit the raw and issuerCertificate fields
|
||||
const { raw, issuerCertificate, ...certWithoutRaw } = cert;
|
||||
resolve(certWithoutRaw);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue