GithubHelp home page GithubHelp logo

Comments (7)

fuzzyrichie avatar fuzzyrichie commented on September 26, 2024

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.

cdent avatar cdent commented on September 26, 2024

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.

fuzzyrichie avatar fuzzyrichie commented on September 26, 2024

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.

cdent avatar cdent commented on September 26, 2024

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.

fuzzyrichie avatar fuzzyrichie commented on September 26, 2024

Didn't see that workflow, but makes sense - #60

from wsgi-intercept.

fuzzyrichie avatar fuzzyrichie commented on September 26, 2024

Thanks for all your help @cdent - are you OK if I close this ticket as resolved?

from wsgi-intercept.

cdent avatar cdent commented on September 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.