eric6/E5Network/E5SslUtilities.py

Tue, 10 Sep 2019 19:30:07 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 10 Sep 2019 19:30:07 +0200
changeset 7229
53054eb5b15a
parent 6942
2602857055c5
child 7360
9190402e4505
permissions
-rw-r--r--

Removed obsolete "from __future__ import ..." statements.

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
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
3 # Copyright (c) 2015 - 2019 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