summaryrefslogtreecommitdiff
path: root/tests/hostname-check-utf8.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2017-04-04 20:13:11 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2017-05-01 12:58:23 +0200
commitabe6a12b9766219163f99d7807a0b07fbe5f590c (patch)
treed6ae3a7993290b2fa9d688cdf5be1f738be2b612 /tests/hostname-check-utf8.c
parent8f981f0373fd3484659a5b0452306d01e13fc26d (diff)
downloadgnutls-abe6a12b9766219163f99d7807a0b07fbe5f590c.tar.gz
Removed support for libidn1
Currently we support both IDNA2003 and IDNA2008. However, IDNA2003 is already obsolete by registrars and NICs, thus there is no reason to continue supporting it. We switch to IDNA2008 exclusively using libidn2. Resolves #194 Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
Diffstat (limited to 'tests/hostname-check-utf8.c')
-rw-r--r--tests/hostname-check-utf8.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/tests/hostname-check-utf8.c b/tests/hostname-check-utf8.c
index 10128bc774..06ce1b7bdf 100644
--- a/tests/hostname-check-utf8.c
+++ b/tests/hostname-check-utf8.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Red Hat, Inc.
+ * Copyright (C) 2016-2017 Red Hat, Inc.
*
* Author: Nikos Mavrogiannopoulos
*
@@ -27,8 +27,10 @@
#include <string.h>
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
-#ifdef ENABLE_OPENPGP
-#include <gnutls/openpgp.h>
+
+#if defined(HAVE_LIBIDN2)
+/* to obtain version */
+#include <idn2.h>
#endif
#include "utils.h"
@@ -101,6 +103,10 @@ void doit(void)
gnutls_datum_t data;
int ret;
+#if !defined(HAVE_LIBIDN2)
+ exit(77);
+#endif
+
ret = global_init();
if (ret < 0)
fail("global_init: %d\n", ret);
@@ -142,6 +148,15 @@ void doit(void)
if (ret)
fail("%d: Invalid hostname incorrectly matches (%d)\n", __LINE__, ret);
+#if IDN2_VERSION_NUMBER >= 0x00160000
+ ret = gnutls_x509_crt_check_hostname(x509, "γΓγ.τόΣτ.gr");
+ if (ret)
+ fail("%d: Hostname incorrectly matches (%d)\n", __LINE__, ret);
+
+ ret = gnutls_x509_crt_check_hostname(x509, "ΤΈΣΤ.gr");
+ if (ret)
+ fail("%d: Hostname incorrectly matches (%d)\n", __LINE__, ret);
+#endif
ret = gnutls_x509_crt_check_hostname(x509, "γγγ.τόστ.gr");
if (ret)
fail("%d: Invalid hostname incorrectly matches (%d)\n", __LINE__, ret);
@@ -188,7 +203,6 @@ void doit(void)
if (ret)
fail("%d: Hostname incorrectly matches (%d)\n", __LINE__, ret);
-#if defined(HAVE_LIBIDN) || defined(HAVE_LIBIDN2)
ret = gnutls_x509_crt_check_hostname(x509, "www.teχ.gr");
if (!ret)
fail("%d: Hostname incorrectly does not match (%d)\n", __LINE__, ret);
@@ -201,7 +215,7 @@ void doit(void)
if (!ret)
fail("%d: Hostname incorrectly does not match (%d)\n", __LINE__, ret);
-#if defined(HAVE_LIBIDN) /* There are IDNA2003 */
+#if IDN2_VERSION_NUMBER >= 0x00160000
ret = gnutls_x509_crt_check_hostname(x509, "γΓγ.τόΣτ.gr");
if (!ret)
fail("%d: Hostname incorrectly does not match (%d)\n", __LINE__, ret);
@@ -210,7 +224,6 @@ void doit(void)
if (!ret)
fail("%d: Hostname incorrectly does not match (%d)\n", __LINE__, ret);
#endif
-#endif
gnutls_x509_crt_deinit(x509);