diff options
author | Attila Molnar <attilamolnar@hush.com> | 2016-04-28 17:06:16 +0200 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2016-04-28 17:06:16 +0200 |
commit | f91da925b585414ab8e768aa331f37ca2d348e2e (patch) | |
tree | 72101612a78763a9b7294490ebb1a16cb7407ca4 | |
parent | b96329dc3b775c77e98964c42cb0def7ca65ba0e (diff) |
Export the GetCiphersuite() method from the SSL modules
-rw-r--r-- | include/modules/ssl.h | 6 | ||||
-rw-r--r-- | src/modules/extra/m_ssl_gnutls.cpp | 4 | ||||
-rw-r--r-- | src/modules/extra/m_ssl_openssl.cpp | 4 |
3 files changed, 12 insertions, 2 deletions
diff --git a/include/modules/ssl.h b/include/modules/ssl.h index adc78e324..9cc504128 100644 --- a/include/modules/ssl.h +++ b/include/modules/ssl.h @@ -198,6 +198,12 @@ class SSLIOHook : public IOHook return cert->GetFingerprint(); return ""; } + + /** + * Get the ciphersuite negotiated with the peer + * @param out String where the ciphersuite string will be appended to + */ + virtual void GetCiphersuite(std::string& out) const = 0; }; /** Helper functions for obtaining SSL client certificates and key fingerprints diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index 6a653dded..69aedf03d 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -1164,8 +1164,10 @@ info_done_dealloc: } } - void GetCiphersuite(std::string& out) const + void GetCiphersuite(std::string& out) const CXX11_OVERRIDE { + if (!IsHandshakeDone()) + return; out.append(UnknownIfNULL(gnutls_protocol_get_name(gnutls_protocol_get_version(sess)))).push_back('-'); out.append(UnknownIfNULL(gnutls_kx_get_name(gnutls_kx_get(sess)))).push_back('-'); out.append(UnknownIfNULL(gnutls_cipher_get_name(gnutls_cipher_get(sess)))).push_back('-'); diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp index c9ae14e11..ed66291f4 100644 --- a/src/modules/extra/m_ssl_openssl.cpp +++ b/src/modules/extra/m_ssl_openssl.cpp @@ -735,8 +735,10 @@ class OpenSSLIOHook : public SSLIOHook } } - void GetCiphersuite(std::string& out) const + void GetCiphersuite(std::string& out) const CXX11_OVERRIDE { + if (!IsHandshakeDone()) + return; out.append(SSL_get_version(sess)).push_back('-'); out.append(SSL_get_cipher(sess)); } |