-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
fix ssl verify and update tests #16149
Conversation
CodSpeed Performance ReportMerging #16149 will not alter performanceComparing Summary
|
According to lundberg/respx#277 |
78ecfe6
to
0a6c723
Compare
uv pip install --upgrade -r requirements-markdown-tests.txt | ||
uv pip install --upgrade -e '.[dev]' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
swapped the order here
if PREFECT_API_TLS_INSECURE_SKIP_VERIFY: | ||
httpx_settings.setdefault("verify", False) | ||
# Create an unverified context for insecure connections | ||
ctx = ssl.create_default_context() | ||
ctx.check_hostname = False | ||
ctx.verify_mode = ssl.CERT_NONE | ||
httpx_settings.setdefault("verify", ctx) | ||
else: | ||
cert_file = PREFECT_API_SSL_CERT_FILE.value() | ||
if not cert_file: | ||
cert_file = certifi.where() | ||
httpx_settings.setdefault("verify", cert_file) | ||
# Create a verified context with the certificate file | ||
ctx = ssl.create_default_context(cafile=cert_file) | ||
httpx_settings.setdefault("verify", ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are repeating a few things in both branches that could be simplified out:
ctx = ssl.create_default_context()
if PREFECT_API_TLS_INSECURE_SKIP_VERIFY:
# Update the context to not verify for insecure connections
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
else:
cert_file = PREFECT_API_SSL_CERT_FILE.value()
if not cert_file:
cert_file = certifi.where()
# Update the context with the certificate file
ctx.load_verify_locations(cafile=cert_file)
httpx_settings.setdefault("verify", ctx)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @mjpieters! you are correct, thanks for pointing this out! in this draft PR i was exploring what fixes would be necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, of course, sorry if I jumped the gun a bit here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mjpieters no worries! if you're interested in following along, we're working through the same upstream issue's impact on our tests here
if PREFECT_API_TLS_INSECURE_SKIP_VERIFY: | ||
httpx_settings.setdefault("verify", False) | ||
# Create an unverified context for insecure connections | ||
ctx = ssl.create_default_context() | ||
ctx.check_hostname = False | ||
ctx.verify_mode = ssl.CERT_NONE | ||
httpx_settings.setdefault("verify", ctx) | ||
else: | ||
cert_file = PREFECT_API_SSL_CERT_FILE.value() | ||
if not cert_file: | ||
cert_file = certifi.where() | ||
httpx_settings.setdefault("verify", cert_file) | ||
# Create a verified context with the certificate file | ||
ctx = ssl.create_default_context(cafile=cert_file) | ||
httpx_settings.setdefault("verify", ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto here.
ea03de4
to
64618b6
Compare
@desertaxle related to sync discussion, I've opened #16179 |
closes #16148
respx
with the fix until the main version is releasedprefect
instead overwriting itrelatedly, #16168 fixes httpx issues with tests and an issue with the worker's cloud client context when adding flow run labels