##// END OF EJS Templates
mail: retain hostname for sslutil.wrapsocket (issue5203)...
timeless -
r28935:a4c5c23d default
parent child Browse files
Show More
@@ -48,9 +48,10 b' class STARTTLS(smtplib.SMTP):'
48 48
49 49 This class allows to pass any keyword arguments to SSL socket creation.
50 50 '''
51 def __init__(self, sslkwargs, **kwargs):
51 def __init__(self, sslkwargs, host=None, **kwargs):
52 52 smtplib.SMTP.__init__(self, **kwargs)
53 53 self._sslkwargs = sslkwargs
54 self._host = host
54 55
55 56 def starttls(self, keyfile=None, certfile=None):
56 57 if not self.has_extn("starttls"):
@@ -59,6 +60,7 b' class STARTTLS(smtplib.SMTP):'
59 60 (resp, reply) = self.docmd("STARTTLS")
60 61 if resp == 220:
61 62 self.sock = sslutil.wrapsocket(self.sock, keyfile, certfile,
63 serverhostname=self._host,
62 64 **self._sslkwargs)
63 65 self.file = smtplib.SSLFakeFile(self.sock)
64 66 self.helo_resp = None
@@ -72,10 +74,12 b' class SMTPS(smtplib.SMTP):'
72 74
73 75 This class allows to pass any keyword arguments to SSL socket creation.
74 76 '''
75 def __init__(self, sslkwargs, keyfile=None, certfile=None, **kwargs):
77 def __init__(self, sslkwargs, keyfile=None, certfile=None, host=None,
78 **kwargs):
76 79 self.keyfile = keyfile
77 80 self.certfile = certfile
78 81 smtplib.SMTP.__init__(self, **kwargs)
82 self._host = host
79 83 self.default_port = smtplib.SMTP_SSL_PORT
80 84 self._sslkwargs = sslkwargs
81 85
@@ -85,6 +89,7 b' class SMTPS(smtplib.SMTP):'
85 89 new_socket = socket.create_connection((host, port), timeout)
86 90 new_socket = sslutil.wrapsocket(new_socket,
87 91 self.keyfile, self.certfile,
92 serverhostname=self._host,
88 93 **self._sslkwargs)
89 94 self.file = smtplib.SSLFakeFile(new_socket)
90 95 return new_socket
@@ -114,9 +119,9 b' def _smtp(ui):'
114 119 sslkwargs = {'ui': ui}
115 120 if smtps:
116 121 ui.note(_('(using smtps)\n'))
117 s = SMTPS(sslkwargs, local_hostname=local_hostname)
122 s = SMTPS(sslkwargs, local_hostname=local_hostname, host=mailhost)
118 123 elif starttls:
119 s = STARTTLS(sslkwargs, local_hostname=local_hostname)
124 s = STARTTLS(sslkwargs, local_hostname=local_hostname, host=mailhost)
120 125 else:
121 126 s = smtplib.SMTP(local_hostname=local_hostname)
122 127 if smtps:
General Comments 0
You need to be logged in to leave comments. Login now