From 271b9c1e995e3a1e7f4d701f1912c3be528f8e89 Mon Sep 17 00:00:00 2001 From: hai Date: Thu, 18 Feb 2021 18:58:45 +0700 Subject: [PATCH] Ensure checking SSL Certificate in IMAP StartTLS. (cherry picked from commit fad23d736ed5a63cf8321469d3a98a583f55df97) --- src/core/imap/MCIMAPSession.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/core/imap/MCIMAPSession.cpp b/src/core/imap/MCIMAPSession.cpp index 56e918374..59b44d044 100644 --- a/src/core/imap/MCIMAPSession.cpp +++ b/src/core/imap/MCIMAPSession.cpp @@ -685,6 +685,12 @@ void IMAPSession::connect(ErrorCode * pError) * pError = ErrorTLSNotAvailable; goto close; } + if (!checkCertificate()) { + MCLog("StartTLS ssl connect certificate ERROR %d", r); + * pError = ErrorCertificate; + goto close; + } + break; case ConnectionTypeTLS: @@ -701,14 +707,14 @@ void IMAPSession::connect(ErrorCode * pError) setMailStreamSSLContextServerName, const_cast(static_cast(MCUTF8(mHostname)))); #endif - MCLog("ssl connect %s %u %u", MCUTF8(mHostname), mPort, r); + MCLog("TLS ssl connect %s %u %u", MCUTF8(mHostname), mPort, r); if (hasError(r)) { MCLog("connect error %i", r); * pError = ErrorConnection; goto close; } if (!checkCertificate()) { - MCLog("ssl connect certificate ERROR %d", r); + MCLog("TLS ssl connect certificate ERROR %d", r); * pError = ErrorCertificate; goto close; }