From b047c903da20862783b50af73594cce1592cbbfe Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Sun, 29 Oct 2017 11:15:47 +0000 Subject: Add support to IOHook for retrieving the hostname sent via SNI. --- src/modules/extra/m_ssl_gnutls.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/modules/extra/m_ssl_gnutls.cpp') diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index 08b4be08f..50c847ee4 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -1182,6 +1182,25 @@ info_done_dealloc: out.append(UnknownIfNULL(gnutls_mac_get_name(gnutls_mac_get(sess)))); } + bool GetServerName(std::string& out) const CXX11_OVERRIDE + { + std::vector nameBuffer; + size_t nameLength = 0; + unsigned int nameType = GNUTLS_NAME_DNS; + + // First, determine the size of the hostname. + if (gnutls_server_name_get(sess, &nameBuffer[0], &nameLength, &nameType, 0) != GNUTLS_E_SHORT_MEMORY_BUFFER) + return false; + + // Then retrieve the hostname. + nameBuffer.resize(nameLength); + if (gnutls_server_name_get(sess, &nameBuffer[0], &nameLength, &nameType, 0) != GNUTLS_E_SUCCESS) + return false; + + out.append(&nameBuffer[0]); + return true; + } + GnuTLS::Profile* GetProfile() { return profile; } bool IsHandshakeDone() const { return (status == ISSL_HANDSHAKEN); } }; -- cgit v1.2.3