summaryrefslogtreecommitdiff
path: root/src/regress/lib/libcrypto/x509/bettertls/check.perl
diff options
context:
space:
mode:
authorbeck <>2020-07-15 03:13:25 +0000
committerbeck <>2020-07-15 03:13:25 +0000
commit55fd08e9f0222e9194a52692ff91d778c1bd8d7b (patch)
treea7d6815dce5a05d4898699e25a774e837d5cfc33 /src/regress/lib/libcrypto/x509/bettertls/check.perl
parent6a41084eb257af132d3a165860164f960390b37c (diff)
downloadopenbsd-55fd08e9f0222e9194a52692ff91d778c1bd8d7b.tar.gz
openbsd-55fd08e9f0222e9194a52692ff91d778c1bd8d7b.tar.bz2
openbsd-55fd08e9f0222e9194a52692ff91d778c1bd8d7b.zip
Add certificate validation tests generated using the tools from
bettertls.com, and a verification suite to try each certificate in the same manner as the web based tests do using X509_verify. This includes the list of "known" failures today in our validaion code so we can move forward without moving back.
Diffstat (limited to 'src/regress/lib/libcrypto/x509/bettertls/check.perl')
-rwxr-xr-xsrc/regress/lib/libcrypto/x509/bettertls/check.perl105
1 files changed, 105 insertions, 0 deletions
diff --git a/src/regress/lib/libcrypto/x509/bettertls/check.perl b/src/regress/lib/libcrypto/x509/bettertls/check.perl
new file mode 100755
index 0000000000..591b9a40d2
--- /dev/null
+++ b/src/regress/lib/libcrypto/x509/bettertls/check.perl
@@ -0,0 +1,105 @@
1#!/usr/bin/perl
2
3# $OpenBSD: check.perl,v 1.1 2020/07/15 03:12:42 beck Exp $
4#
5# Copyright (c) 2020 Bob Beck <beck@openbsd.org>
6#
7# Permission to use, copy, modify, and distribute this software for any
8# purpose with or without fee is hereby granted, provided that the above
9# copyright notice and this permission notice appear in all copies.
10#
11# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18#
19
20my $num_args = $#ARGV + 1;
21if ($num_args != 3) {
22 print "\nUsage: test.perl expected known testoutput\n";
23 exit 1;
24}
25
26my $expected_file=$ARGV[0];
27my $known_file=$ARGV[1];
28my $output_file=$ARGV[1];
29
30open (OUT, "<$output_file") || die "can't open $output_file";
31open (KNOWN, "<$known_file") || die "can't open $known_file";
32open (EXPECTED, "<$expected_file") || die "can't open $expected_file";
33
34my @expectedip;
35my @expecteddns;
36my @knownip;
37my @knowndns;
38my @outip;
39my @outdns;
40
41my $i = 0;
42while(<OUT>) {
43 chomp;
44 my @line = split(',');
45 my $id = $line[0];
46 die "$id mismatch with $i" if ($id != $i + 1);
47 $outdns[$i] = $line[1];
48 $outip[$i] = $line[2];
49 $i++;
50}
51$i = 0;
52while(<KNOWN>) {
53 chomp;
54 my @line = split(',');
55 my $id = $line[0];
56 die "$id mismatch with $i" if ($id != $i + 1);
57 $knowndns[$i] = $line[1];
58 $knownip[$i] = $line[2];
59 $i++;
60}
61$i = 0;
62while(<EXPECTED>) {
63 chomp;
64 my @line = split(',');
65 my $id = $line[0];
66 die "$id mismatch with $i" if ($id != $i + 1);
67 $expecteddns[$i] = $line[1];
68 $expectedip[$i] = $line[2];
69 $i++;
70}
71my $id;
72my $regressions = 0;
73my $known = 0;
74for ($id = 0; $id < $i; $id++) {
75 my $ipknown = ($outip[$id] eq $knownip[$id]);
76 my $dnsknown = ($outdns[$id] eq $knowndns[$id]);
77 if ($expecteddns[$id] ne $outdns[$id] && $expecteddns[$id] !~ /WEAK/) {
78 print STDERR "$id DNS expected $expecteddns[$id] known $knowndns[$id] result $outdns[$id]";
79 if ($dnsknown) {
80 print " (known failure)\n";
81 $known++;
82 } else {
83 print " (REGRESSED)\n";
84 $regressions++;
85 }
86 }
87 if ($expectedip[$id] ne $outip[$id] && $expectedip[$id] !~ /WEAK/) {
88 print "$id IP expected $expectedip[$id] known $knownip[$id] result $outip[$id]";
89 if ($ipknown) {
90 print " (known failure)\n";
91 $known++;
92 } else {
93 print " (REGRESSED)\n";
94 $regressions++;
95 }
96 }
97}
98print "\n\nTested $i certificates\n";
99if ($regressions == 0) {
100 print STDERR "SUCCESS - no new regressions ($known known failures)\n";
101} else {
102 print STDERR "FAILED - $regressions new regressions ($known known failures)\n";
103}
104
105