eric6/E5Network/E5SslUtilities.py

Wed, 30 Dec 2020 11:00:05 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:05 +0100
changeset 7923
91e843545d9a
parent 7360
9190402e4505
permissions
-rw-r--r--

Updated copyright for 2021.

4317
0de465a93200 Added code to limit SSL sockets to ciphers with at least 128 bits for Qt < 5.3.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
0de465a93200 Added code to limit SSL sockets to ciphers with at least 128 bits for Qt < 5.3.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
3 # Copyright (c) 2015 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
4317
0de465a93200 Added code to limit SSL sockets to ciphers with at least 128 bits for Qt < 5.3.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
0de465a93200 Added code to limit SSL sockets to ciphers with at least 128 bits for Qt < 5.3.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
0de465a93200 Added code to limit SSL sockets to ciphers with at least 128 bits for Qt < 5.3.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
0de465a93200 Added code to limit SSL sockets to ciphers with at least 128 bits for Qt < 5.3.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing SSL utility functions.
0de465a93200 Added code to limit SSL sockets to ciphers with at least 128 bits for Qt < 5.3.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
0de465a93200 Added code to limit SSL sockets to ciphers with at least 128 bits for Qt < 5.3.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
4332
64034d85c709 Corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4318
diff changeset
10
4317
0de465a93200 Added code to limit SSL sockets to ciphers with at least 128 bits for Qt < 5.3.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 def initSSL():
0de465a93200 Added code to limit SSL sockets to ciphers with at least 128 bits for Qt < 5.3.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 """
0de465a93200 Added code to limit SSL sockets to ciphers with at least 128 bits for Qt < 5.3.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 Function to initialize some global SSL stuff.
0de465a93200 Added code to limit SSL sockets to ciphers with at least 128 bits for Qt < 5.3.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 """
4348
fcb65da90a07 Extended the web browser privacy settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
15 blacklist = [
fcb65da90a07 Extended the web browser privacy settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
16 "SRP-AES-256-CBC-SHA", # open to MitM
fcb65da90a07 Extended the web browser privacy settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
17 "SRP-AES-128-CBC-SHA", # open to MitM
fcb65da90a07 Extended the web browser privacy settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
18 ]
fcb65da90a07 Extended the web browser privacy settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
19
fcb65da90a07 Extended the web browser privacy settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
20 try:
fcb65da90a07 Extended the web browser privacy settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
21 from PyQt5.QtNetwork import QSslSocket
fcb65da90a07 Extended the web browser privacy settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
22 except ImportError:
fcb65da90a07 Extended the web browser privacy settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
23 # no SSL available, so there is nothing to initialize
fcb65da90a07 Extended the web browser privacy settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
24 return
fcb65da90a07 Extended the web browser privacy settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
25
fcb65da90a07 Extended the web browser privacy settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
26 strongCiphers = [c for c in QSslSocket.supportedCiphers()
fcb65da90a07 Extended the web browser privacy settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
27 if c.name() not in blacklist and c.usedBits() >= 128]
fcb65da90a07 Extended the web browser privacy settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
28 QSslSocket.setDefaultCiphers(strongCiphers)

eric ide

mercurial