eric6/E5Network/E5SslCertificatesInfoWidget.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7923
91e843545d9a
child 8143
2c730d5fd177
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

2359
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
3 # Copyright (c) 2010 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
2359
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a widget to show SSL certificate infos.
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5624
diff changeset
10 from PyQt5.QtCore import pyqtSlot, QCryptographicHash, QDateTime
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
11 from PyQt5.QtWidgets import QWidget
7766
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
12 try:
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
13 from PyQt5.QtNetwork import QSslCertificate
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
14 except ImportError:
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
15 QSslCertificate = None
2359
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
2432
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
17 from .Ui_E5SslCertificatesInfoWidget import Ui_E5SslCertificatesInfoWidget
2359
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 import Utilities
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
2432
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
22 class E5SslCertificatesInfoWidget(QWidget, Ui_E5SslCertificatesInfoWidget):
2359
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 """
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 Class implementing a widget to show SSL certificate infos.
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 def __init__(self, parent=None):
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 Constructor
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 @param parent reference to the parent widget (QWidget)
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2432
diff changeset
32 super(E5SslCertificatesInfoWidget, self).__init__(parent)
2359
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 self.setupUi(self)
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34
2432
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
35 self.__chain = []
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
36
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
37 def showCertificateChain(self, certificateChain):
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
38 """
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
39 Public method to show the SSL certificates of a certificate chain.
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
40
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2578
diff changeset
41 @param certificateChain list od SSL certificates
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2578
diff changeset
42 (list of QSslCertificate)
2432
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
43 """
7766
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
44 if QSslCertificate:
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
45 self.chainLabel.show()
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
46 self.chainComboBox.show()
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
47 self.chainComboBox.clear()
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
48
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
49 self.__chain = certificateChain[:]
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
50
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
51 for cert in self.__chain:
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
52 name = ", ".join(cert.subjectInfo(QSslCertificate.CommonName))
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
53 if not name:
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
54 name = ", ".join(
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
55 cert.subjectInfo(QSslCertificate.Organization))
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
56 if not name:
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
57 name = cert.serialNumber()
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
58 self.chainComboBox.addItem(name)
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
59
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
60 self.on_chainComboBox_activated(0)
2432
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
61
2359
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 def showCertificate(self, certificate):
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 """
2432
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
64 Public method to show the SSL certificate information.
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
65
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
66 @param certificate reference to the SSL certificate (QSslCertificate)
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
67 """
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
68 self.chainLabel.hide()
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
69 self.chainComboBox.hide()
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
70 self.chainComboBox.clear()
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
71
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
72 self.__chain = []
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
73
7766
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
74 if QSslCertificate:
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
75 self.__showCertificate(certificate)
2432
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
76
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
77 def __showCertificate(self, certificate):
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
78 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
79 Private method to show the SSL certificate information.
2359
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 @param certificate reference to the SSL certificate (QSslCertificate)
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 """
7766
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
83 if QSslCertificate:
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
84 self.blacklistedLabel.setVisible(False)
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
85 self.blacklistedLabel.setStyleSheet(
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
86 "QLabel { color : white; background-color : red; }")
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
87 self.expiredLabel.setVisible(False)
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
88 self.expiredLabel.setStyleSheet(
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
89 "QLabel { color : white; background-color : red; }")
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
90
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
91 self.subjectCommonNameLabel.setText(self.__certificateString(
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
92 ", ".join(certificate.subjectInfo(
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
93 QSslCertificate.CommonName))))
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
94 self.subjectOrganizationLabel.setText(self.__certificateString(
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
95 ", ".join(certificate.subjectInfo(
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
96 QSslCertificate.Organization))))
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
97 self.subjectOrganizationalUnitLabel.setText(
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
98 self.__certificateString(", ".join(
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
99 certificate.subjectInfo(
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
100 QSslCertificate.OrganizationalUnitName))))
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
101 self.issuerCommonNameLabel.setText(self.__certificateString(
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
102 ", ".join(certificate.issuerInfo(QSslCertificate.CommonName))))
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
103 self.issuerOrganizationLabel.setText(self.__certificateString(
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
104 ", ".join(certificate.issuerInfo(
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
105 QSslCertificate.Organization))))
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
106 self.issuerOrganizationalUnitLabel.setText(
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
107 self.__certificateString(", ".join(
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
108 certificate.issuerInfo(
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
109 QSslCertificate.OrganizationalUnitName))))
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
110 self.serialNumberLabel.setText(self.__serialNumber(certificate))
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
111 self.effectiveLabel.setText(
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
112 certificate.effectiveDate().toString("yyyy-MM-dd"))
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
113 self.expiresLabel.setText(
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
114 certificate.expiryDate().toString("yyyy-MM-dd"))
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
115 self.sha1Label.setText(self.__formatHexString(
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
116 str(certificate.digest(QCryptographicHash.Sha1).toHex(),
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
117 encoding="ascii")))
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
118 self.md5Label.setText(self.__formatHexString(
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
119 str(certificate.digest(QCryptographicHash.Md5).toHex(),
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
120 encoding="ascii")))
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
121
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
122 if certificate.isBlacklisted():
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
123 # something is wrong; indicate it to the user
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
124 if self.__hasExpired(certificate.effectiveDate(),
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
125 certificate.expiryDate()):
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
126 self.expiredLabel.setVisible(True)
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
127 else:
0af772bc14c4 Web Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
128 self.blacklistedLabel.setVisible(True)
2359
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 def __certificateString(self, txt):
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 """
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 Private method to prepare some text for display.
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 @param txt text to be displayed (string)
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 @return prepared text (string)
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 """
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 if txt is None or txt == "":
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
138 return self.tr("<not part of the certificate>")
2359
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 return Utilities.decodeString(txt)
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 def __serialNumber(self, cert):
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 """
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 Private slot to format the certificate serial number.
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 @param cert reference to the SSL certificate (QSslCertificate)
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 @return formated serial number (string)
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 """
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 serial = cert.serialNumber()
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 if serial == "":
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
151 return self.tr("<not part of the certificate>")
2359
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152
4326
e52318f11812 Change code to make eric compatible to PyQt 5.5 (QByteArry issue).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
153 if b':' in serial:
2359
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 return str(serial, encoding="ascii").upper()
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 else:
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 hexString = hex(int(serial))[2:]
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 return self.__formatHexString(hexString)
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 def __formatHexString(self, hexString):
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 """
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 Private method to format a hex string for display.
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 @param hexString hex string to be formatted (string)
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 @return formatted string (string)
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 """
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 hexString = hexString.upper()
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 if len(hexString) % 2 == 1:
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 hexString = '0' + hexString
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 hexList = []
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 while hexString:
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 hexList.append(hexString[:2])
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 hexString = hexString[2:]
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 return ':'.join(hexList)
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 def __hasExpired(self, effectiveDate, expiryDate):
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 """
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 Private method to check for a certificate expiration.
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 @param effectiveDate date the certificate becomes effective (QDateTime)
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 @param expiryDate date the certificate expires (QDateTime)
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 @return flag indicating the expiration status (boolean)
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 """
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 now = QDateTime.currentDateTime()
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187
ef81d2d0a031 Moved the SSL widgets to the E5Network package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 return now < effectiveDate or now >= expiryDate
2432
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
189
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
190 @pyqtSlot(int)
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
191 def on_chainComboBox_activated(self, index):
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
192 """
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
193 Private slot to show the certificate info for the selected entry.
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
194
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2578
diff changeset
195 @param index number of the certificate in the certificate chain
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2578
diff changeset
196 (integer)
2432
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
197 """
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
198 self.__showCertificate(self.__chain[index])

eric ide

mercurial