Sorry I was on my phone and didn’t get to fully reply to this.

On Aug 29, 2014, at 4:00 PM, M.-A. Lemburg <mal@egenix.com> wrote:

On 29.08.2014 21:47, Alex Gaynor wrote:
Hi all,

I've just submitted PEP 476, on enabling certificate validation by default for
HTTPS clients in Python. Please have a look and let me know what you think.

PEP text follows.

Thanks for the PEP. I think this is generally a good idea,
but some important parts are missing from the PEP:

* transition plan:

  I think starting with warnings in Python 3.5 and going
  for exceptions in 3.6 would make a good transition

  Going straight for exceptions in 3.5 is not in line with
  our normal procedures for backwards incompatible changes.

As far as a transition plan, I think that this is an important
enough thing to have an accelerated process. If we need
to provide a warning than let’s add it to the next 3.4 otherwise
it’s going to be 2.5+ years until we stop being unsafe by
default.

Another problem with this is that I don’t think it’s actually
possible to do. Python itself isn’t validating the TLS certificates,
OpenSSL is doing that. To my knowledge OpenSSL doesn’t
have a way to say “please validate these certificates and if
they don’t validate go ahead and keep going and just let me
get a warning from it”. It’s a 3 way switch, no validation, validation
if a certificate is provided, and validation always.

Now that’s strictly for the “verify the certificate chain” portion,
the hostname verification is done entirely on our end and we
could do something there… but I’m not sure it makes sense
to do so if we can’t do it for invalid certificates too.


* configuration:

  It would be good to be able to switch this on or off
  without having to change the code, e.g. via a command
  line switch and environment variable; perhaps even
  controlling whether or not to raise an exception or
  warning.

I’m on the fence about this, if someone provides a certificate
that we can validate against (which can be done without
touching the code) then the only thing that really can’t be
“fixed” without touching the code is if someone has a certificate
that is otherwise invalid (expired, not yet valid, wrong hostname,
etc). I’d say if I was voting on this particular thing I’d be -0, I’d
rather it didn’t exist but I wouldn’t cry too much if it did.


* choice of trusted certificate:

  Instead of hard wiring using the system CA roots into
  Python it would be good to just make this default and
  permit the user to point Python to a different set of
  CA roots.

  This would enable using self signed certs more easily.
  Since these are often used for tests, demos and education,
  I think it's important to allow having more control of
  the trusted certs.

Like my other email said, the Python API has everything needed
to easily specify your own CA roots and/or disable the validations.
The OpenSSL library also allows you to specify either a directory
or a file to change the root certificates without code changes. The
only real problems with the APIs are that the default is bad and
an unrelated thing where you can’t pass in an in memory certificate.

---
Donald Stufft
PGP: 7C6B 7C5D 5E2B 6356 A926 F04F 6E3C BCE9 3372 DCFA