13 |
13 |
14 from .Ui_SslInfoDialog import Ui_SslInfoDialog |
14 from .Ui_SslInfoDialog import Ui_SslInfoDialog |
15 |
15 |
16 import Utilities |
16 import Utilities |
17 |
17 |
|
18 |
18 class SslInfoDialog(QDialog, Ui_SslInfoDialog): |
19 class SslInfoDialog(QDialog, Ui_SslInfoDialog): |
19 """ |
20 """ |
20 Class implementing a dialog to show SSL certificate infos. |
21 Class implementing a dialog to show SSL certificate infos. |
21 """ |
22 """ |
22 def __init__(self, certificate, parent = None): |
23 def __init__(self, certificate, parent=None): |
23 """ |
24 """ |
24 Constructor |
25 Constructor |
25 |
26 |
26 @param certificate reference to the SSL certificate (QSslCertificate) |
27 @param certificate reference to the SSL certificate (QSslCertificate) |
27 @param parent reference to the parent widget (QWidget) |
28 @param parent reference to the parent widget (QWidget) |
43 self.issuerOrganizationalUnitLabel.setText(self.__certificateString( |
44 self.issuerOrganizationalUnitLabel.setText(self.__certificateString( |
44 certificate.issuerInfo(QSslCertificate.OrganizationalUnitName))) |
45 certificate.issuerInfo(QSslCertificate.OrganizationalUnitName))) |
45 self.effectiveLabel.setText(certificate.effectiveDate().toString("yyyy-MM-dd")) |
46 self.effectiveLabel.setText(certificate.effectiveDate().toString("yyyy-MM-dd")) |
46 self.expiresLabel.setText(certificate.expiryDate().toString("yyyy-MM-dd")) |
47 self.expiresLabel.setText(certificate.expiryDate().toString("yyyy-MM-dd")) |
47 self.sha1Label.setText(self.__formatHexString( |
48 self.sha1Label.setText(self.__formatHexString( |
48 str(certificate.digest(QCryptographicHash.Sha1).toHex(), encoding = "ascii"))) |
49 str(certificate.digest(QCryptographicHash.Sha1).toHex(), encoding="ascii"))) |
49 self.md5Label.setText(self.__formatHexString( |
50 self.md5Label.setText(self.__formatHexString( |
50 str(certificate.digest(QCryptographicHash.Md5).toHex(), encoding = "ascii"))) |
51 str(certificate.digest(QCryptographicHash.Md5).toHex(), encoding="ascii"))) |
51 |
52 |
52 def __certificateString(self, txt): |
53 def __certificateString(self, txt): |
53 """ |
54 """ |
54 Private method to prepare some text for display. |
55 Private method to prepare some text for display. |
55 |
56 |
71 serial = cert.serialNumber() |
72 serial = cert.serialNumber() |
72 if serial == "": |
73 if serial == "": |
73 return self.trUtf8("<not part of the certificate>") |
74 return self.trUtf8("<not part of the certificate>") |
74 |
75 |
75 if ':' in serial: |
76 if ':' in serial: |
76 return str(serial, encoding = "ascii").upper() |
77 return str(serial, encoding="ascii").upper() |
77 else: |
78 else: |
78 hexString = hex(int(serial))[2:] |
79 hexString = hex(int(serial))[2:] |
79 return self.__formatHexString(hexString) |
80 return self.__formatHexString(hexString) |
80 |
81 |
81 def __formatHexString(self, hexString): |
82 def __formatHexString(self, hexString): |