libgnutls_x509_la_SOURCES = \
common.c key_encode.c \
common.h key_decode.c \
+ gnutls-idna.h \
crl.c \
crl_write.c \
crq.c \
--- /dev/null
+/*
+ * Copyright (C) 2014 Red Hat
+ *
+ * Author: Nikos Mavrogiannopoulos
+ *
+ * This file is part of GnuTLS.
+ *
+ * The GnuTLS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser 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/>
+ *
+ */
+
+#ifndef _GNUTLS_IDNA_H
+# define _GNUTLS_IDNA_H
+
+#include <config.h>
+
+#ifdef HAVE_LIBIDN
+# include <idna.h>
+#endif
+
+#ifndef HAVE_LIBIDN
+#define IDNA_SUCCESS 0
+
+static inline
+int idna_to_ascii_8z(const char * input, char ** output, int flags)
+{
+ *output = input;
+ return 0;
+}
+
+#define idna_free(x)
+
+static inline
+const char *idna_strerror(int ret)
+{
+ return "";
+}
+#else
+# define idna_free(x) free(x)
+#endif
+
+#endif
#include <common.h>
#include <gnutls_errors.h>
#include <system.h>
-
-#ifdef HAVE_LIBIDN
-# include <idna.h>
-#endif
+#include <gnutls-idna.h>
/**
* gnutls_x509_crt_check_hostname:
return 0;
}
-#ifndef HAVE_LIBIDN
-#define IDNA_SUCCESS 0
-
-static inline
-int idna_to_ascii_8z(const char * input, char ** output, int flags)
-{
- *output = input;
- return 0;
-}
-
-#define idna_free(x)
-
-static inline
-const char *idna_strerror(int ret)
-{
- return "";
-}
-#else
-# define idna_free(x) free(x)
-#endif
-
static int has_embedded_null(const char *str, unsigned size)
{
if (strlen(str) != size)
#include <gnutls_num.h>
#include <gnutls_errors.h>
#include <extras/randomart.h>
+#include <c-ctype.h>
+#include <gnutls-idna.h>
#ifdef HAVE_INET_NTOP
# include <arpa/inet.h>
char *sname = (char*)name->data;
char str_ip[64];
const char *p;
+unsigned non_ascii = 0, i;
if ((type == GNUTLS_SAN_DNSNAME
|| type == GNUTLS_SAN_RFC822NAME
switch (type) {
case GNUTLS_SAN_DNSNAME:
- addf(str, _("%sDNSname: %.*s\n"), prefix, name->size, NON_NULL(name->data));
+#ifdef HAVE_LIBIDN
+ for (i=0;i<name->size;i++) {
+ if (c_isascii(name->data[i]) == 0) {
+ non_ascii = 1;
+ break;
+ }
+ }
+#endif
+
+ if (non_ascii != 0) {
+ char *s;
+ int rc;
+
+ rc = idna_to_ascii_8z((char*)name->data, &s, 0);
+ if (rc == IDNA_SUCCESS) {
+ addf(str, _("%sDNSname: %.*s (%s)\n"), prefix, name->size, NON_NULL(name->data), s);
+ idna_free(s);
+ } else {
+ adds(str, _("note: DNSname is not in UTF-8.\n"));
+ addf(str, _("%sDNSname: %.*s\n"), prefix, name->size, NON_NULL(name->data));
+ }
+ } else {
+ addf(str, _("%sDNSname: %.*s\n"), prefix, name->size, NON_NULL(name->data));
+ }
break;
case GNUTLS_SAN_RFC822NAME: