"""
GLAMWalk -- Volume 2: The Gauntlet
02_ssl_diagnostic.py

Diagnosing an SSL/transport-layer failure and forcing requests to use a fresh, explicit certificate bundle via certifi.

Source: Volume Two, Section 1.2 -- Front One: The SSL Wall
Targets Python 3.11.4 -- see Volume One, Chapter 1.5/1.6.

NOTE: This script makes real network requests to a live public API.
It's safe to run as-is, but requires an internet connection.
"""

import requests

response = requests.get("https://collections.artsmia.org/api/some-endpoint")


import ssl
import certifi

# Confirm which certificate bundle Python is actually trusting —
# a stale bundle is one of the most common real causes.
print(certifi.where())

# Force requests to use certifi's bundle explicitly, rather than
# whatever the OS happens to have configured:
import requests
response = requests.get(
    "https://collections.artsmia.org/api/some-endpoint",
    verify=certifi.where(),
    timeout=15,
)
