Skip to main content

Relax python default SSL Context verification flags

Project description

SSL Context Relaxer

Relax the SSL verification strictness introduced in python 3.13

Monkey-patching structure inspired by truststore

Usage

Install the library

pip install context-relaxer

At the entry point of your project, inject the monkey-patch

import context_relaxer

context_relaxer.inject_into_ssl()

Rationale

Many corporates have systems that proxy internal traffic, and sometimes they produce broken certificates.

Yes, they should be fixed, No, probably won't be fixed soon, but that doesn't mean you should pass verify=False or ssl_verify=False to every HTTPS session instance.

Usage with truststore

You can use this concurrently with truststore, as we monkey-patch different properties of ssl, this library patches the default context creation function and truststore patches the SSLContext class.

Usage example (the order doesn't matter)

import context_relaxer
import truststore

truststore.inject_into_ssl()
context_relaxer.inject_into_ssl()

Tested usage

  • urllib (builtin)
  • urllib3
  • requests
  • aiohttp

Requests 2.32.0 - 2.32.4

In version 2.32.0 requests introduced a preloaded context, which was reverted in 2.32.5

If you are using a version in this range, make sure to inject the monkey-patch before importing requests

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

context_relaxer-0.1.1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

context_relaxer-0.1.1-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file context_relaxer-0.1.1.tar.gz.

File metadata

  • Download URL: context_relaxer-0.1.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.5

File hashes

Hashes for context_relaxer-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6ffa7d0fbdf657636fd0cc6766f85bd9e9a6454d9434622ac009a382c58590c7
MD5 53c9b6d1a3d4e101ed1db12d863f4d11
BLAKE2b-256 f1d835c759b701395b23411889eb7ec2f0d358d21f36430785e610f56af76a7b

See more details on using hashes here.

File details

Details for the file context_relaxer-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for context_relaxer-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bffee9645b7315fe0dd7aa3f503d7663d130777f12d14cb03895b7662ee096b6
MD5 3e459529918a721bd2c28d02ddbabe0c
BLAKE2b-256 937df6f24f0b7c9e2703b6f5b4a8cc415af599a3bd73da8e683a4df5e97bc7e7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page