Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TLSAdapter bugfixes #96

Merged
merged 3 commits into from
Apr 20, 2024
Merged

TLSAdapter bugfixes #96

merged 3 commits into from
Apr 20, 2024

Conversation

mildsunrise
Copy link
Contributor

when the --allow-insecure-ciphers option is used, we register our own HTTPAdapter which overrides the ssl_context used by connections.

we need to do this in order to control the options and ciphers, but this bypasses the urllib3's create_urllib3_context logic, which leads to some features not working when --allow-insecure-ciphers is in place.

this PR replicates some of that logic to fix it; see each commit for explanation and references.

Python [1] and urllib3 [2] honor this environment variable by default,
but because we're setting our own ssl_context, we don't get that
behavior out of the box.

SSLKEYLOGFILE support is very handy for debugging
authentication problems through a network capture.

[1]: https://github.com/python/cpython/blob/c053d52edd1e05ccc339e380b705749a3240d645/Lib/ssl.py#L725-L728
[2]: https://github.com/urllib3/urllib3/blob/b7c2910a9f49ba0d58c8d4381500c208f9a24765/src/urllib3/util/ssl_.py#L344-L349
the --no-verify flag has been broken since Python 3.4
when it is used together with --allow-insecure-ciphers.

this is because setting cert_mode to NONE now requires
previously setting check_hostname to False [1].

again, urllib3 normally takes care of this [2], but because
we set our own ssl_context, we need to replicate this logic.

[1]: python/cpython@1aa9a75#diff-89879be484d86da4e77c90d5408b2e10190ee27cc86337cd0f8efc3520d60621R2237-R2242
[2]: https://github.com/urllib3/urllib3/blob/b7c2910a9f49ba0d58c8d4381500c208f9a24765/src/urllib3/util/ssl_.py#L327-L337
@dlenski
Copy link
Owner

dlenski commented Apr 17, 2024

Thank you @mildsunrise, this is great. I believe a78357e will also fix #83.

For a (partial) explanation of why getting all of the TLS tweaks right in gp-saml-gui is hard, see #55 (comment). Basically, we have to both adjust TLS in the webview and adjust it in the OpenConnect params 😵

gp_saml_gui.py Outdated Show resolved Hide resolved
gp_saml_gui.py Show resolved Hide resolved
@mildsunrise
Copy link
Contributor Author

yeah, it's frustrating that we can't make webkitgtk use python's TLS stack...

@dlenski dlenski merged commit 71bf81d into dlenski:master Apr 20, 2024
6 checks passed
@mildsunrise mildsunrise deleted the fix-tlsadapter branch April 30, 2024 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants