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 __future__ import unicode_literals |
10 from __future__ import unicode_literals |
11 try: |
11 try: |
12 str = unicode # __IGNORE_WARNING__ |
12 str = unicode |
13 except (NameError): |
13 except NameError: |
14 pass |
14 pass |
15 |
15 |
16 from PyQt4.QtCore import pyqtSlot, QCryptographicHash, QDateTime, qVersion |
16 from PyQt4.QtCore import pyqtSlot, QCryptographicHash, QDateTime, qVersion |
17 from PyQt4.QtGui import QWidget |
17 from PyQt4.QtGui import QWidget |
18 from PyQt4.QtNetwork import QSslCertificate |
18 from PyQt4.QtNetwork import QSslCertificate |
156 |
156 |
157 @param txt text to be displayed (string) |
157 @param txt text to be displayed (string) |
158 @return prepared text (string) |
158 @return prepared text (string) |
159 """ |
159 """ |
160 if txt is None or txt == "": |
160 if txt is None or txt == "": |
161 return self.trUtf8("<not part of the certificate>") |
161 return self.tr("<not part of the certificate>") |
162 |
162 |
163 return Utilities.decodeString(txt) |
163 return Utilities.decodeString(txt) |
164 |
164 |
165 def __serialNumber(self, cert): |
165 def __serialNumber(self, cert): |
166 """ |
166 """ |
169 @param cert reference to the SSL certificate (QSslCertificate) |
169 @param cert reference to the SSL certificate (QSslCertificate) |
170 @return formated serial number (string) |
170 @return formated serial number (string) |
171 """ |
171 """ |
172 serial = cert.serialNumber() |
172 serial = cert.serialNumber() |
173 if serial == "": |
173 if serial == "": |
174 return self.trUtf8("<not part of the certificate>") |
174 return self.tr("<not part of the certificate>") |
175 |
175 |
176 if ':' in serial: |
176 if ':' in serial: |
177 return str(serial, encoding="ascii").upper() |
177 return str(serial, encoding="ascii").upper() |
178 else: |
178 else: |
179 hexString = hex(int(serial))[2:] |
179 hexString = hex(int(serial))[2:] |