From 59bb601cfeb0e9d7368ff4f592ae940c7eda78b0 Mon Sep 17 00:00:00 2001 From: Bosie Ionut <33691449+BosieIonut@users.noreply.github.com> Date: Thu, 17 Oct 2024 23:35:22 +0300 Subject: [PATCH] Solved a little bug hopefully When you are trying to connect to a domain with the dot at the end the smtp connection works just fine but starttls() will raise an handshake execption. --- Lib/smtplib.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Lib/smtplib.py b/Lib/smtplib.py index b3cc68a789a7d8..fdd5412adc7a44 100755 --- a/Lib/smtplib.py +++ b/Lib/smtplib.py @@ -776,8 +776,13 @@ def starttls(self, *, context=None): raise RuntimeError("No SSL support included in this Python") if context is None: context = ssl._create_stdlib_context() + if self._host[-1] is ".": + context_host = self._host[:-1] + else: + context_host = self._host self.sock = context.wrap_socket(self.sock, - server_hostname=self._host) + server_hostname=context_host) + self.file = None # RFC 3207: # The client MUST discard any knowledge obtained from