Check the key usage bits during certificate verification.
[gnutls.git] / tests / suite / chain
blob35bc541c9300c3947b9b033e95e39bd101601c10
1 #!/bin/sh
3 # Copyright (C) 2004-2012 Free Software Foundation, Inc.
5 # Author: Simon Josefsson
7 # This file is part of GnuTLS.
9 # GnuTLS is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by the
11 # Free Software Foundation; either version 3 of the License, or (at
12 # your option) any later version.
14 # GnuTLS is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with GnuTLS; if not, write to the Free Software Foundation,
21 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 CERTTOOL=../../../src/certtool
25 SUCCESS=" 1 4 7 12 15 16 17 18 24 26 27 30 33 56 57 62 63 "
26 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 "
27 KNOWN_BUGS=" 15 16 17 18 19 31 32 54 55 58 59 60 61 "
29 cd x509paths
31 test -d X509tests || tar xfz x509tests.tgz
32 mkdir -p chains
33 RET=0
35 i=1
36 while test -d X509tests/test$i; do
37 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
38 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
39 if test "$i" -gt 1; then
40 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
42 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
43 $CERTTOOL -e --infile chains/chain$i.pem > out 2>&1
44 rc=$?
45 if test $rc != 0 && test $rc != 1; then
46 echo "Chain $i FATAL failure."
47 RET=1
48 else
49 if echo "$KNOWN_BUGS" | grep " $i " > /dev/null 2>&1; then
50 echo "Chain $i verification was skipped due to known bug."
51 elif echo "$SUCCESS" | grep " $i " > /dev/null 2>&1; then
52 if grep 'Chain verification output:' out | grep -v 'Chain verification output: Verified\.' > /dev/null 2>&1; then
53 echo "Chain $i verification failure UNEXPECTED."
54 RET=1
55 else
56 echo "Chain $i verification success as expected."
58 elif echo "$FAILURE" | grep " $i " >/dev/null 2>&1; then
59 if grep 'Chain verification output:' out | grep -v 'Chain verification output: Verified\.' > /dev/null 2>&1; then
60 echo "Chain $i verification failure as expected."
61 else
62 echo "Chain $i verification success UNEXPECTED. "
63 RET=1
65 else
66 echo "Chain $i unclassified."
69 i=`expr $i + 1`
70 done
71 rm -f out
73 exit $RET