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.4.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.4-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: context_relaxer-0.1.4.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Alpine Linux","version":"3.22.2","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for context_relaxer-0.1.4.tar.gz
Algorithm Hash digest
SHA256 e29fd278acb6d97874552c21c0952f93899327d6fef37c4f8627dfe661455f4f
MD5 19e31e450e06b73c296ba6100c385dbb
BLAKE2b-256 d7361f18f8720734a27f7d973370dbb276b46c6d2be5e3efbc0bbd5312c9e3d7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: context_relaxer-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Alpine Linux","version":"3.22.2","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for context_relaxer-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 20f31240b85a4cbae9dbf1169359471d91c1f66e33c17a49a0a9a780b5f6014d
MD5 4885ecdae2b2859c6eef61cf7e5f0ca4
BLAKE2b-256 29ed93aa3d74131fbfefb3c6b3c40d05c84d7fe22419f506bce00f40b7cbeed7

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