Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DH_KEY_TOO_SMALL error fix, e.g. Ubuntu 18 -> 20 increase in SECLEVEL #29

Open
christianchristensen opened this issue Jan 1, 2022 · 0 comments

Comments

@christianchristensen
Copy link

Error observed

$ python2.7 pygop/gopcli.py -r 4 -s 0
Failed to reach the lighting server. Check to make sure you're connected to the same network as the gateway and it's online.
Reason:  [SSL: DH_KEY_TOO_SMALL] dh key too small (_ssl.c:727)
Failed to setRoomLevelByRid

Fix (...at least that worked):

diff --git a/pygop.py b/pygop.py
index 50833f2..ce74d3a 100644
--- a/pygop.py
+++ b/pygop.py
@@ -231,7 +231,10 @@ class pygop(object):

         # handle any connection errors
         try:
-            response = urllib2.urlopen(req)
+            # https://askubuntu.com/questions/1231844/ssl-sslerror-ssl-dh-key-too-small-dh-key-too-small-ssl-c1108 & https://docs
.python.org/2/library/urllib2.html
+            context=ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
+            context.set_ciphers('DEFAULT@SECLEVEL=1')
+            response = urllib2.urlopen(req,context=context)
         except urllib2.URLError as e:
             if hasattr(e, 'reason'):
                 print 'Failed to reach the lighting server. Check to make ' \

After fix:

python2.7 pygop/gopcli.py -r 4 -s 0
Turning 4 off

This fix is to be local to pygop rather than overriding global (e.g. https://askubuntu.com/questions/1233186/ubuntu-20-04-how-to-set-lower-ssl-security-level )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant