twine icon indicating copy to clipboard operation
twine copied to clipboard

cli: use truststore if available

Open James-E-A opened this issue 1 year ago • 1 comments

The lack of this has been a perennial thorn for people behind corporate TLS MITM ALG proxies; when it's soluble, it's still annoying, and sometimes the proxy applications don't use a stable root bundle, rendering the situation kinda insoluble.

Pip added truststore support back in version 22.2, but Twine still seems to require users to rustle up CA bundles themselves, which can be difficult and is actually infeasible with certain proxy software (e.g. ZScaler) that rotates the roots regularly and distributes new bundles into the system trust stores via a system-level mechanism like Active Directory.

The current draft of the code only applies truststore during CLI dispatch, to avoid interfering with Twine's use as a library, per truststore documentation:

inject_into_ssl() must not be used by libraries or packages as it will cause issues on import time when integrated with other libraries. Libraries and packages should instead use truststore.SSLContext directly which is detailed below. The inject_into_ssl() function is intended only for use in applications and scripts.

James-E-A avatar Feb 01 '24 23:02 James-E-A

Do you have any intention of making this ready for review at any point?

sigmavirus24 avatar May 15 '24 21:05 sigmavirus24