- TD-79 Bad error message for wrong hostname configuration (thanks to Jens
        Erat).
This commit is contained in:
Paul Beckingham 2014-10-23 22:46:50 -04:00
parent 959df159fa
commit 2c6b3b3991
3 changed files with 11 additions and 7 deletions

View file

@ -233,3 +233,4 @@ suggestions:
dev-zero dev-zero
Petteri Petteri
Black Ops Testing Black Ops Testing
Jens Erat

View file

@ -8,6 +8,8 @@
- TD-56 File.cpp needs to include <string.h> on Solaris (thanks to Tatjana - TD-56 File.cpp needs to include <string.h> on Solaris (thanks to Tatjana
Heuѕer). Heuѕer).
- TD-57 taskdctl script assumes /bin/sh is /bin/bash (thanks to Tatjana Heuser). - 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). - #1255 l10n translation utility improvements (thanks to Renato Alves).
- #1473 Make TASK_RCDIR customizable (thanks to Elias Probst). - #1473 Make TASK_RCDIR customizable (thanks to Elias Probst).
- #1486 Truncated sentence in task-sync(5) manpage (thanks to Jakub Wilk). - #1486 Truncated sentence in task-sync(5) manpage (thanks to Jakub Wilk).

View file

@ -42,6 +42,7 @@
#include <sys/errno.h> #include <sys/errno.h>
#endif #endif
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h> #include <netdb.h>
#include <TLSClient.h> #include <TLSClient.h>
#include <gnutls/x509.h> #include <gnutls/x509.h>
@ -119,11 +120,11 @@ void TLSClient::trust (const enum trust_level value)
if (_debug) if (_debug)
{ {
if (_trust == allow_all) 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) 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 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 hints.ai_flags = AI_PASSIVE; // use my IP
struct addrinfo* res; struct addrinfo* res;
if (::getaddrinfo (host.c_str (), port.c_str (), &hints, &res) != 0) int ret = ::getaddrinfo (host.c_str (), port.c_str (), &hints, &res);
throw std::string (::gai_strerror (errno)); if (ret != 0)
throw std::string (::gai_strerror (ret));
// Try them all, stop on success. // Try them all, stop on success.
struct addrinfo* p; struct addrinfo* p;
@ -247,7 +249,6 @@ void TLSClient::connect (const std::string& host, const std::string& port)
#endif #endif
// Perform the TLS handshake // Perform the TLS handshake
int ret;
do do
{ {
ret = gnutls_handshake (_session); 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 // gnutls_certificate_set_verify_function does only work with gnutls
// >=2.9.10. So with older versions we should call the verify function // >=2.9.10. So with older versions we should call the verify function
// manually after the gnutls handshake. // manually after the gnutls handshake.
ret = verify_certificate(); ret = verify_certificate ();
if (ret < 0) if (ret < 0)
{ {
if (_debug) if (_debug)