forked from solderpunk/AV-98
1
0
Fork 0

improve compatibility with Python 3.10

This commit is contained in:
Nic Waller 2022-06-29 20:57:34 -07:00
parent 265a69a6ed
commit 6ee2a0716d
1 changed files with 9 additions and 2 deletions

11
av98.py
View File

@ -548,8 +548,15 @@ you'll be able to transparently follow links to Gopherspace!""")
addresses = self._get_addresses(host, port)
# Prepare TLS context
protocol = ssl.PROTOCOL_TLS if sys.version_info.minor >=6 else ssl.PROTOCOL_TLSv1_2
context = ssl.SSLContext(protocol)
def _newest_supported_protocol():
if sys.version_info >= (3, 10):
return ssl.PROTOCOL_TLS_CLIENT
elif sys.version_info >= (3, 6):
return ssl.PROTOCOL_TLS
else:
return ssl.PROTOCOL_TLSv1_2
context = ssl.SSLContext(_newest_supported_protocol())
# Use CAs or TOFU
if self.options["tls_mode"] == "ca":
context.verify_mode = ssl.CERT_REQUIRED