]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
m_ssl_gnutls, m_ssl_openssl Extract code that builds a ciphersuite string into a...
authorAttila Molnar <attilamolnar@hush.com>
Tue, 27 Jan 2015 15:52:21 +0000 (16:52 +0100)
committerAttila Molnar <attilamolnar@hush.com>
Tue, 27 Jan 2015 15:52:21 +0000 (16:52 +0100)
src/modules/extra/m_ssl_gnutls.cpp
src/modules/extra/m_ssl_openssl.cpp

index be642a79d65512187d49c00379662ffe1318691a..967cb2a8ec0fe41f8a5d2549dcc2bbccba3cbcd1 100644 (file)
@@ -934,11 +934,8 @@ info_done_dealloc:
                if (sess)
                {
                        std::string text = "*** You are connected using SSL cipher '";
-
-                       text += UnknownIfNULL(gnutls_kx_get_name(gnutls_kx_get(sess)));
-                       text.append("-").append(UnknownIfNULL(gnutls_cipher_get_name(gnutls_cipher_get(sess)))).append("-");
-                       text.append(UnknownIfNULL(gnutls_mac_get_name(gnutls_mac_get(sess)))).append("'");
-
+                       GetCiphersuite(text);
+                       text += '\'';
                        if (!certificate->fingerprint.empty())
                                text += " and your SSL certificate fingerprint is " + certificate->fingerprint;
 
@@ -946,6 +943,13 @@ info_done_dealloc:
                }
        }
 
+       void GetCiphersuite(std::string& out) const
+       {
+               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('-');
+               out.append(UnknownIfNULL(gnutls_mac_get_name(gnutls_mac_get(sess))));
+       }
+
        GnuTLS::Profile* GetProfile() { return profile; }
 };
 
index b38478d6d992cb0429f6fc1c3db372cef1582949..2b45625448e409306a11ed579528d0c085e42d99 100644 (file)
@@ -678,7 +678,9 @@ class OpenSSLIOHook : public SSLIOHook
        {
                if (sess)
                {
-                       std::string text = "*** You are connected using SSL cipher '" + std::string(SSL_get_cipher(sess)) + "'";
+                       std::string text = "*** You are connected using SSL cipher '";
+                       GetCiphersuite(text);
+                       text += '\'';
                        const std::string& fingerprint = certificate->fingerprint;
                        if (!fingerprint.empty())
                                text += " and your SSL certificate fingerprint is " + fingerprint;
@@ -686,6 +688,11 @@ class OpenSSLIOHook : public SSLIOHook
                        user->WriteNotice(text);
                }
        }
+
+       void GetCiphersuite(std::string& out) const
+       {
+               out.append(SSL_get_cipher(sess));
+       }
 };
 
 static void StaticSSLInfoCallback(const SSL* ssl, int where, int rc)