From 5a0dfa634cfba17e00ec52877ba25209f8d177dd Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 29 Oct 2013 22:59:04 -0400 Subject: [PATCH] Certificates - Implemented TLSClient::trust, which overrides certifcate validation. --- src/TLSClient.cpp | 15 +++++++++++++++ src/TLSClient.h | 1 + 2 files changed, 16 insertions(+) diff --git a/src/TLSClient.cpp b/src/TLSClient.cpp index 579f75517..27a31b0bd 100644 --- a/src/TLSClient.cpp +++ b/src/TLSClient.cpp @@ -46,6 +46,8 @@ #define MAX_BUF 16384 +static bool trust_override = false; + //////////////////////////////////////////////////////////////////////////////// static void gnutls_log_function (int level, const char* message) { @@ -93,6 +95,19 @@ void TLSClient::debug (int level) gnutls_global_set_log_level (level); } +//////////////////////////////////////////////////////////////////////////////// +void TLSClient::trust (bool value) +{ + trust_override = value; + if (_debug) + { + if (trust_override) + std::cout << "c: INFO Server certificate trusted automatically.\n"; + else + std::cout << "c: INFO Server certificate trust verified.\n"; + } +} + //////////////////////////////////////////////////////////////////////////////// void TLSClient::init (const std::string& ca) { diff --git a/src/TLSClient.h b/src/TLSClient.h index 45e9f0cc3..668a04992 100644 --- a/src/TLSClient.h +++ b/src/TLSClient.h @@ -39,6 +39,7 @@ public: ~TLSClient (); void limit (int); void debug (int); + void trust (bool); void init (const std::string&); void connect (const std::string&, const std::string&); void bye ();