Skip to content

Commit

Permalink
Merge pull request #285 from ionos-cloud/dimclient-ssl-compat
Browse files Browse the repository at this point in the history
dimclient: work around issues due to SSL defaults changes in Python 3.13
  • Loading branch information
zeromind authored Nov 13, 2024
2 parents ced4f83 + 631d71e commit c775fa9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions dimclient/dimclient/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
from http.cookiejar import LWPCookieJar
from urllib.parse import urlencode
from urllib.error import HTTPError
from urllib.request import urlopen, Request, build_opener, HTTPCookieProcessor
from urllib.request import urlopen, Request, build_opener, HTTPCookieProcessor, HTTPSHandler
import logging
import getpass
import time
import os
import os.path
import ssl
from pprint import pformat
from . import version

Expand Down Expand Up @@ -36,7 +37,10 @@ class DimClient(object):
def __init__(self, server_url, cookie_file=None, cookie_umask=None, request_timeout=120):
self.server_url = server_url
self.cookie_jar = LWPCookieJar()
self.session = build_opener(HTTPCookieProcessor(self.cookie_jar))
self.ssl_context = ssl.create_default_context()
if hasattr(ssl, 'VERIFY_X509_STRICT'):
self.ssl_context.verify_flags &= ~ssl.VERIFY_X509_STRICT
self.session = build_opener(HTTPSHandler(context=self.ssl_context), HTTPCookieProcessor(self.cookie_jar))
if cookie_file:
self._use_cookie_file(cookie_file, cookie_umask)
self.request_timeout = request_timeout
Expand Down
2 changes: 1 addition & 1 deletion dimclient/dimclient/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "1.0.1"
VERSION = "1.0.5"
2 changes: 1 addition & 1 deletion dimclient/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "dimclient"
version = "1.0.1"
version = "1.0.5"
maintainers = [
{ name = "zerimond" },
]
Expand Down

0 comments on commit c775fa9

Please sign in to comment.