Another try

- remove -naccept as it was futile
- fix identation
- kill the server when run locally (perl's PID was wrong)
- quiet key generation

This works on both Linux and Mac locally (except some debug stuff unser MacOS)
This commit is contained in:
Dirk Wetter
2026-09-06 15:03:38 +02:00
parent d715595276
commit ca9f3746fe
+10 -17
View File
@@ -60,13 +60,13 @@ fi
# Generate self-signed cert and key if they don't exist # Generate self-signed cert and key if they don't exist
if [ ! -f "$CERT" ] || [ ! -f "$KEY" ]; then if [ ! -f "$CERT" ] || [ ! -f "$KEY" ]; then
echo "Generating self-signed certificate and key..." echo "Generating self-signed certificate and key..."
$OPENSSL req -x509 -newkey rsa:2048 -keyout "$KEY" -out "$CERT" -days 42 -nodes -subj "/CN=localhost" -addext "subjectAltName=DNS:localhost,IP:127.0.0.1" >/dev/null $OPENSSL req -quiet -x509 -newkey rsa:2048 -keyout "$KEY" -out "$CERT" -days 42 -nodes -subj "/CN=localhost" -addext "subjectAltName=DNS:localhost,IP:127.0.0.1" >/dev/null
fi fi
# Start OpenSSL server # Start OpenSSL server
echo "Starting server on port $PORT..." echo "Starting server on port $PORT..."
# $OPENSSL s_server -accept "$IP:$PORT" -cert "$CERT" -key "$KEY" -tls1_3 -ciphersuites "$CIPHER_SUITE" -naccept 4242 # $OPENSSL s_server -accept "$IP:$PORT" -cert "$CERT" -key "$KEY" -tls1_3 -ciphersuites "$CIPHER_SUITE"
$OPENSSL s_server -accept "$IP:$PORT" -cert "$CERT" -key "$KEY" -tls1_3 -naccept 4242 $OPENSSL s_server -accept "$IP:$PORT" -cert "$CERT" -key "$KEY" -tls1_3
HEREDOC HEREDOC
@@ -108,14 +108,11 @@ elsif ($pid > 0) {
close($socket); close($socket);
last; last;
} }
sleep 1; sleep (1);
} }
ok($ready, "Server is listening on $listenip:$port"); ok($ready, "Server is listening on $listenip:$port");
if ($ready) {
sleep(2);
# ---- DEBUG stuff, taken right before testssl runs ---- # ---- DEBUG stuff, taken right before testssl runs ----
my $reaped = waitpid($pid, WNOHANG); # 0 => still running my $reaped = waitpid($pid, WNOHANG); # 0 => still running
my $state = ($reaped == 0) ? 'ALIVE' : "DEAD (waitpid=$reaped)"; my $state = ($reaped == 0) ? 'ALIVE' : "DEAD (waitpid=$reaped)";
@@ -134,6 +131,8 @@ diag("DEBUG direct bash connect: " .
(`timeout 2 bash -c "echo > /dev/tcp/$listenip/$port" 2>&1 && echo OK || echo REFUSED`)); (`timeout 2 bash -c "echo > /dev/tcp/$listenip/$port" 2>&1 && echo OK || echo REFUSED`));
sleep (2);
my $log_pre = ''; my $log_pre = '';
if (open my $lfh, '<', "$temp_dir/server.log") { if (open my $lfh, '<', "$temp_dir/server.log") {
local $/; local $/;
@@ -157,16 +156,10 @@ diag("DEBUG direct bash connect: " .
diag("Server Log:\n$log"); diag("Server Log:\n$log");
} }
# Cleanup: Kill the server process # Cleanup: Kill the server process. When run locally this is needed
kill 9, $pid; my $openssl_pid = `lsof -i -Pn | grep \$USER | grep openssl | awk '{ print \$2 }'`;
waitpid($pid, 0); kill 9, $openssl_pid;
} waitpid($openssl_pid, 0);
else {
die "Fork failed: $!";
}
done_testing(); done_testing();