From b96329dc3b775c77e98964c42cb0def7ca65ba0e Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Thu, 28 Apr 2016 17:04:33 +0200 Subject: Add SSLIOHook::IsSSL() to determine whether a socket is using SSL or not Use it in a few places --- include/modules/ssl.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/modules/ssl.h b/include/modules/ssl.h index 67bfc7b2e..adc78e324 100644 --- a/include/modules/ssl.h +++ b/include/modules/ssl.h @@ -164,6 +164,14 @@ class SSLIOHook : public IOHook } public: + static SSLIOHook* IsSSL(StreamSocket* sock) + { + IOHook* const iohook = sock->GetIOHook(); + if ((iohook) && ((iohook->prov->type == IOHookProvider::IOH_SSL))) + return static_cast(iohook); + return NULL; + } + SSLIOHook(IOHookProvider* hookprov) : IOHook(hookprov) { @@ -205,11 +213,10 @@ class SSLClientCert */ static ssl_cert* GetCertificate(StreamSocket* sock) { - IOHook* iohook = sock->GetIOHook(); - if ((!iohook) || (iohook->prov->type != IOHookProvider::IOH_SSL)) + SSLIOHook* ssliohook = SSLIOHook::IsSSL(sock); + if (!ssliohook) return NULL; - SSLIOHook* ssliohook = static_cast(iohook); return ssliohook->GetCertificate(); } -- cgit v1.2.3