Merge pull request #226 from daniel-123/master

Workaround for older twisted versions which don't support raiseMinimumTo. Ensure server support for Twisted >=16.4.0
This commit is contained in:
Alberto Sottile 2019-02-26 08:45:13 +01:00 committed by GitHub
commit 2b7d36f45c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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