[PATCH fix-default] mail: provide ui to wrapsocket in STARTTLS (issue4713)

Yuya Nishihara yuya at tcha.org
Sat Jun 6 19:14:21 CDT 2015


On Sat, 06 Jun 2015 14:04:10 -0700, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at fb.com>
> # Date 1433624401 25200
> #      Sat Jun 06 14:00:01 2015 -0700
> # Node ID 8d53041dc3acf990d6b6fc023384ee65c42775db
> # Parent  6fabde6ef4453ee6c2aa964184f6cf2c54483621
> mail: provide ui to wrapsocket in STARTTLS (issue4713)
> 
> Since 21b536f01eda we need to feed a ui object to wrapsocket. So we now provide
> a ui object to STARTTLS to be able to provide it.
> 
> diff --git a/mercurial/mail.py b/mercurial/mail.py
> --- a/mercurial/mail.py
> +++ b/mercurial/mail.py
> @@ -33,22 +33,23 @@ email.Header.Header.__dict__['__init__']
>  class STARTTLS(smtplib.SMTP):
>      '''Derived class to verify the peer certificate for STARTTLS.
>  
>      This class allows to pass any keyword arguments to SSL socket creation.
>      '''
> -    def __init__(self, sslkwargs, **kwargs):
> +    def __init__(self, ui, sslkwargs, **kwargs):
>          smtplib.SMTP.__init__(self, **kwargs)
>          self._sslkwargs = sslkwargs
> +        self.ui = ui
>  
>      def starttls(self, keyfile=None, certfile=None):
>          if not self.has_extn("starttls"):
>              msg = "STARTTLS extension not supported by server"
>              raise smtplib.SMTPException(msg)
>          (resp, reply) = self.docmd("STARTTLS")
>          if resp == 220:
>              self.sock = sslutil.wrapsocket(self.sock, keyfile, certfile,
> -                                           **self._sslkwargs)
> +                                           self.ui, **self._sslkwargs)

This will crash if --config smtp.verifycert=strict is set.
I'll send another workaround soon.


More information about the Mercurial-devel mailing list