Skip to content

Commit

Permalink
Merge pull request #51 from greg12000/master
Browse files Browse the repository at this point in the history
handle urllib 2.0 changes
  • Loading branch information
simon-weber authored Jun 2, 2023
2 parents 835262d + 5068662 commit d0e770e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions gpsoauth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@

# Type annotations for urllib3 will be released with v2.
from urllib3.poolmanager import PoolManager # type: ignore[import]
from urllib3.util import ssl_ # type: ignore[import]

SSL_DEFAULT_CIPHERS = None
if version("urllib3") < "2.0.0a1":
from urllib3.util.ssl_ import DEFAULT_CIPHERS # type: ignore[import]
SSL_DEFAULT_CIPHERS = DEFAULT_CIPHERS

from . import google

Expand Down Expand Up @@ -67,7 +71,8 @@ def init_poolmanager(self, *args: Any, **kwargs: Any) -> None:
Authentication.
"""
context = SSLContext()
context.set_ciphers(ssl_.DEFAULT_CIPHERS)
if SSL_DEFAULT_CIPHERS:
context.set_ciphers(SSL_DEFAULT_CIPHERS)
context.verify_mode = ssl.CERT_REQUIRED
context.options &= ~ssl.OP_NO_TICKET # pylint: disable=E1101
self.poolmanager = PoolManager(*args, ssl_context=context, **kwargs)
Expand Down

0 comments on commit d0e770e

Please # to comment.