From 2c6b3b3991e382e3890cf3165d3e279ca3f973c2 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Thu, 23 Oct 2014 22:46:50 -0400 Subject: [PATCH] TD-79 - TD-79 Bad error message for wrong hostname configuration (thanks to Jens Erat). --- AUTHORS | 1 + ChangeLog | 2 ++ src/TLSClient.cpp | 15 ++++++++------- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/AUTHORS b/AUTHORS index c1ac41eef..7b41cff96 100644 --- a/AUTHORS +++ b/AUTHORS @@ -233,3 +233,4 @@ suggestions: dev-zero Petteri Black Ops Testing + Jens Erat diff --git a/ChangeLog b/ChangeLog index e5edb7a59..f3c50917c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,8 @@ - TD-56 File.cpp needs to include on Solaris (thanks to Tatjana Heuѕer). - TD-57 taskdctl script assumes /bin/sh is /bin/bash (thanks to Tatjana Heuser). +- TD-79 Bad error message for wrong hostname configuration (thanks to Jens + Erat). - #1255 l10n translation utility improvements (thanks to Renato Alves). - #1473 Make TASK_RCDIR customizable (thanks to Elias Probst). - #1486 Truncated sentence in task-sync(5) manpage (thanks to Jakub Wilk). diff --git a/src/TLSClient.cpp b/src/TLSClient.cpp index e603edc28..2abf0a0e5 100644 --- a/src/TLSClient.cpp +++ b/src/TLSClient.cpp @@ -42,6 +42,7 @@ #include #endif #include +#include #include #include #include @@ -119,11 +120,11 @@ void TLSClient::trust (const enum trust_level value) if (_debug) { if (_trust == allow_all) - std::cout << "c: INFO Server certificate trusted automatically.\n"; + std::cout << "c: INFO Server certificate will be trusted automatically.\n"; else if (_trust == ignore_hostname) - std::cout << "c: INFO Server certificate trust verified but hostname ignored.\n"; + std::cout << "c: INFO Server certificate will be verified but hostname ignored.\n"; else - std::cout << "c: INFO Server certificate trust verified.\n"; + std::cout << "c: INFO Server certificate will be verified.\n"; } } @@ -208,8 +209,9 @@ void TLSClient::connect (const std::string& host, const std::string& port) hints.ai_flags = AI_PASSIVE; // use my IP struct addrinfo* res; - if (::getaddrinfo (host.c_str (), port.c_str (), &hints, &res) != 0) - throw std::string (::gai_strerror (errno)); + int ret = ::getaddrinfo (host.c_str (), port.c_str (), &hints, &res); + if (ret != 0) + throw std::string (::gai_strerror (ret)); // Try them all, stop on success. struct addrinfo* p; @@ -247,7 +249,6 @@ void TLSClient::connect (const std::string& host, const std::string& port) #endif // Perform the TLS handshake - int ret; do { ret = gnutls_handshake (_session); @@ -261,7 +262,7 @@ void TLSClient::connect (const std::string& host, const std::string& port) // gnutls_certificate_set_verify_function does only work with gnutls // >=2.9.10. So with older versions we should call the verify function // manually after the gnutls handshake. - ret = verify_certificate(); + ret = verify_certificate (); if (ret < 0) { if (_debug)