Workaround for older twisted versions which don't support raiseMinimumTo.

This commit is contained in:
Daniel Wróbel 2019-02-23 20:54:35 +01:00
parent 7b82802f6f
commit 30c8cbbc08

View File

@ -13,6 +13,7 @@ from twisted.internet.protocol import Factory
try:
from OpenSSL import crypto
from twisted.internet import ssl
from OpenSSL.SSL import TLSv1_2_METHOD
except:
pass
@ -225,9 +226,14 @@ class SyncFactory(Factory):
"ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384"
accCiphers = ssl.AcceptableCiphers.fromOpenSSLCipherString(cipherListString)
try:
contextFactory = ssl.CertificateOptions(privateKey=privKeyPySSL, certificate=certifPySSL,
extraCertChain=chainPySSL, acceptableCiphers=accCiphers,
raiseMinimumTo=ssl.TLSVersion.TLSv1_2)
except:
contextFactory = ssl.CertificateOptions(privateKey=privKeyPySSL, certificate=certifPySSL,
extraCertChain=chainPySSL, acceptableCiphers=accCiphers,
method=TLSv1_2_METHOD)
self.options = contextFactory
self.serverAcceptsTLS = True