Comments (7)
Patch that I created locally:
diff --git a/wsgi_intercept/__init__.py b/wsgi_intercept/__init__.py
index 81de790..d2cb2c2 100644
--- a/wsgi_intercept/__init__.py
+++ b/wsgi_intercept/__init__.py
@@ -623,6 +623,13 @@ class WSGI_HTTPSConnection(HTTPSConnection, WSGI_HTTPConnection):
else:
try:
import ssl
+ if hasattr(self, '_context'):
+ self._context.check_hostname = self.assert_hostname
+ if isinstance(self.cert_reqs, ssl.VerifyMode):
+ self._context.verify_mode = self.cert_reqs
+ else:
+ self._context.verify_mode = ssl.VerifyMode[self.cert_reqs]
+
if not hasattr(self, 'key_file'):
self.key_file = None
if not hasattr(self, 'cert_file'):
diff --git a/wsgi_intercept/tests/test_requests.py b/wsgi_intercept/tests/test_requests.py
index 4d69ba9..c8eb663 100644
--- a/wsgi_intercept/tests/test_requests.py
+++ b/wsgi_intercept/tests/test_requests.py
@@ -59,6 +59,20 @@ def test_https():
assert app.success()
+def test_https_no_ssl_verification_intercepted():
+ with InstalledApp(wsgi_app.simple_app, host=HOST, port=443) as app:
+ resp = requests.get('https://some_hopefully_nonexistant_domain:443/', verify=False)
+ assert resp.content == b'WSGI intercept successful!\n'
+ assert app.success()
+
+
+def test_https_no_ssl_verification_not_intercepted():
+ with InstalledApp(wsgi_app.simple_app, host=HOST, port=443) as app:
+ resp = requests.get('https://self-signed.badssl.com/', verify=False)
+ assert resp.status_code >= 200 and resp.status_code < 300
+ assert not app.success()
+
+
def test_https_default_port():
with InstalledApp(wsgi_app.simple_app, host=HOST, port=443) as app:
resp = requests.get('https://some_hopefully_nonexistant_domain/')
from wsgi-intercept.
If you can turn this into a pull request I'll happily merge it. Thanks for noticing (and figuring out how to fix) the issue.
from wsgi-intercept.
I can't push a fix unfortunately - getting permission denied in doing so. Any permissions you need to set on your end?
from wsgi-intercept.
You need to fork the repo into your own user and then create a pull request, which I can then merge. If that's not something you know how to do, let me know and I'll incorporate the change myself.
from wsgi-intercept.
Didn't see that workflow, but makes sense - #60
from wsgi-intercept.
Thanks for all your help @cdent - are you OK if I close this ticket as resolved?
from wsgi-intercept.
are you OK if I close this ticket as resolved?
Since I'm here, I'll get it. Thanks again for fixing this.
from wsgi-intercept.
Related Issues (20)
- Feature request: Add optional before_intercept and after_intercept callbacks HOT 8
- kwarg error when $http_proxy is set in environ HOT 7
- Including LICENSE file in the code repository and Adding it in the Manifest file HOT 4
- unexpected keyword argument 'source_address' HOT 3
- Please allow to disable internet tests HOT 3
- wsgi_intercept.make_environ turns headers into unicode HOT 3
- When using the url arg to an Interceptor, if there is no port in the url an error happens
- wsgi-intercept should build in some character encoding checks
- Write ignores response body when first item in iterable is an empty string HOT 1
- urllib3 intercept cause TypeError with https URL HOT 8
- Logs / errors are lost due to `wsgi.errors` not extracted HOT 4
- Interceptor.uninstall_interceptor turns off intercept for all intercepts using the same module
- Pypi sdist tarball doesn't have README.rst HOT 3
- Missing 2 required positional arguments: 'environ' and 'start_response' with Django 2.2 HOT 4
- With httplib2 0.14.0 many tests fail HOT 9
- Support aiohttp HOT 2
- Simple example fails with Python 2 HOT 5
- PEP517 HOT 4
- Incompatibility with pytest 7.2.0 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wsgi-intercept.