6 """ |
6 """ |
7 Module implementing a SSL error handler. |
7 Module implementing a SSL error handler. |
8 """ |
8 """ |
9 |
9 |
10 from __future__ import unicode_literals |
10 from __future__ import unicode_literals |
|
11 |
|
12 import platform |
11 |
13 |
12 from PyQt5.QtCore import QObject, QByteArray |
14 from PyQt5.QtCore import QObject, QByteArray |
13 from PyQt5.QtNetwork import QSslCertificate, QSslConfiguration, QSslSocket, \ |
15 from PyQt5.QtNetwork import QSslCertificate, QSslConfiguration, QSslSocket, \ |
14 QSslError, QSsl |
16 QSslError, QSsl |
15 |
17 |
56 if cert not in caList: |
58 if cert not in caList: |
57 caList.append(cert) |
59 caList.append(cert) |
58 sslCfg = QSslConfiguration.defaultConfiguration() |
60 sslCfg = QSslConfiguration.defaultConfiguration() |
59 sslCfg.setCaCertificates(caList) |
61 sslCfg.setCaCertificates(caList) |
60 try: |
62 try: |
61 sslCfg.setProtocol(QSsl.TlsV1_1OrLater) |
63 sslProtocol = QSsl.TlsV1_1OrLater |
|
64 if Globals.isWindowsPlatform() and platform.win32_ver()[0] == '7': |
|
65 sslProtocol = QSsl.SecureProtocols |
62 except AttributeError: |
66 except AttributeError: |
63 sslCfg.setProtocol(QSsl.SecureProtocols) |
67 sslProtocol = QSsl.SecureProtocols |
|
68 sslCfg.setProtocol(sslProtocol) |
64 try: |
69 try: |
65 sslCfg.setSslOption(QSsl.SslOptionDisableCompression, True) |
70 sslCfg.setSslOption(QSsl.SslOptionDisableCompression, True) |
66 except AttributeError: |
71 except AttributeError: |
67 pass |
72 pass |
68 QSslConfiguration.setDefaultConfiguration(sslCfg) |
73 QSslConfiguration.setDefaultConfiguration(sslCfg) |