52 lines
1.5 KiB
Python
52 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
# /// script
|
|
# requires-python = ">=3.10"
|
|
# dependencies = ["requests", "cryptography"]
|
|
# ///
|
|
"""Quick CRL parse debug test."""
|
|
import requests, traceback
|
|
from cryptography import x509
|
|
|
|
urls = [
|
|
"http://pki.imy.se/IMY-RootCA01/CRL/IMY-RootCA01.crl",
|
|
"http://pki.imy.se/IMY-IssuingCA02/CRL/IMY-IssuingCA02.crl",
|
|
"http://pki.imy.se/CDP/IMYRootCa01.crl",
|
|
"http://pki.imy.se/CDP/IMY%20Sub%20CA+.crl",
|
|
]
|
|
|
|
session = requests.Session()
|
|
session.verify = False
|
|
session.headers.update({
|
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)',
|
|
'Accept-Encoding': 'identity',
|
|
})
|
|
requests.packages.urllib3.disable_warnings()
|
|
|
|
for url in urls:
|
|
print(f"\n{'='*70}")
|
|
print(f"URL: {url}")
|
|
try:
|
|
resp = session.get(url, timeout=30)
|
|
data = resp.content
|
|
print(f"Size: {len(data)} bytes | Status: {resp.status_code}")
|
|
print(f"Content-Type: {resp.headers.get('content-type')}")
|
|
print(f"First 20 bytes hex: {data[:20].hex(' ')}")
|
|
except Exception as e:
|
|
print(f"Download failed: {e}")
|
|
continue
|
|
|
|
print(f"\nTrying DER parse...")
|
|
try:
|
|
crl = x509.load_der_x509_crl(data)
|
|
print(f" ✔ SUCCESS! Issuer: {crl.issuer}")
|
|
except Exception as e:
|
|
print(f" ✘ FAILED:")
|
|
traceback.print_exc()
|
|
|
|
print(f"\nTrying PEM parse...")
|
|
try:
|
|
crl = x509.load_pem_x509_crl(data)
|
|
print(f" ✔ SUCCESS! Issuer: {crl.issuer}")
|
|
except Exception as e:
|
|
print(f" ✘ FAILED:")
|
|
traceback.print_exc() |