diff --git a/src/lib/net/SecureSocket.cpp b/src/lib/net/SecureSocket.cpp index 855e16bb..5ae443bf 100644 --- a/src/lib/net/SecureSocket.cpp +++ b/src/lib/net/SecureSocket.cpp @@ -329,7 +329,7 @@ SecureSocket::initSsl(bool server) initContext(server); } -bool SecureSocket::loadCertificates(std::string& filename) +bool SecureSocket::loadCertificates(const std::string& filename) { if (filename.empty()) { showError("ssl certificate is not specified"); @@ -341,9 +341,7 @@ bool SecureSocket::loadCertificates(std::string& filename) file.close(); if (!exist) { - std::string errorMsg("ssl certificate doesn't exist: "); - errorMsg.append(filename); - showError(errorMsg.c_str()); + showError("ssl certificate doesn't exist: " + filename); return false; } } @@ -403,7 +401,7 @@ SecureSocket::initContext(bool server) SSL_CTX_set_options(m_ssl->m_context, SSL_OP_NO_SSLv3); if (m_ssl->m_context == NULL) { - showError(); + showError(""); } } @@ -618,16 +616,15 @@ SecureSocket::checkResult(int status, int& retry) if (isFatal()) { retry = 0; - showError(); + showError(""); disconnect(); } } -void -SecureSocket::showError(const char* reason) +void SecureSocket::showError(const std::string& reason) { - if (reason != NULL) { - LOG((CLOG_ERR "%s", reason)); + if (!reason.empty()) { + LOG((CLOG_ERR "%s", reason.c_str())); } std::string error = getError(); diff --git a/src/lib/net/SecureSocket.h b/src/lib/net/SecureSocket.h index c602e2da..4be5ac3c 100644 --- a/src/lib/net/SecureSocket.h +++ b/src/lib/net/SecureSocket.h @@ -55,7 +55,7 @@ public: EJobResult doRead() override; EJobResult doWrite() override; void initSsl(bool server); - bool loadCertificates(std::string& CertFile); + bool loadCertificates(const std::string& filename); private: // SSL @@ -65,7 +65,7 @@ private: int secureConnect(int s); bool showCertificate(); void checkResult(int n, int& retry); - void showError(const char* reason = NULL); + void showError(const std::string& reason); std::string getError(); void disconnect(); void formatFingerprint(std::string& fingerprint, bool hex = true, bool separator = true);