diff --git a/src/vmime/net/tls/gnutls/TLSSocket_GnuTLS.cpp b/src/vmime/net/tls/gnutls/TLSSocket_GnuTLS.cpp index eea2a15b..b0a497f0 100644 --- a/src/vmime/net/tls/gnutls/TLSSocket_GnuTLS.cpp +++ b/src/vmime/net/tls/gnutls/TLSSocket_GnuTLS.cpp @@ -94,8 +94,6 @@ void TLSSocket_GnuTLS::connect(const string& address, const port_t port) { try { - gnutls_server_name_set(*m_session->m_gnutlsSession, GNUTLS_NAME_DNS, address.c_str(), address.size()); - m_wrapped->connect(address, port); handshake(); @@ -319,6 +317,9 @@ void TLSSocket_GnuTLS::handshake() { // Start handshaking process try { + string peerAddress = getPeerAddress(); + + gnutls_server_name_set(*m_session->m_gnutlsSession, GNUTLS_NAME_DNS, peerAddress.c_str(), peerAddress.size()); while (true) {