Verify TLS against the OS trust store in the remaining notebooks - #21
Open
frozer wants to merge 3 commits into
Open
Verify TLS against the OS trust store in the remaining notebooks#21frozer wants to merge 3 commits into
frozer wants to merge 3 commits into
Conversation
Verify TLS against the OS trust store
8548dd2 wired truststore into Developer_Platform.ipynb and added it to requirements.txt. Do the same for the other four exercises, so a corporate TLS-inspecting proxy (Zscaler et al.) doesn't break them either. Each setup cell now calls truststore.inject_into_ssl() before the Anthropic client is constructed, wrapped in a try/except that falls back to certifi with an explanatory message on Python < 3.10 or when the install was blocked. Saving through Jupyter also normalised these four files to canonical nbformat key order and split single-string `source` fields into line lists. That is the bulk of the diff; no cell content changed apart from the TLS block. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Two gaps left open by the previous commit.
The four notebooks imported truststore but never installed it: only
Developer_Platform.ipynb listed it in _ensure_packages. Anyone running them
in Colab or a fresh kernel without `pip install -r requirements.txt` landed
on the certifi fallback — exactly the corporate-proxy case the shim exists
to fix. Add ("truststore", "truststore") to each bootstrap list, keeping the
same position after anthropic that Developer_Platform.ipynb uses.
The fallback message tells readers to see SETUP.md, which said nothing about
certificates. Add a CERTIFICATE_VERIFY_FAILED section covering why TLS
inspection breaks certifi, how to read the "[!!] truststore unavailable"
diagnostic, and — since it is the first thing people reach for — why not to
disable verification, with SSL_CERT_FILE against an IT-supplied root CA as
the supported alternative.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Commit 8548dd2 wired
truststoreintoday1/02_developer-platform/Developer_Platform.ipynband added it torequirements.txt. This PR extends the same fix to the remaining four exercise notebooks:day1/03_prompt-rescue/Prompt_Rescue_solo.ipynbday1/04_diagnosing-ai-problems/Diagnose_Fix_Brief.ipynbday2/01_evals/Building_an_Eval.ipynbday2/02_inference-optimization/Inference_Optimization.ipynbWhy
anthropic/httpxverify TLS against thecertifibundle, which does not contain a corporate root CA. Behind a TLS-inspecting proxy (Zscaler and friends) every notebook fails on the first API call withCERTIFICATE_VERIFY_FAILED.truststore.inject_into_ssl()switches verification to the OS certificate store, where the corporate root is already trusted by IT.How
Each setup cell now opens with, before the Anthropic client is constructed:
The
try/exceptkeeps the notebooks working unchanged for anyone not behind a proxy, and on Python < 3.10 wheretruststoreis unavailable.Diff noise
Saving through Jupyter normalised these four files to canonical
nbformatkey order (cells/metadata/nbformatlast) and split single-stringsourcefields into line lists. That accounts for most of the +235/-153. No cell content changed apart from the TLS block. All five notebooks still parse as valid JSON.Also in this PR
truststoreis now installed by the notebooks themselves. All four_ensure_packages([...])calls gained("truststore", "truststore"), in the sameposition after
anthropicthatDeveloper_Platform.ipynbuses. Without this, a Colabor fresh-kernel run never installed the shim and fell straight through to the certifi
path — the exact scenario this PR targets.
SETUP.mdgained aCERTIFICATE_VERIFY_FAILEDsection, which the fallback messagepoints at. It explains why TLS inspection defeats certifi, how to read the
[!!] truststore unavailablediagnostic (ModuleNotFoundError= wrong kernel/notinstalled; anything else = Python < 3.10), and why
verify=False/PYTHONHTTPSVERIFY=0is the wrong reflex, with
SSL_CERT_FILEagainst an IT-supplied root CA as thesupported alternative.
Testing
json.loadafter each edit.TLS-inspecting proxy.