Skip to content

Commit

Permalink
Merge pull request #95 from reingart/py310-ssl-win-dh-key-too-small
Browse files Browse the repository at this point in the history
Fix #94 SSL: DH_KEY_TOO_SMALL (python 3.10 win)
  • Loading branch information
reingart authored Jul 14, 2022
2 parents 63efaa5 + 896318f commit 02ccfa0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 21 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ jobs:
run: |
wget "https://www.sistemasagiles.com.ar/soft/pyafipws/reingart2021.zip" -O reingart2019.zip
unzip reingart2019.zip
- name: Fix OpenSSL "dh key too small"
run: |
sudo cp .github/openssl.cnf /etc/ssl/openssl.cnf
- name: Copy rece.ini file
run: |
sudo cp conf/rece.ini rece.ini
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
httplib2==0.9.2; python_version <= '2.7'
httplib2==0.19.0; python_version > '3'
httplib2==0.20.4; python_version > '3'
pysimplesoap==1.08.14; python_version <= '2.7'
git+https://github.com/pysimplesoap/pysimplesoap.git@stable_py3k#pysimplesoap; python_version > '3'
cryptography==3.3.2; python_version <= '2.7'
Expand Down
23 changes: 6 additions & 17 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,34 +81,23 @@
print("para soporte de JSON debe instalar simplejson")
json = None


try:
import httplib2

# corregir temas de negociacion de SSL en algunas versiones de ubuntu:
import platform, distro

dist, ver, nick = (
distro.linux_distribution() if sys.version_info > (2, 6) else ("", "", "")
)
release, winver, csd, ptype = (
platform.win32_ver() if sys.version_info > (2, 6) else ("", "", "", "")
)
from pysimplesoap.client import SoapClient
import platform

monkey_patch = httplib2._build_ssl_context.__module__ != "httplib2"
if dist:
needs_patch = (dist == "Ubuntu" and ver == "14.04") or (
dist == "Ubuntu" and ver >= "20.04"
)
elif release:
needs_patch = release in "XP"
else:
needs_patch = False
monkey_patch = sys.version_info < (3, ) or httplib2._build_ssl_context.__module__ != "httplib2"
needs_patch = platform.system() == 'Linux' or sys.version_info > (3, 10)
if needs_patch and not monkey_patch:
_build_ssl_context = httplib2._build_ssl_context

def _build_ssl_context_new(*args, **kwargs):
context = _build_ssl_context(*args, **kwargs)
# fix ssl.SSLError: [SSL: DH_KEY_TOO_SMALL] dh key too small
# alternative: context.set_ciphers("DEFAULT@SECLEVEL=1")
context.set_ciphers("AES128-SHA")
return context

Expand Down

0 comments on commit 02ccfa0

Please sign in to comment.