Helpviewer/SslInfoWidget.py

changeset 2080
4b33165dd55b
parent 2078
9f4a45741622
child 2302
f29e9405c851
equal deleted inserted replaced
2079:febae63bb821 2080:4b33165dd55b
5 5
6 """ 6 """
7 Module implementing a widget to show SSL certificate infos. 7 Module implementing a widget to show SSL certificate infos.
8 """ 8 """
9 9
10 from PyQt4.QtCore import QCryptographicHash, QDateTime, Qt, qVersion 10 from PyQt4.QtCore import QCryptographicHash, QDateTime, qVersion
11 from PyQt4.QtGui import QWidget 11 from PyQt4.QtGui import QWidget
12 from PyQt4.QtNetwork import QSslCertificate 12 from PyQt4.QtNetwork import QSslCertificate
13 13
14 from .Ui_SslInfoWidget import Ui_SslInfoWidget 14 from .Ui_SslInfoWidget import Ui_SslInfoWidget
15 15
68 self.issuerOrganizationLabel.setText(self.__certificateString( 68 self.issuerOrganizationLabel.setText(self.__certificateString(
69 certificate.issuerInfo(QSslCertificate.Organization))) 69 certificate.issuerInfo(QSslCertificate.Organization)))
70 self.issuerOrganizationalUnitLabel.setText(self.__certificateString( 70 self.issuerOrganizationalUnitLabel.setText(self.__certificateString(
71 certificate.issuerInfo(QSslCertificate.OrganizationalUnitName))) 71 certificate.issuerInfo(QSslCertificate.OrganizationalUnitName)))
72 self.serialNumberLabel.setText(self.__serialNumber(certificate)) 72 self.serialNumberLabel.setText(self.__serialNumber(certificate))
73 self.effectiveLabel.setText(Qt.escape( 73 self.effectiveLabel.setText(Utilities.html_encode(
74 certificate.effectiveDate().toString("yyyy-MM-dd"))) 74 certificate.effectiveDate().toString("yyyy-MM-dd")))
75 self.expiresLabel.setText(Qt.escape( 75 self.expiresLabel.setText(Utilities.html_encode(
76 certificate.expiryDate().toString("yyyy-MM-dd"))) 76 certificate.expiryDate().toString("yyyy-MM-dd")))
77 self.sha1Label.setText(self.__formatHexString( 77 self.sha1Label.setText(self.__formatHexString(
78 str(certificate.digest(QCryptographicHash.Sha1).toHex(), encoding="ascii"))) 78 str(certificate.digest(QCryptographicHash.Sha1).toHex(), encoding="ascii")))
79 self.md5Label.setText(self.__formatHexString( 79 self.md5Label.setText(self.__formatHexString(
80 str(certificate.digest(QCryptographicHash.Md5).toHex(), encoding="ascii"))) 80 str(certificate.digest(QCryptographicHash.Md5).toHex(), encoding="ascii")))
95 @return prepared text (string) 95 @return prepared text (string)
96 """ 96 """
97 if txt is None or txt == "": 97 if txt is None or txt == "":
98 return self.trUtf8("<not part of the certificate>") 98 return self.trUtf8("<not part of the certificate>")
99 99
100 return Qt.escape(Utilities.decodeString(txt)) 100 return Utilities.html_encode(Utilities.decodeString(txt))
101 101
102 def __serialNumber(self, cert): 102 def __serialNumber(self, cert):
103 """ 103 """
104 Private slot to format the certificate serial number. 104 Private slot to format the certificate serial number.
105 105
131 hexList = [] 131 hexList = []
132 while hexString: 132 while hexString:
133 hexList.append(hexString[:2]) 133 hexList.append(hexString[:2])
134 hexString = hexString[2:] 134 hexString = hexString[2:]
135 135
136 return Qt.escape(':'.join(hexList)) 136 return Utilities.html_encode(':'.join(hexList))
137 137
138 def __hasExpired(self, effectiveDate, expiryDate): 138 def __hasExpired(self, effectiveDate, expiryDate):
139 """ 139 """
140 Private method to check for a certificate expiration. 140 Private method to check for a certificate expiration.
141 141

eric ide

mercurial