11 try: |
11 try: |
12 str = unicode |
12 str = unicode |
13 except NameError: |
13 except NameError: |
14 pass |
14 pass |
15 |
15 |
16 from PyQt5.QtCore import pyqtSlot, QCryptographicHash, QDateTime, qVersion |
16 from PyQt5.QtCore import pyqtSlot, QCryptographicHash, QDateTime |
17 from PyQt5.QtWidgets import QWidget |
17 from PyQt5.QtWidgets import QWidget |
18 from PyQt5.QtNetwork import QSslCertificate |
18 from PyQt5.QtNetwork import QSslCertificate |
19 |
19 |
20 from .Ui_E5SslCertificatesInfoWidget import Ui_E5SslCertificatesInfoWidget |
20 from .Ui_E5SslCertificatesInfoWidget import Ui_E5SslCertificatesInfoWidget |
21 |
21 |
22 import Utilities |
22 import Utilities |
|
23 from Globals import qVersionTuple |
23 |
24 |
24 |
25 |
25 class E5SslCertificatesInfoWidget(QWidget, Ui_E5SslCertificatesInfoWidget): |
26 class E5SslCertificatesInfoWidget(QWidget, Ui_E5SslCertificatesInfoWidget): |
26 """ |
27 """ |
27 Class implementing a widget to show SSL certificate infos. |
28 Class implementing a widget to show SSL certificate infos. |
49 self.chainComboBox.clear() |
50 self.chainComboBox.clear() |
50 |
51 |
51 self.__chain = certificateChain[:] |
52 self.__chain = certificateChain[:] |
52 |
53 |
53 for cert in self.__chain: |
54 for cert in self.__chain: |
54 if qVersion() >= "5.0.0": |
55 if qVersionTuple() >= (5, 0, 0): |
55 name = ", ".join(cert.subjectInfo(QSslCertificate.CommonName)) |
56 name = ", ".join(cert.subjectInfo(QSslCertificate.CommonName)) |
56 else: |
57 else: |
57 name = cert.subjectInfo(QSslCertificate.CommonName) |
58 name = cert.subjectInfo(QSslCertificate.CommonName) |
58 if not name: |
59 if not name: |
59 if qVersion() >= "5.0.0": |
60 if qVersionTuple() >= (5, 0, 0): |
60 name = ", ".join( |
61 name = ", ".join( |
61 cert.subjectInfo(QSslCertificate.Organization)) |
62 cert.subjectInfo(QSslCertificate.Organization)) |
62 else: |
63 else: |
63 name = cert.subjectInfo(QSslCertificate.Organization) |
64 name = cert.subjectInfo(QSslCertificate.Organization) |
64 if not name: |
65 if not name: |
92 "QLabel { color : white; background-color : red; }") |
93 "QLabel { color : white; background-color : red; }") |
93 self.expiredLabel.setVisible(False) |
94 self.expiredLabel.setVisible(False) |
94 self.expiredLabel.setStyleSheet( |
95 self.expiredLabel.setStyleSheet( |
95 "QLabel { color : white; background-color : red; }") |
96 "QLabel { color : white; background-color : red; }") |
96 |
97 |
97 if qVersion() >= "5.0.0": |
98 if qVersionTuple() >= (5, 0, 0): |
98 self.subjectCommonNameLabel.setText(self.__certificateString( |
99 self.subjectCommonNameLabel.setText(self.__certificateString( |
99 ", ".join(certificate.subjectInfo( |
100 ", ".join(certificate.subjectInfo( |
100 QSslCertificate.CommonName)))) |
101 QSslCertificate.CommonName)))) |
101 self.subjectOrganizationLabel.setText(self.__certificateString( |
102 self.subjectOrganizationLabel.setText(self.__certificateString( |
102 ", ".join(certificate.subjectInfo( |
103 ", ".join(certificate.subjectInfo( |
139 encoding="ascii"))) |
140 encoding="ascii"))) |
140 self.md5Label.setText(self.__formatHexString( |
141 self.md5Label.setText(self.__formatHexString( |
141 str(certificate.digest(QCryptographicHash.Md5).toHex(), |
142 str(certificate.digest(QCryptographicHash.Md5).toHex(), |
142 encoding="ascii"))) |
143 encoding="ascii"))) |
143 |
144 |
144 if (qVersion() >= "5.0.0" and certificate.isBlacklisted()) or \ |
145 if (qVersionTuple() >= (5, 0, 0) and certificate.isBlacklisted()) or \ |
145 (qVersion() < "5.0.0" and not certificate.isValid()): |
146 (qVersionTuple() < (5, 0, 0) and not certificate.isValid()): |
146 # something is wrong; indicate it to the user |
147 # something is wrong; indicate it to the user |
147 if self.__hasExpired(certificate.effectiveDate(), |
148 if self.__hasExpired(certificate.effectiveDate(), |
148 certificate.expiryDate()): |
149 certificate.expiryDate()): |
149 self.expiredLabel.setVisible(True) |
150 self.expiredLabel.setVisible(True) |
150 else: |
151 else: |