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:
commit
2b7d36f45c
@ -12,6 +12,7 @@ from twisted.internet.protocol import Factory
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
from OpenSSL import crypto
|
from OpenSSL import crypto
|
||||||
|
from OpenSSL.SSL import TLSv1_2_METHOD
|
||||||
from twisted.internet import ssl
|
from twisted.internet import ssl
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
@ -225,9 +226,14 @@ class SyncFactory(Factory):
|
|||||||
"ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384"
|
"ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384"
|
||||||
accCiphers = ssl.AcceptableCiphers.fromOpenSSLCipherString(cipherListString)
|
accCiphers = ssl.AcceptableCiphers.fromOpenSSLCipherString(cipherListString)
|
||||||
|
|
||||||
contextFactory = ssl.CertificateOptions(privateKey=privKeyPySSL, certificate=certifPySSL,
|
try:
|
||||||
extraCertChain=chainPySSL, acceptableCiphers=accCiphers,
|
contextFactory = ssl.CertificateOptions(privateKey=privKeyPySSL, certificate=certifPySSL,
|
||||||
raiseMinimumTo=ssl.TLSVersion.TLSv1_2)
|
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.options = contextFactory
|
||||||
self.serverAcceptsTLS = True
|
self.serverAcceptsTLS = True
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user