Skip to content

Commit 1f9aa80

Browse files
committed
For Mac: use homebrew's openssl
... so that we have a comparison between OpenSSL and LibreSSL. Otherwise this test would be completely futile for MacOS. Also change the displayed text. See #2832 (which was for 3.2)
1 parent 84bfb30 commit 1f9aa80

1 file changed

Lines changed: 43 additions & 4 deletions

File tree

t/12_diff_opensslversions.t

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ my $uri="google.com";
2020
my $diff="";
2121
my $distro_openssl="/usr/bin/openssl";
2222
my @args="";
23+
# that can be done better but I am a perl n00b ;-)
24+
my $os=`perl -e 'print "$^O";'`;
2325

2426
die "Unable to open $prg" unless -f $prg;
2527
die "Unable to open $distro_openssl" unless -f $distro_openssl;
@@ -29,13 +31,35 @@ unlink $csvfile;
2931
unlink $csvfile2;
3032

3133
#1 run
32-
printf "\n%s\n", "Diff test IPv4 with supplied openssl against \"$uri\"";
33-
@args="$prg $check2run $csvfile $uri >/dev/null";
34+
if ( $os eq "linux" ){
35+
# Comparison ~/bin/openssl.Linux.x86_64
36+
printf "\n%s\n", "Test with supplied openssl against \"$uri\" and save it";
37+
@args="$prg $check2run $csvfile $uri >/dev/null";
38+
} elsif ( $os eq "darwin" ){
39+
# MacOS silicon doesn't have ~/bin/openssl.Darwin.arm64 binary so we use the
40+
# homebrew version which was moved to /opt/homebrew/bin/openssl.NOPE in
41+
# .github/workflows/unit_tests_macos.yml . This gives us instead a comparison
42+
# check from OpenSSL
43+
# If this will be run outside GH actions, i.e. locally, we provide a fallback to
44+
# /opt/homebrew/bin/openssl or just leave this thing
45+
if ( -x "/opt/homebrew/bin/openssl.NOPE" ) {
46+
printf "\n%s\n", "Test with homebrew's openssl 3.5.x against \"$uri\" and save it";
47+
@args="$prg $check2run $csvfile --openssl /opt/homebrew/bin/openssl.NOPE $uri >/dev/null";
48+
}
49+
elsif ( -x "/opt/homebrew/bin/openssl" ) {
50+
printf "\n%s\n", "Test with homebrew's openssl 3.5.x against \"$uri\" and save it";
51+
@args="$prg $check2run $csvfile --openssl /opt/homebrew/bin/openssl $uri >/dev/null";
52+
}
53+
else {
54+
die ("No alternative version to LibreSSL found");
55+
}
56+
}
3457
system("@args") == 0
3558
or die ("FAILED: \"@args\"");
3659

37-
# 2
38-
printf "\n%s\n", "Diff test IPv4 with $distro_openssl against \"$uri\"";
60+
61+
# 2 (LibreSSL in case of MacOS, /usr/bin/openssl for Linux)
62+
printf "\n%s\n", "Test with $distro_openssl against \"$uri\" and save it";
3963
@args="$prg $check2run $csvfile2 --openssl=$distro_openssl $uri >/dev/null";
4064
system("@args") == 0
4165
or die ("FAILED: \"@args\" ");
@@ -67,6 +91,21 @@ $cat_csvfile2 =~ s/.nonce-.* //g;
6791
$cat_csvfile =~ s/","google.com\/.*","443/","google.com","443/g;
6892
$cat_csvfile2 =~ s/","google.com\/.*","443/","google.com","443/g;
6993

94+
95+
if ( $os eq "darwin" ){
96+
# Now address the differences for LibreSSL, see t/61_diff_testsslsh.t
97+
#
98+
# MacOS / LibreSSL has different OpenSSL names for TLS 1.3 ciphers. That should be rather solved in
99+
# testssl.sh, see #2763. But for now we do this here.
100+
$cat_csvfile2 =~ s/AEAD-AES128-GCM-SHA256/TLS_AES_128_GCM_SHA256/g;
101+
$cat_csvfile2 =~ s/AEAD-AES256-GCM-SHA384/TLS_AES_256_GCM_SHA384/g;
102+
# this is a bit ugly but otherwise the line cipher-tls1_3_x1303 with the CHACHA20 cipher misses a space
103+
$cat_csvfile2 =~ s/x1303 AEAD-CHACHA20-POLY1305-SHA256/x1303 TLS_CHACHA20_POLY1305_SHA256 /g;
104+
# now the other lines, where we don't need to insert the additional space:
105+
$cat_csvfile2 =~ s/AEAD-CHACHA20-POLY1305-SHA256/TLS_CHACHA20_POLY1305_SHA256/g;
106+
# we changed above the ECDH bit length already
107+
}
108+
70109
$diff = diff \$cat_csvfile, \$cat_csvfile2;
71110

72111
# Compare the differences -- and print them if there were any

0 commit comments

Comments
 (0)