[PATCH STABLE 🚑] mail: actually use the verifycert config value

Pierre-Yves David pierre-yves.david at ens-lyon.org
Wed Nov 5 19:11:40 CST 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1415212299 0
#      Wed Nov 05 18:31:39 2014 +0000
# Node ID 3a44dbed6cb41b9573b4d74dd4cd9998a8f6a1c2
# Parent  1743ad376a1aae9981a8fdd57f3690e8a8c0d819
mail: actually use the verifycert config value

The mail module only verify the smtp ssl certificate if 'verifycert' is enabled
(the default). The 'verifycert' can take three possible values:

- 'strict' (means enabled)
- 'loose' (means disabled)
- any "False" value, eg: 'false' or '0' (means disabled)

The code was checked one of this three value was used. But never translated them
to actual boolean value. As "loose" is evaluated as 'True', the 'verifycert'
feature was never disabled.

diff --git a/mercurial/mail.py b/mercurial/mail.py
--- a/mercurial/mail.py
+++ b/mercurial/mail.py
@@ -98,14 +98,19 @@ def _smtp(ui):
         raise util.Abort(_("can't use TLS: Python SSL support not installed"))
     mailhost = ui.config('smtp', 'host')
     if not mailhost:
         raise util.Abort(_('smtp.host not configured - cannot send mail'))
     verifycert = ui.config('smtp', 'verifycert', 'strict')
-    if verifycert not in ['strict', 'loose']:
+    if verifycert == 'strict':
+        verifycert = True
+    elif verifycert == 'loose':
+        verifycert = False
+    else:
         if util.parsebool(verifycert) is not False:
             raise util.Abort(_('invalid smtp.verifycert configuration: %s')
                              % (verifycert))
+        verifycert = False
     if (starttls or smtps) and verifycert:
         sslkwargs = sslutil.sslkwargs(ui, mailhost)
     else:
         sslkwargs = {}
     if smtps:


More information about the Mercurial-devel mailing list