[glib-networking] Avoid trailing dots in SNI hostnames
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib-networking] Avoid trailing dots in SNI hostnames
- Date: Wed, 8 Aug 2018 17:59:09 +0000 (UTC)
commit f8703406a623d7bfcf27cc466386dc6532532285
Author: Michael Catanzaro <mcatanzaro igalia com>
Date: Wed Aug 8 12:55:15 2018 -0500
Avoid trailing dots in SNI hostnames
Sending the trailing dot violates RFC 6066 section 3: "The hostname is
represented as a byte string using ASCII encoding without a trailing
dot." gnutls_server_name_set() should probably strip the trailing dot
for us, but man page says we are responsible for doing so manually... so
do it.
Hopefully fixes #11
tls/gnutls/gtlsclientconnection-gnutls.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/tls/gnutls/gtlsclientconnection-gnutls.c b/tls/gnutls/gtlsclientconnection-gnutls.c
index af8e823..cac2deb 100644
--- a/tls/gnutls/gtlsclientconnection-gnutls.c
+++ b/tls/gnutls/gtlsclientconnection-gnutls.c
@@ -213,8 +213,15 @@ g_tls_client_connection_gnutls_initable_init (GInitable *initable,
hostname = get_server_identity (G_TLS_CLIENT_CONNECTION_GNUTLS (gnutls));
if (hostname)
{
+ gchar *normalized_hostname = g_strdup (hostname);
+
+ if (hostname[strlen (hostname) - 1] == '.')
+ normalized_hostname[strlen (hostname) - 1] = '\0';
+
gnutls_server_name_set (session, GNUTLS_NAME_DNS,
- hostname, strlen (hostname));
+ normalized_hostname, strlen (normalized_hostname));
+
+ g_free (normalized_hostname);
}
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]