summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2017-11-21 16:31:02 +0100
committerNikos Mavrogiannopoulos <nmav@redhat.com>2018-02-19 15:29:37 +0100
commitff5eb736c0476f53594cdd50b4b1751a98beeeb3 (patch)
tree1cd05bd8563e5cda854484ae39ae131777536075
parentdb486d97c53725fe7917f1a4cb272e7e83536021 (diff)
downloadgnutls-ff5eb736c0476f53594cdd50b4b1751a98beeeb3.tar.gz
tests: added ocsptool sanity check program
This checks its functionality in loading and exporting PEM and DER structures. Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
-rw-r--r--tests/Makefile.am3
-rwxr-xr-xtests/ocsp-tests/ocsptool89
-rw-r--r--tests/ocsp-tests/response1.pem45
-rw-r--r--tests/ocsp-tests/response2.pem47
4 files changed, 183 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f42b88f372..26bb86075d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -57,6 +57,7 @@ EXTRA_DIST = suppressions.valgrind eagain-common.h cert-common.h test-chains.h \
rng-op.c x509sign-verify-common.h common-key-tests.h \
ocsp-tests/certs/ca.key ocsp-tests/certs/ca.pem ocsp-tests/certs/ocsp-server.key ocsp-tests/certs/ocsp-server.pem ocsp-tests/response1.der \
ocsp-tests/response2.der ocsp-tests/certs/ocsp_index.txt ocsp-tests/certs/ocsp_index.txt.attr \
+ ocsp-tests/response1.pem ocsp-tests/response2.pem \
ocsp-tests/certs/server_good.key ocsp-tests/certs/server_bad.key ocsp-tests/certs/server_good.template \
ocsp-tests/certs/server_bad.template ocsp-tests/certs/ocsp-staple-unrelated.der ocsp-tests/suppressions.valgrind \
data/listings-DTLS1.0 data/listings-SSL3.0 data/listings-TLS1.0 data/listings-TLS1.1 \
@@ -380,7 +381,7 @@ dist_check_SCRIPTS += fastopen.sh pkgconfig.sh starttls.sh starttls-ftp.sh start
ocsp-tests/ocsp-tls-connection ocsp-tests/ocsp-must-staple-connection \
ocsp-tests/ocsp-test cipher-listings.sh sni-hostname.sh server-multi-keys.sh \
psktool.sh ocsp-tests/ocsp-load-chain gnutls-cli-save-data.sh gnutls-cli-debug.sh \
- sni-resume.sh
+ sni-resume.sh ocsp-tests/ocsptool
dist_check_SCRIPTS += gnutls-cli-self-signed.sh
diff --git a/tests/ocsp-tests/ocsptool b/tests/ocsp-tests/ocsptool
new file mode 100755
index 0000000000..22d5bd3fb2
--- /dev/null
+++ b/tests/ocsp-tests/ocsptool
@@ -0,0 +1,89 @@
+#!/bin/sh
+
+# Copyright (C) 2017 Red Hat, Inc.
+#
+# 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 Lesser General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>
+
+#set -e
+
+# Sanity check program for various ocsptool options
+
+srcdir="${srcdir:-.}"
+OCSPTOOL="${OCSPTOOL:-../src/ocsptool${EXEEXT}}"
+DIFF="${DIFF:-diff}"
+CMP="${CMP:-cmp}"
+TMPFILE=ocsp.$$.tmp
+
+if ! test -x "${OCSPTOOL}"; then
+ exit 77
+fi
+
+export TZ="UTC"
+
+"${OCSPTOOL}" -j --infile "${srcdir}/ocsp-tests/response1.pem" --outfile "${TMPFILE}"
+rc=$?
+
+# We're done.
+if test "${rc}" != "0"; then
+ echo "Test 1 - PEM loading failed"
+ exit ${rc}
+fi
+
+${CMP} "${srcdir}/ocsp-tests/response1.der" "${TMPFILE}" >/dev/null 2>&1
+rc=$?
+if test "${rc}" != "0"; then
+ echo "Test 1 - Comparison of DER file failed"
+ exit ${rc}
+fi
+
+"${OCSPTOOL}" -j --outpem --infile "${srcdir}/ocsp-tests/response1.pem" --outfile "${TMPFILE}"
+rc=$?
+
+# We're done.
+if test "${rc}" != "0"; then
+ echo "Test 2 - PEM loading failed"
+ exit ${rc}
+fi
+
+${DIFF} -B "${srcdir}/ocsp-tests/response1.pem" "${TMPFILE}" >/dev/null 2>&1
+rc=$?
+if test "${rc}" != "0"; then
+ echo "Test 2 - Comparison of PEM file failed $TMPFILE"
+ exit ${rc}
+fi
+
+
+"${OCSPTOOL}" -j --infile "${srcdir}/ocsp-tests/response1.der"
+rc=$?
+
+# We're done.
+if test "${rc}" != "0"; then
+ echo "Test 3 - Transparent (backwards compatible) DER loading failed"
+ exit ${rc}
+fi
+
+"${OCSPTOOL}" -j --inder --infile "${srcdir}/ocsp-tests/response1.der"
+rc=$?
+
+# We're done.
+if test "${rc}" != "0"; then
+ echo "Test 4 - DER loading failed"
+ exit ${rc}
+fi
+
+rm -f "${TMPFILE}"
+
+exit 0
diff --git a/tests/ocsp-tests/response1.pem b/tests/ocsp-tests/response1.pem
new file mode 100644
index 0000000000..66adfe30e7
--- /dev/null
+++ b/tests/ocsp-tests/response1.pem
@@ -0,0 +1,45 @@
+OCSP Response Information:
+ Response Status: Successful
+ Response Type: Basic OCSP Response
+ Version: 1
+ Responder ID: CN=Testing Authority
+ Produced At: Wed Mar 23 21:55:28 UTC 2016
+ Responses:
+ Certificate ID:
+ Hash Algorithm: SHA1
+ Issuer Name Hash: bac68790352ceb4c4de1534445348f8b4b5309b3
+ Issuer Key Hash: e865fcb9123c7285fc28c803149f06ad94dfd934
+ Serial Number: 56f304a1326dc9b2d51b31b3
+ Certificate Status: unknown
+ This Update: Wed Mar 23 21:55:28 UTC 2016
+ Extensions:
+ Signature Algorithm: RSA-SHA256
+
+-----BEGIN OCSP RESPONSE-----
+MIIEwAoBAKCCBLkwggS1BgkrBgEFBQcwAQEEggSmMIIEojCBj6EeMBwxGjAYBgNV
+BAMTEVRlc3RpbmcgQXV0aG9yaXR5GA8yMD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AeFga
+tyXUuxSvPq8rVTVYvb6+AOXBVTDidp0CAwEAAaMyMDAwDwYDVR0TAQH/BAUwAwEB
+/zAdBgNVHQ4EFgQULdgUmhbVbf77sODe8fXFIwvTYr4wDQYJKoZIhvcNAQELBQAD
+ggEBAGGF8as/0Ew1prrQKOKSbVB3nrILF7D9fOxKIEUEOprtYGgjvvfkqG7xDQRP
+SvIiVy3X0wZQpzytCgvkjXeQ8QsIIMnrYpjy6iRCRkDlti3iUqx6zo7B7iYaEIdK
+Ky6uCn5z/RPti5WJIeqvg3WqTNeOXjWIK3ac6cROqUcUlLxy1AukNRYuvpVszQu9
+FDs9ecdA5aOvBvb0WlVjbEU37EVuoveayBpgP0c2I7xu2zAkobNdn7JYNOGJx4x9
+8WMlcCP0ZU7O0wwk9y/U/FxARqfFIzDC2JanTi2LxyHdQw8iWAvaBksb7vLdMnn2
+9prXtfKhcCXLVECxSJuI1swHETA=
+-----END OCSP RESPONSE-----
diff --git a/tests/ocsp-tests/response2.pem b/tests/ocsp-tests/response2.pem
new file mode 100644
index 0000000000..1ca75c39a9
--- /dev/null
+++ b/tests/ocsp-tests/response2.pem
@@ -0,0 +1,47 @@
+OCSP Response Information:
+ Response Status: Successful
+ Response Type: Basic OCSP Response
+ Version: 1
+ Responder ID: CN=Testing Authority OCSP Responder
+ Produced At: Wed Mar 23 22:31:19 UTC 2016
+ Responses:
+ Certificate ID:
+ Hash Algorithm: SHA1
+ Issuer Name Hash: bac68790352ceb4c4de1534445348f8b4b5309b3
+ Issuer Key Hash: e865fcb9123c7285fc28c803149f06ad94dfd934
+ Serial Number: 56f318d612de99176ccaa1e0
+ Certificate Status: unknown
+ This Update: Wed Mar 23 22:31:19 UTC 2016
+ Extensions:
+ Signature Algorithm: RSA-SHA256
+
+-----BEGIN OCSP RESPONSE-----
+MIIFIgoBAKCCBRswggUXBgkrBgEFBQcwAQEEggUIMIIFBDCBnqEtMCsxKTAnBgNV
+BAMTIFRlc3RpbmcgQXV0aG9yaXR5I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