From ec8ea4806287710a8e341868366cdd8e5a4d1177 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Obiltschnig?= Date: Thu, 16 May 2019 14:35:19 +0200 Subject: [PATCH] SecureSMTPClientSession now uses _host from SMTPClientSession --- Net/include/Poco/Net/SMTPClientSession.h | 7 +++++++ .../include/Poco/Net/SecureSMTPClientSession.h | 7 ++----- NetSSL_OpenSSL/src/SecureSMTPClientSession.cpp | 9 ++++----- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Net/include/Poco/Net/SMTPClientSession.h b/Net/include/Poco/Net/SMTPClientSession.h index 5ef45487b..8368024da 100644 --- a/Net/include/Poco/Net/SMTPClientSession.h +++ b/Net/include/Poco/Net/SMTPClientSession.h @@ -187,6 +187,7 @@ protected: void loginUsingXOAUTH2(const std::string& username, const std::string& password); void loginUsingNTLM(const std::string& username, const std::string& password); DialogSocket& socket(); + const std::string& host() const; private: void sendCommands(const MailMessage& message, const Recipients* pRecipients = 0); @@ -231,6 +232,12 @@ inline DialogSocket& SMTPClientSession::socket() } +inline const std::string& SMTPClientSession::host() const +{ + return _host; +} + + } } // namespace Poco::Net diff --git a/NetSSL_OpenSSL/include/Poco/Net/SecureSMTPClientSession.h b/NetSSL_OpenSSL/include/Poco/Net/SecureSMTPClientSession.h index 146be2aeb..06e6e6f0f 100644 --- a/NetSSL_OpenSSL/include/Poco/Net/SecureSMTPClientSession.h +++ b/NetSSL_OpenSSL/include/Poco/Net/SecureSMTPClientSession.h @@ -59,7 +59,7 @@ public: /// Destroys the SMTPClientSession. bool startTLS(); - /// Sends a STARTTLS command and, if successful, + /// Sends a STARTTLS command and, if successful, /// creates a secure SSL/TLS connection over the /// existing socket connection. /// @@ -71,7 +71,7 @@ public: /// false otherwise. bool startTLS(Context::Ptr pContext); - /// Sends a STARTTLS command and, if successful, + /// Sends a STARTTLS command and, if successful, /// creates a secure SSL/TLS connection over the /// existing socket connection. /// @@ -84,9 +84,6 @@ public: /// /// Returns true if the STARTTLS command was successful, /// false otherwise. - -private: - std::string _host; }; diff --git a/NetSSL_OpenSSL/src/SecureSMTPClientSession.cpp b/NetSSL_OpenSSL/src/SecureSMTPClientSession.cpp index c1a9569bc..74ec2e4d0 100644 --- a/NetSSL_OpenSSL/src/SecureSMTPClientSession.cpp +++ b/NetSSL_OpenSSL/src/SecureSMTPClientSession.cpp @@ -29,8 +29,7 @@ SecureSMTPClientSession::SecureSMTPClientSession(const StreamSocket& socket): SecureSMTPClientSession::SecureSMTPClientSession(const std::string& host, Poco::UInt16 port): - SMTPClientSession(host, port), - _host(host) + SMTPClientSession(host, port) { } @@ -50,13 +49,13 @@ bool SecureSMTPClientSession::startTLS(Context::Ptr pContext) { int status = 0; std::string response; - + status = sendCommand("STARTTLS", response); if (!isPositiveCompletion(status)) return false; - SecureStreamSocket sss(SecureStreamSocket::attach(socket(), _host, pContext)); + SecureStreamSocket sss(SecureStreamSocket::attach(socket(), host(), pContext)); socket() = sss; - + return true; }