Skip to content

Commit 87d57bb

Browse files
authored
Merge pull request #2700 from testssl/unitttest_revocation
Unit test revocation
2 parents 2090bdc + 52476b8 commit 87d57bb

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

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+

testssl.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2097,7 +2097,7 @@ check_revocation_ocsp() {
20972097
host_header=${uri##http://}
20982098
host_header=${host_header%%/*}
20992099

2100-
# This the follwomg is the default (like "-header Host r11.o.lencr.org")
2100+
# The following is the default (like "-header Host r11.o.lencr.org")
21012101
host_header="-header Host ${host_header}"
21022102

21032103
if "$smartswitch" ; then

0 commit comments

Comments
 (0)