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

Add httpx.SSLContext configuration. #3022

Merged
merged 43 commits into from
Oct 8, 2024

Conversation

karpetrosyan
Copy link
Member

@karpetrosyan karpetrosyan commented Dec 25, 2023

Discussed in #3007

TODO:

  • Add changelog
  • Add more migration examples

Migration examples

Enabling and disabling verification

import httpx

# instead of 
httpx.Client(verify=False)

# do
context = httpx.SSLContext(verify=False)
httpx.Client(ssl_context=context)

Use a different set of certificates

import httpx

# instead of
httpx.Client(verify="path/to/certs.pem")

# do
context = httpx.SSLContext(verify="path/to/certs.pem")
httpx.Client(ssl_context=context)

Client side certificates

import httpx

# instead of
httpx.Client(cert="path/to/client.pem")

# do
context = httpx.SSLContext(cert="path/to/client.pem")
httpx.Client(ssl_context=context)

Using alternate SSL contexts

import ssl
import httpx

context = ssl.create_default_context()

# instead of
client = httpx.Client(verify=context)

# do
client = httpx.Client(ssl_context=context)

@karpetrosyan karpetrosyan added the api change PRs that contain breaking public API changes label Dec 25, 2023
@T-256

This comment was marked as resolved.

@karpetrosyan
Copy link
Member Author

Yes, I agree that removing them completely is not what the user expects.
However, I believe migration is simple enough to skip that stage in order to avoid making that part of the code overly complicated.

Or should we deprecate them anyway? Not obvious to me.

@T-256

This comment was marked as resolved.

httpx/_config.py Outdated Show resolved Hide resolved
httpx/_client.py Outdated Show resolved Hide resolved
@tomchristie
Copy link
Member

Looking good.

Update documentation

I'd suggest you don't spin time on that until we've had a clear discussion around the "API finessing" and "Documentation refresh" areas mentioned in #947 (comment). I like this change, but we'll want to make it as part of a coherent & consistent 1.0 refresh.

@tomchristie tomchristie mentioned this pull request Jan 8, 2024
@tomchristie tomchristie added the 1.0 proposal Pull requests proposing 1.0 API changes label Jan 11, 2024
@tomchristie tomchristie changed the title Replace the verify and cert arguments with ssl_context. Add httpx.SSLContext configuration. Jan 12, 2024
@tomchristie
Copy link
Member

Okay, shall we take the docs from this comment... #3007 (comment) and include them in the PR?

@karpetrosyan
Copy link
Member Author

Okay, shall we take the docs from this comment... #3007 (comment) and include them in the PR?

I like it

@karpetrosyan
Copy link
Member Author

Have we decided to remove or deprecate the old arguments?

httpx/_api.py Outdated Show resolved Hide resolved
httpx/_api.py Outdated Show resolved Hide resolved
httpx/_api.py Outdated Show resolved Hide resolved
httpx/_api.py Outdated Show resolved Hide resolved
httpx/_api.py Outdated Show resolved Hide resolved
httpx/_api.py Outdated Show resolved Hide resolved
httpx/_api.py Outdated Show resolved Hide resolved
httpx/_api.py Outdated Show resolved Hide resolved
httpx/_client.py Outdated Show resolved Hide resolved
httpx/_client.py Outdated Show resolved Hide resolved
tests/test_config.py Outdated Show resolved Hide resolved
httpx/_config.py Outdated Show resolved Hide resolved
httpx/_config.py Outdated Show resolved Hide resolved
httpx/_config.py Outdated Show resolved Hide resolved
tests/test_config.py Outdated Show resolved Hide resolved
Dropping `trust_env` from `httpx.SSLContext()` API.
tests/test_config.py Outdated Show resolved Hide resolved
@tomchristie
Copy link
Member

tomchristie commented Oct 8, 2024

Thanks so much @karpetrosyan - going to merge this into "version-1.0" now, and then apply remaining changes incrementally. Fantastic work!! 😎

@tomchristie tomchristie merged commit 2763690 into encode:version-1.0 Oct 8, 2024
5 checks passed
@karpetrosyan
Copy link
Member Author

karpetrosyan commented Oct 8, 2024

Sorry, I couldn't find time to finish all the tidy-ups.
Thank you for the help! 🙏 @T-256 @tomchristie

@tomchristie
Copy link
Member

Thank you so much for your time & dedication @karpetrosyan. 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.0 proposal Pull requests proposing 1.0 API changes api change PRs that contain breaking public API changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants