]> granicus.if.org Git - icinga2/blobdiff - lib/base/tlsstream.cpp
Merge pull request #6718 from Icinga/bugfix/ssl-shutdown
[icinga2] / lib / base / tlsstream.cpp
index 0c6a765254f3d185f606c6b7ce1d26ccafa15308..b771b3622600057838a7e76ee8b2d70cf8bfb7c7 100644 (file)
@@ -1,6 +1,6 @@
 /******************************************************************************
  * Icinga 2                                                                   *
- * Copyright (C) 2012-2018 Icinga Development Team (https://www.icinga.com/)  *
+ * Copyright (C) 2012-2018 Icinga Development Team (https://icinga.com/)      *
  *                                                                            *
  * This program is free software; you can redistribute it and/or              *
  * modify it under the terms of the GNU General Public License                *
@@ -21,6 +21,8 @@
 #include "base/utility.hpp"
 #include "base/exception.hpp"
 #include "base/logger.hpp"
+#include "base/configuration.hpp"
+#include "base/convert.hpp"
 #include <iostream>
 
 #ifndef _WIN32
@@ -315,14 +317,13 @@ void TlsStream::Handshake()
        m_CurrentAction = TlsActionHandshake;
        ChangeEvents(POLLOUT);
 
-       boost::system_time const timeout = boost::get_system_time() + boost::posix_time::seconds(TLS_TIMEOUT_SECONDS);
+       boost::system_time const timeout = boost::get_system_time() + boost::posix_time::milliseconds(long(Configuration::TlsHandshakeTimeout * 1000));
 
        while (!m_HandshakeOK && !m_ErrorOccurred && !m_Eof && timeout > boost::get_system_time())
                m_CV.timed_wait(lock, timeout);
 
-       // We should _NOT_ (underline, bold, itallic and wordart) throw an exception for a timeout.
        if (timeout < boost::get_system_time())
-               BOOST_THROW_EXCEPTION(std::runtime_error("Timeout during handshake."));
+               BOOST_THROW_EXCEPTION(std::runtime_error("Timeout was reached (" + Convert::ToString(Configuration::TlsHandshakeTimeout) + ") during TLS handshake."));
 
        if (m_Eof)
                BOOST_THROW_EXCEPTION(std::runtime_error("Socket was closed during TLS handshake."));