epee: fix SSL autodetect on reconnection

This commit is contained in:
xiphon 2019-06-10 10:40:16 +00:00
parent 5fbfa8a656
commit b0a04f7d45

View file

@ -193,7 +193,6 @@ namespace net_utils
return CONNECT_FAILURE; return CONNECT_FAILURE;
} }
} }
m_ssl_options.support = ssl_support_t::e_ssl_support_enabled;
} }
return CONNECT_SUCCESS; return CONNECT_SUCCESS;
}else }else
@ -223,7 +222,6 @@ namespace net_utils
return false; return false;
if (m_ssl_options.support == epee::net_utils::ssl_support_t::e_ssl_support_autodetect) if (m_ssl_options.support == epee::net_utils::ssl_support_t::e_ssl_support_autodetect)
{ {
m_ssl_options.support = epee::net_utils::ssl_support_t::e_ssl_support_enabled;
if (try_connect_result == CONNECT_NO_SSL) if (try_connect_result == CONNECT_NO_SSL)
{ {
MERROR("SSL handshake failed on an autodetect connection, reconnecting without SSL"); MERROR("SSL handshake failed on an autodetect connection, reconnecting without SSL");
@ -396,7 +394,7 @@ namespace net_utils
if (!m_connected || !m_ssl_socket->next_layer().is_open()) if (!m_connected || !m_ssl_socket->next_layer().is_open())
return false; return false;
if (ssl) if (ssl)
*ssl = m_ssl_options.support == ssl_support_t::e_ssl_support_enabled; *ssl = m_ssl_options.support != ssl_support_t::e_ssl_support_disabled;
return true; return true;
} }
@ -651,7 +649,7 @@ namespace net_utils
bool write(const void* data, size_t sz, boost::system::error_code& ec) bool write(const void* data, size_t sz, boost::system::error_code& ec)
{ {
bool success; bool success;
if(m_ssl_options.support == ssl_support_t::e_ssl_support_enabled) if(m_ssl_options.support != ssl_support_t::e_ssl_support_disabled)
success = boost::asio::write(*m_ssl_socket, boost::asio::buffer(data, sz), ec); success = boost::asio::write(*m_ssl_socket, boost::asio::buffer(data, sz), ec);
else else
success = boost::asio::write(m_ssl_socket->next_layer(), boost::asio::buffer(data, sz), ec); success = boost::asio::write(m_ssl_socket->next_layer(), boost::asio::buffer(data, sz), ec);
@ -660,7 +658,7 @@ namespace net_utils
void async_write(const void* data, size_t sz, boost::system::error_code& ec) void async_write(const void* data, size_t sz, boost::system::error_code& ec)
{ {
if(m_ssl_options.support == ssl_support_t::e_ssl_support_enabled) if(m_ssl_options.support != ssl_support_t::e_ssl_support_disabled)
boost::asio::async_write(*m_ssl_socket, boost::asio::buffer(data, sz), boost::lambda::var(ec) = boost::lambda::_1); boost::asio::async_write(*m_ssl_socket, boost::asio::buffer(data, sz), boost::lambda::var(ec) = boost::lambda::_1);
else else
boost::asio::async_write(m_ssl_socket->next_layer(), boost::asio::buffer(data, sz), boost::lambda::var(ec) = boost::lambda::_1); boost::asio::async_write(m_ssl_socket->next_layer(), boost::asio::buffer(data, sz), boost::lambda::var(ec) = boost::lambda::_1);
@ -668,7 +666,7 @@ namespace net_utils
void async_read(char* buff, size_t sz, boost::asio::detail::transfer_at_least_t transfer_at_least, handler_obj& hndlr) void async_read(char* buff, size_t sz, boost::asio::detail::transfer_at_least_t transfer_at_least, handler_obj& hndlr)
{ {
if(m_ssl_options.support != ssl_support_t::e_ssl_support_enabled) if(m_ssl_options.support == ssl_support_t::e_ssl_support_disabled)
boost::asio::async_read(m_ssl_socket->next_layer(), boost::asio::buffer(buff, sz), transfer_at_least, hndlr); boost::asio::async_read(m_ssl_socket->next_layer(), boost::asio::buffer(buff, sz), transfer_at_least, hndlr);
else else
boost::asio::async_read(*m_ssl_socket, boost::asio::buffer(buff, sz), transfer_at_least, hndlr); boost::asio::async_read(*m_ssl_socket, boost::asio::buffer(buff, sz), transfer_at_least, hndlr);