diff --git a/mercurial_keyring.py b/mercurial_keyring.py --- a/mercurial_keyring.py +++ b/mercurial_keyring.py @@ -620,7 +620,9 @@ def keyring_supported_smtp(ui, username) raise util.Abort(_('invalid smtp.verifycert configuration: %s') % (verifycert)) verifycert = False - if (starttls or smtps) and verifycert: + if getattr(sslutil, 'sslkwargs', None) is None: + sslkwargs = None + elif (starttls or smtps) and verifycert: sslkwargs = sslutil.sslkwargs(ui, mailhost) else: sslkwargs = {} @@ -628,12 +630,16 @@ def keyring_supported_smtp(ui, username) ui.note(_('(using smtps)\n')) # mercurial 3.8 added a mandatory host arg - if 'host' in SMTPS.__init__.__code__.co_varnames: + if not sslkwargs: + s = SMTPS(ui, local_hostname=local_hostname, host=mailhost) + elif 'host' in SMTPS.__init__.__code__.co_varnames: s = SMTPS(sslkwargs, local_hostname=local_hostname, host=mailhost) else: s = SMTPS(sslkwargs, local_hostname=local_hostname) elif starttls: - if 'host' in STARTTLS.__init__.__code__.co_varnames: + if not sslkwargs: + s = STARTTLS(ui, local_hostname=local_hostname, host=mailhost) + elif 'host' in STARTTLS.__init__.__code__.co_varnames: s = STARTTLS(sslkwargs, local_hostname=local_hostname, host=mailhost) else: s = STARTTLS(sslkwargs, local_hostname=local_hostname) @@ -654,7 +660,10 @@ def keyring_supported_smtp(ui, username) s.ehlo() if (starttls or smtps) and verifycert: ui.note(_('(verifying remote certificate)\n')) - sslutil.validator(ui, mailhost)(s.sock, verifycert == 'strict') + if getattr(sslutil, 'validatesocket', None): + sslutil.validatesocket(s.sock) + else: + validator(ui, mailhost)(s.sock, verifycert == 'strict') # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> stored = password = password_store.get_smtp_password(