From b8ba37b4f4687a4bdd6160095ee10abecca7e841 Mon Sep 17 00:00:00 2001 From: XinyuHou Date: Wed, 1 Apr 2015 16:32:04 +0100 Subject: [PATCH] Made callback function global #4522 --- src/lib/plugin/ns/SecureSocket.cpp | 14 +++++++++----- src/lib/plugin/ns/SecureSocket.h | 8 +------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/lib/plugin/ns/SecureSocket.cpp b/src/lib/plugin/ns/SecureSocket.cpp index facf8337..bf4d4c3b 100644 --- a/src/lib/plugin/ns/SecureSocket.cpp +++ b/src/lib/plugin/ns/SecureSocket.cpp @@ -23,6 +23,7 @@ #include "arch/XArch.h" #include "base/Log.h" +#include #include #include #include @@ -30,6 +31,9 @@ #include #include #include +#include + +int verifyCertFingerprint(X509_STORE_CTX* ctx, void* arg); // // SecureSocket @@ -207,7 +211,7 @@ SecureSocket::initContext(bool server) if (!server) { //void* p = reinterpret_cast(const_cast(m_certFingerprint.c_str())); - SSL_CTX_set_cert_verify_callback(m_ssl->m_context, CSecureSocket::verifyCertFingerprint, (void*)test); + SSL_CTX_set_cert_verify_callback(m_ssl->m_context, verifyCertFingerprint, (void*)test); } } @@ -437,7 +441,7 @@ SecureSocket::serviceAccept(ISocketMultiplexerJob* job, } int -CSecureSocket::verifyCertFingerprint(X509_STORE_CTX* ctx, void* arg) +verifyCertFingerprint(X509_STORE_CTX* ctx, void* arg) { X509 *cert = ctx->cert; @@ -446,13 +450,13 @@ CSecureSocket::verifyCertFingerprint(X509_STORE_CTX* ctx, void* arg) unsigned int tempFingerprintLen; tempDigest = (EVP_MD*)EVP_sha1(); if (X509_digest(cert, tempDigest, tempFingerprint, &tempFingerprintLen) <= 0) { - s_verifyFingerprintFailed = true; + CSecureSocket::s_verifyFingerprintFailed = true; return 0; } std::stringstream ss; ss << std::hex; - for (int i = 0; i < tempFingerprintLen; i++) { + for (unsigned int i = 0; i < tempFingerprintLen; i++) { ss << std::setw(2) << std::setfill('0') << (int)tempFingerprint[i]; } CString fingerprint = ss.str(); @@ -483,6 +487,6 @@ CSecureSocket::verifyCertFingerprint(X509_STORE_CTX* ctx, void* arg) file.close(); - s_verifyFingerprintFailed = true; + CSecureSocket::s_verifyFingerprintFailed = true; return 0; } diff --git a/src/lib/plugin/ns/SecureSocket.h b/src/lib/plugin/ns/SecureSocket.h index d184814c..507566e8 100644 --- a/src/lib/plugin/ns/SecureSocket.h +++ b/src/lib/plugin/ns/SecureSocket.h @@ -20,8 +20,6 @@ #include "net/TCPSocket.h" #include "net/XSocket.h" -#include - class IEventQueue; class SocketMultiplexer; class ISocketMultiplexerJob; @@ -73,15 +71,11 @@ private: serviceAccept(ISocketMultiplexerJob*, bool, bool, bool); -private: -static int verifyCertFingerprint(X509_STORE_CTX* ctx, void* arg); - - private: Ssl* m_ssl; bool m_secureReady; CString m_certFingerprint; -private: +public: static bool s_verifyFingerprintFailed; };