E5Network/E5SslUtilities.py

changeset 4348
fcb65da90a07
parent 4332
64034d85c709
child 4631
5c1a96925da4
equal deleted inserted replaced
4345:de313fb93dee 4348:fcb65da90a07
7 Module implementing SSL utility functions. 7 Module implementing SSL utility functions.
8 """ 8 """
9 9
10 from __future__ import unicode_literals 10 from __future__ import unicode_literals
11 11
12 from PyQt5.QtCore import qVersion
13
14 12
15 def initSSL(): 13 def initSSL():
16 """ 14 """
17 Function to initialize some global SSL stuff. 15 Function to initialize some global SSL stuff.
18 """ 16 """
19 if qVersion() < "5.3.0": 17 blacklist = [
20 # Qt 5.3.0 and newer don't use weak ciphers anymore 18 "SRP-AES-256-CBC-SHA", # open to MitM
21 try: 19 "SRP-AES-128-CBC-SHA", # open to MitM
22 from PyQt5.QtNetwork import QSslSocket 20 ]
23 except ImportError: 21
24 # no SSL available, so there is nothing to initialize 22 try:
25 return 23 from PyQt5.QtNetwork import QSslSocket
26 24 except ImportError:
27 strongCiphers = [c for c in QSslSocket.supportedCiphers() 25 # no SSL available, so there is nothing to initialize
28 if c.usedBits() >= 128] 26 return
29 QSslSocket.setDefaultCiphers(strongCiphers) 27
28 strongCiphers = [c for c in QSslSocket.supportedCiphers()
29 if c.name() not in blacklist and c.usedBits() >= 128]
30 QSslSocket.setDefaultCiphers(strongCiphers)

eric ide

mercurial