summaryrefslogtreecommitdiff
path: root/tests/suite/chain
blob: f1967c981132e017a5b4a621ab7a8f5c566ae4f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/sh

# Copyright (C) 2004-2012 Free Software Foundation, Inc.
#
# Author: Simon Josefsson
#
# This file is part of GnuTLS.
#
# GnuTLS is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at
# your option) any later version.
#
# GnuTLS is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GnuTLS; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

CERTTOOL=../../../src/certtool

SUCCESS=" 1 4 7 12 15 16 17 18 24 26 27 30 33 56 57 62 63 "
FAILURE=" 2 3 5 6 8 9 10 11 13 14 19 20 21 22 23 25 28 29 31 32 54 55 58 59 60 61 "
KNOWN_BUGS=" 15 16 17 18 19 31 32 "

cd x509paths

test -d X509tests || tar xfz x509tests.tgz
mkdir -p chains
RET=0

i=1
while test -d X509tests/test$i; do
    find X509tests/test$i -name *.crl -print0 |sort -r -z|xargs -n1 --null $CERTTOOL --crl-info --inder --infile > chains/chain$i.pem  2>/dev/null
    find X509tests/test$i -name E*.crt -print0 |sort -r -z|xargs -n1 --null $CERTTOOL --certificate-info --inder --infile >> chains/chain$i.pem 2>/dev/null
    if test "$i" -gt 1; then
	find X509tests/test$i -name I*.crt -print0 |sort -r -z|xargs -n1 --null $CERTTOOL --certificate-info --inder --infile >> chains/chain$i.pem 2>/dev/null
    fi
    find X509tests/test$i -name T*.crt -print0 |sort -r -z|xargs -n1 --null $CERTTOOL --certificate-info --inder --infile >> chains/chain$i.pem 2>/dev/null
    $CERTTOOL -e --infile chains/chain$i.pem > out 2>&1
    rc=$?
    if test $rc != 0 && test $rc != 1; then
	echo "Chain $i FATAL failure."
	RET=1
    else
	if echo "$KNOWN_BUGS" | grep " $i " > /dev/null 2>&1; then
		echo "Chain $i verification was skipped due to known bug."
	elif echo "$SUCCESS" | grep " $i " > /dev/null 2>&1; then
	    if grep 'Chain verification output:' out | grep -v 'Chain verification output: Verified\.' > /dev/null 2>&1; then
		echo "Chain $i verification failure UNEXPECTED."
		RET=1
	    else
		echo "Chain $i verification success as expected."
	    fi
	elif echo "$FAILURE" | grep " $i " >/dev/null 2>&1; then
	    if grep 'Chain verification output:' out | grep -v 'Chain verification output: Verified\.' > /dev/null 2>&1; then
		echo "Chain $i verification failure as expected."
	    else
		echo "Chain $i verification success UNEXPECTED. "
		RET=1
	    fi
	else
	    echo "Chain $i unclassified."
	fi
    fi
    i=`expr $i + 1`
done
rm -f out

exit $RET