Skip to content

Commit

Permalink
test fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaker Gilbert authored and Shaker Gilbert committed Dec 1, 2024
1 parent 0b9908e commit 3abbf0c
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions tlsreader.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const tls = require('tls');
const { execFile } = require('child_process');
const { exec } = require('child_process');

function getTlsResults(hostname) {
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -78,17 +78,21 @@ function getTlsResults(hostname) {

ciphers.forEach(cipher => {
const tlsVersionFlag = cipher.startsWith('TLS_') ? '-tls1_3' : '-tls1_2';
const args = ['s_client', '-connect', `${hostname}:${port}`, '-cipher', cipher, tlsVersionFlag, '<', '/dev/null'];
const command = `openssl s_client -connect ${hostname}:${port} -cipher ${cipher} ${tlsVersionFlag} < /dev/null`;

execFile('openssl', args, (error, stdout, stderr) => {
// Parse the stdout to check if the cipher was successful
const cipherRegex = /Cipher\s*:\s*(.*)/;
const match = stdout.match(cipherRegex);

if (match && match[1].trim() === cipher) {
results.ciphers.push({ cipher, status: 'Pass' });
exec(command, (error, stdout, stderr) => {
if (error) {
results.ciphers.push({ cipher, status: 'Fail', error: error.message });
} else {
results.ciphers.push({ cipher, status: 'Fail' });
const output = stdout + stderr;
const cipherRegex = /Cipher\s*:\s*(.*)/;
const match = output.match(cipherRegex);

if (match && match[1].trim() === cipher) {
results.ciphers.push({ cipher, status: 'Pass' });
} else {
results.ciphers.push({ cipher, status: 'Fail' });
}
}

completed++;
Expand Down

0 comments on commit 3abbf0c

Please sign in to comment.