git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [git-multimail] smtplib, check certificate

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Apr 22, 2016, 06:05 UTC
Message-ID
<vpqoa92rxew.fsf@anie.imag.fr>
In-Reply-To
<571949D2.10507@le-huit.fr>
Simon P <simon.git@le-huit.fr> writes:
> Hi,
Hi, and thanks for the patch.

Please, add your sign-off and a proper commit message to your patch, see:

https://github.com/git-multimail/git-multimail/blob/master/CONTRIBUTING.rst

I'm OK with patches by email, but you may prefer using a pull-request (among other things, creating a pull-request triggers a Travis-CI build and would have noticed the absence of sign-off and a minor PEP8 issue in your code.

The patch obviously lacks documentation, and some way to test it. Actually, the testsuite will fail if you document the configuration variable and they don't appear somewhere in the testsuite. A fully automatic test would be hard to write, but I have a semi-automated testsuite for smtp: some configurations in t/*.config.in, and a script test-email-config to run a test with each of the configurations (then I check my mailbox). There should be one configuration with a valid certificate and another with a buggy one so that we can check that the certificate is actually checked.

Show 5 quoted lines
> @@ -1945,6 +1946,7 @@ class SMTPMailer(Mailer):
>                   smtpservertimeout=10.0, smtpserverdebuglevel=0,
>                   smtpencryption='none',
>                   smtpuser='', smtppass='',
> +                 smtpcacerts='/etc/ssl/certs/ca-certificates.crt',smtpcheckcert=False

Do you need a default for smtpcheckcert if you already have one in config.get(smtpcheckcert)? In any case, I'd rather avoid having two hardcoded path in the code. If you need '/etc/ssl/certs/ca-certificates.crt' in two places, please define a constant elsewhere in the code and use it here.

Missing space after ,.
Show 9 quoted lines
> +                if smtpcheckcert:
> +                    # inspired form:
> +                    #   https://github.com/graingert/secure-smtplib/blob/master/src/secure_smtplib/__init__.py
> +                    # but add the path to trusted ca, and force ceritficate verification.
> +                    self.smtp.ehlo_or_helo_if_needed()
> +                    if not self.smtp.has_extn("starttls"):
> +                        msg = "STARTTLS extension not supported by server"
> +                        raise smtplib.SMTPException(msg)
> +                    (resp, reply) = self.smtp.docmd("STARTTLS")
Parenthesis around (resp, reply) are not needed, I prefer to omit them.
Thanks,
-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Simon PNext: Michael Haggerty
Message 2 of 5 in “[git-multimail] smtplib, check certificate”
  1. Simon PApr 21, 2016
  2. Matthieu MoyApr 22, 2016
  3. Michael HaggertyApr 22, 2016
  4. Simon PontiéApr 24, 2016
  5. Simon PontiéApr 24, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.