`ssl`: changing the default `SSLContext.verify_flags`?

In order to do this, I think we’d effectively need to run every X.509 path validation twice: once with the flag, and once without. That’s probably possible since CPython controls all of the inputs here, but I have no idea whether it’s advisable or not :slightly_smiling_face: – it’d be a bit of a performance hit and we’d need to be careful about ownership/not misusing OpenSSL’s APIs across two verification contexts.

Those users could explicitly configure a weaker set of SSLContext.verify_flags, e.g.:

>>> ctx.verify_flags 
<VerifyFlags.VERIFY_X509_TRUSTED_FIRST|VERIFY_X509_PARTIAL_CHAIN: 557056>
>>> ctx.verify_flags -= ssl.VERIFY_X509_PARTIAL_CHAIN
>>> ctx.verify_flags 
<VerifyFlags.VERIFY_X509_TRUSTED_FIRST: 32768>

If by “crypto policy” you mean something more global than that (e.g. an environment variable that sets the verify_flags), then I don’t believe that currently exists (but I might be wrong!)

IMO adding that kind of global switch here might cause more problems than it solves: even users who need weaker X.509 verification settings probably don’t need them on a per-interpreter basis, but probably only need them for a specific handful of uses of ssl. Giving them a big flag that makes the error go away might result in a lot of people opting into a worse overall security posture for just a single use of ssl that actually needs it :slightly_smiling_face: