E5Network/E5SslInfoWidget.py

changeset 5736
000ea446ff4b
parent 5389
9b1c800daff3
child 6048
82ad8ec9548c
equal deleted inserted replaced
5735:f606dbe20be6 5736:000ea446ff4b
7 Module implementing a widget to show SSL information. 7 Module implementing a widget to show SSL information.
8 """ 8 """
9 9
10 from __future__ import unicode_literals 10 from __future__ import unicode_literals
11 11
12 from PyQt5.QtCore import qVersion, Qt, QUrl, QPoint 12 from PyQt5.QtCore import Qt, QUrl, QPoint
13 from PyQt5.QtWidgets import QMenu, QGridLayout, QLabel, QSizePolicy 13 from PyQt5.QtWidgets import QMenu, QGridLayout, QLabel, QSizePolicy
14 from PyQt5.QtNetwork import QSsl, QSslConfiguration, QSslCertificate 14 from PyQt5.QtNetwork import QSsl, QSslConfiguration, QSslCertificate
15 15
16 import UI.PixmapCache 16 import UI.PixmapCache
17 import Utilities 17 import Utilities
18 from Globals import qVersionTuple
18 19
19 20
20 class E5SslInfoWidget(QMenu): 21 class E5SslInfoWidget(QMenu):
21 """ 22 """
22 Class implementing a widget to show SSL certificate infos. 23 Class implementing a widget to show SSL certificate infos.
66 if cert.isNull(): 67 if cert.isNull():
67 label.setText(self.tr( 68 label.setText(self.tr(
68 "Warning: this site is NOT carrying a certificate.")) 69 "Warning: this site is NOT carrying a certificate."))
69 imageLabel.setPixmap(UI.PixmapCache.getPixmap("securityLow32.png")) 70 imageLabel.setPixmap(UI.PixmapCache.getPixmap("securityLow32.png"))
70 else: 71 else:
71 if qVersion() >= "5.0.0": 72 if qVersionTuple() >= (5, 0, 0):
72 valid = not cert.isBlacklisted() 73 valid = not cert.isBlacklisted()
73 else: 74 else:
74 valid = cert.isValid() 75 valid = cert.isValid()
75 if valid: 76 if valid:
76 if qVersion() >= "5.0.0": 77 if qVersionTuple() >= (5, 0, 0):
77 txt = ", ".join( 78 txt = ", ".join(
78 cert.issuerInfo(QSslCertificate.CommonName)) 79 cert.issuerInfo(QSslCertificate.CommonName))
79 else: 80 else:
80 txt = cert.issuerInfo(QSslCertificate.CommonName) 81 txt = cert.issuerInfo(QSslCertificate.CommonName)
81 label.setText(self.tr( 82 label.setText(self.tr(
149 UI.PixmapCache.getPixmap("securityLow32.png")) 150 UI.PixmapCache.getPixmap("securityLow32.png"))
150 else: 151 else:
151 sslVersion = self.tr("unknown") 152 sslVersion = self.tr("unknown")
152 imageLabel.setPixmap( 153 imageLabel.setPixmap(
153 UI.PixmapCache.getPixmap("securityLow32.png")) 154 UI.PixmapCache.getPixmap("securityLow32.png"))
154 if qVersion() >= "5.0.0": 155 if qVersionTuple() >= (5, 0, 0):
155 if proto == QSsl.TlsV1_0: 156 if proto == QSsl.TlsV1_0:
156 sslVersion = "TLS 1.0" 157 sslVersion = "TLS 1.0"
157 imageLabel.setPixmap( 158 imageLabel.setPixmap(
158 UI.PixmapCache.getPixmap("securityHigh32.png")) 159 UI.PixmapCache.getPixmap("securityHigh32.png"))
159 elif proto == QSsl.TlsV1_1: 160 elif proto == QSsl.TlsV1_1:

eric ide

mercurial