summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2016-01-08 12:16:29 +0100
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2016-01-08 14:20:47 +0100
commite2d69151e334946b0f67531a46c2cd89a58f9610 (patch)
tree129f99da7f7b72873bb912269f1fe58d3f55aea5
parent4a65b1a0ce58064b55c94c92dcc4445552827d37 (diff)
downloadgnutls-e2d69151e334946b0f67531a46c2cd89a58f9610.tar.gz
tests: added check for certtool's othername writing functionality
-rw-r--r--tests/cert-tests/Makefile.am4
-rwxr-xr-xtests/cert-tests/othername-test66
-rw-r--r--tests/cert-tests/template-othername.pem22
-rw-r--r--tests/cert-tests/template-othername.tmpl71
4 files changed, 161 insertions, 2 deletions
diff --git a/tests/cert-tests/Makefile.am b/tests/cert-tests/Makefile.am
index 630d0f1a4d..51b2d1ef62 100644
--- a/tests/cert-tests/Makefile.am
+++ b/tests/cert-tests/Makefile.am
@@ -35,7 +35,7 @@ EXTRA_DIST = ca-no-pathlen.pem no-ca-or-pathlen.pem aki-cert.pem \
template-generalized.tmpl privkey1.pem privkey2.pem privkey3.pem \
name-constraints-ip.pem cert-invalid-utf8.der very-long-dn.pem \
provable3072.pem provable2048.pem provable-dsa2048.pem provable-dsa2048-fips.pem \
- template-unique.tmpl template-unique.pem
+ template-unique.tmpl template-unique.pem template-othername.tmpl template-othername.pem
dist_check_SCRIPTS = pathlen aki certtool invalid-sig email \
pkcs7 privkey-import name-constraints certtool-long-cn crl provable-privkey
@@ -49,7 +49,7 @@ dist_check_SCRIPTS += crq
endif
if !WINDOWS
-dist_check_SCRIPTS += template-test pem-decoding
+dist_check_SCRIPTS += template-test pem-decoding othername-test
endif
if ENABLE_DANE
diff --git a/tests/cert-tests/othername-test b/tests/cert-tests/othername-test
new file mode 100755
index 0000000000..413e873dd2
--- /dev/null
+++ b/tests/cert-tests/othername-test
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+# Copyright (C) 2015 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 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.
+
+#set -e
+
+srcdir="${srcdir:-.}"
+CERTTOOL="${CERTTOOL:-../../src/certtool${EXEEXT}}"
+DIFF="${DIFF:-diff}"
+OUTFILE=tmp-othername.pem
+
+export TZ="UTC"
+
+# Check for datefudge
+TSTAMP=`datefudge "2006-09-23" date -u +%s || true`
+if test "$TSTAMP" != "1158969600"; then
+ echo $TSTAMP
+ echo "You need datefudge to run this test"
+ exit 77
+fi
+
+# Note that in rare cases this test may fail because the
+# time set using datefudge could have changed since the generation
+# (if example the system was busy)
+
+rc=1
+counter=1
+
+while [ "${rc}" != "0" -a $counter -le 3 ]; do
+ datefudge "2007-04-22" \
+ "${CERTTOOL}" --generate-self-signed \
+ --load-privkey "${srcdir}/template-test.key" \
+ --template "${srcdir}/template-othername.tmpl" \
+ --outfile ${OUTFILE} 2>/dev/null
+
+ ${DIFF} "${srcdir}/template-othername.pem" ${OUTFILE} >/dev/null 2>&1
+ rc=$?
+ test ${rc} != 0 && sleep 3
+ counter=`expr $counter + 1`
+done
+
+# We're done.
+if test "${rc}" != "0"; then
+ echo "Test 1 failed"
+ exit ${rc}
+fi
+
+rm -f ${OUTFILE}
+
+exit 0
diff --git a/tests/cert-tests/template-othername.pem b/tests/cert-tests/template-othername.pem
new file mode 100644
index 0000000000..49e8da7a0e
--- /dev/null
+++ b/tests/cert-tests/template-othername.pem
@@ -0,0 +1,22 @@
+-----BEGIN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VHR8E
+JzAlMCOgIaAfhh1odHRwOi8vd3d3LmdldGNybC5jcmwvZ2V0Y3JsLzANBgkqhkiG
+9w0BAQsFAAOBgQCYRfs5878sm6LHJKEPbvEhSpLykRxDvzd/mUF13whbC0WL4o2X
+4A/q3UW15vtcKhLHDErKJf7RymxObOEASzfPGnljp1kgFFO/r/3c+dBHZRmDyCak
+POg6AaOGJDE97HlvJfykuHK+CnzB30WQTQTXlHZMxXoJwcub0zT8GCt6Eg==
+-----END CERTIFICATE-----
diff --git a/tests/cert-tests/template-othername.tmpl b/tests/cert-tests/template-othername.tmpl
new file mode 100644
index 0000000000..96b9b0c2c4
--- /dev/null
+++ b/tests/cert-tests/template-othername.tmpl
@@ -0,0 +1,71 @@
+# X.509 Certificate options
+#
+# DN options
+
+dn = "cn=Nik,st=Attiki,C=GR,surName=Mavrogiannopoulos,2.5.4.9=Arkadias"
+
+# The serial number of the certificate
+serial = 7
+
+# In how many days, counting from today, this certificate will expire.
+expiration_days = 2590
+
+# X.509 v3 extensions
+
+# A dnsname in case of a WWW server.
+dns_name = "www.none.org"
+dns_name = "www.morethanone.org"
+other_name = "1.3.6.1.5.2.2 302ca00d1b0b56414e5245494e2e4f5247a11b3019a006020400000002a10f300d1b047269636b1b0561646d696e"
+other_name_utf8 = "1.3.6.1.5.5.7.8.7 nmav@gnutls.org"
+other_name_utf8 = "1.3.6.1.5.5.7.8.5 nmav@gnutls.org"
+other_name_octet = "1.2.4.5.6 a test string"
+
+# An IP address in case of a server.
+ip_address = "192.168.1.1"
+
+dns_name = "www.evenmorethanone.org"
+
+# An email in case of a person
+email = "none@none.org"
+
+# An URL that has CRLs (certificate revocation lists)
+# available. Needed in CA certificates.
+crl_dist_points = "http://www.getcrl.crl/getcrl/"
+
+email = "where@none.org"
+
+# Whether this is a CA certificate or not
+ca
+
+# Whether this certificate will be used for a TLS client
+#tls_www_client
+
+# Whether this certificate will be used for a TLS server
+#tls_www_server
+
+# Whether this certificate will be used to sign data (needed
+# in TLS DHE ciphersuites).
+signing_key
+
+# Whether this certificate will be used to encrypt data (needed
+# in TLS RSA ciphersuites). Note that it is preferred to use different
+# keys for encryption and signing.
+#encryption_key
+
+# Whether this key will be used to sign other certificates.
+cert_signing_key
+
+# Whether this key will be used to sign CRLs.
+#crl_signing_key
+
+# Whether this key will be used to sign code.
+#code_signing_key
+
+# Whether this key will be used to sign OCSP data.
+ocsp_signing_key
+
+# Whether this key will be used for time stamping.
+#time_stamping_key
+
+# Whether this key will be used for IPsec IKE operations.
+#ipsec_ike_key