Skip to content

Commit c7e0953

Browse files
committed
Add unit test for certificate revocation
One positive, one negative This should detect failures in the future like in #2667, #2516 and #1275 .
1 parent 2090bdc commit c7e0953

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

t/52_ocsp_revoked.t

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env perl
2+
3+
# Check revoked.badssl.com whether certificate is revoked
4+
# and cloudflare whether is is not
5+
# Maybe amended
6+
#
7+
# We don't use a full run, only the certificate section.
8+
9+
use strict;
10+
use Test::More;
11+
use Data::Dumper;
12+
use Text::Diff;
13+
14+
my $tests = 0;
15+
my $prg="./testssl.sh";
16+
my $csv="tmp.csv";
17+
my $cat_csv="";
18+
my $check2run="-q -S --color 0 --phone-out --ip=one --severity CRITICAL --csvfile $csv";
19+
my $uri="revoked.badssl.com";
20+
my @args="";
21+
22+
die "Unable to open $prg" unless -f $prg;
23+
24+
# Provide proper start conditions
25+
unlink $csv;
26+
27+
#1 run
28+
printf "\n%s\n", "Unit test for certificate revocation against \"$uri\"";
29+
@args="$prg $check2run $uri >/dev/null";
30+
system("@args") == 0
31+
or die ("FAILED: \"@args\" ");
32+
$cat_csv=`cat $csv`;
33+
34+
# Is the certificate revoked?
35+
like($cat_csv, qr/"cert_ocspRevoked".*"CRITICAL","revoked"/,"The certificate should be revoked");
36+
$tests++;
37+
unlink $csv;
38+
39+
$uri="cloudflare.com";
40+
@args="$prg $check2run $uri >/dev/null";
41+
system("@args") == 0
42+
or die ("FAILED: \"@args\" ");
43+
$cat_csv=`cat $csv`;
44+
45+
# this should not be revoked --> no such line
46+
unlike($cat_csv, qr/cert_ocspRevoked/,"There should be no certificate revocation entry");
47+
$tests++;
48+
unlink $csv;
49+
50+
done_testing($tests);
51+
printf "\n";
52+
53+
54+
# vim:ts=5:sw=5:expandtab
55+

0 commit comments

Comments
 (0)