Helpviewer/SslCertificatesDialog.py

changeset 753
e19a516f0a97
parent 752
2ec6ec7cd381
child 762
48190a225699
equal deleted inserted replaced
752:2ec6ec7cd381 753:e19a516f0a97
5 5
6 """ 6 """
7 Module implementing a dialog to show and edit all certificates. 7 Module implementing a dialog to show and edit all certificates.
8 """ 8 """
9 9
10 from PyQt4.QtCore import pyqtSlot, Qt, QByteArray 10 from PyQt4.QtCore import pyqtSlot, Qt
11 from PyQt4.QtGui import QDialog, QTreeWidgetItem 11 from PyQt4.QtGui import QDialog, QTreeWidgetItem
12 try: 12 try:
13 from PyQt4.QtNetwork import QSslCertificate, QSslSocket, QSslConfiguration 13 from PyQt4.QtNetwork import QSslCertificate, QSslSocket, QSslConfiguration
14 except ImportError: 14 except ImportError:
15 pass 15 pass
19 from .Ui_SslCertificatesDialog import Ui_SslCertificatesDialog 19 from .Ui_SslCertificatesDialog import Ui_SslCertificatesDialog
20 20
21 from .SslInfoDialog import SslInfoDialog 21 from .SslInfoDialog import SslInfoDialog
22 22
23 import Preferences 23 import Preferences
24 import Utilities
24 25
25 class SslCertificatesDialog(QDialog, Ui_SslCertificatesDialog): 26 class SslCertificatesDialog(QDialog, Ui_SslCertificatesDialog):
26 """ 27 """
27 Class implementing a dialog to show and edit all certificates. 28 Class implementing a dialog to show and edit all certificates.
28 """ 29 """
60 61
61 @param server server name of the certificate (string) 62 @param server server name of the certificate (string)
62 @param cert certificate to insert (QSslCertificate) 63 @param cert certificate to insert (QSslCertificate)
63 """ 64 """
64 # step 1: extract the info to be shown 65 # step 1: extract the info to be shown
65 organisation = cert.subjectInfo(QSslCertificate.Organization) 66 organisation = Utilities.decodeString(
67 cert.subjectInfo(QSslCertificate.Organization))
66 if organisation is None or organisation == "": 68 if organisation is None or organisation == "":
67 organisation = self.trUtf8("(Unknown)") 69 organisation = self.trUtf8("(Unknown)")
68 commonName = cert.subjectInfo(QSslCertificate.CommonName) 70 commonName = Utilities.decodeString(
71 cert.subjectInfo(QSslCertificate.CommonName))
69 if commonName is None or commonName == "": 72 if commonName is None or commonName == "":
70 commonName = self.trUtf8("(Unknown common name)") 73 commonName = self.trUtf8("(Unknown common name)")
71 expiryDate = cert.expiryDate().toString("yyyy-MM-dd") 74 expiryDate = cert.expiryDate().toString("yyyy-MM-dd")
72 75
73 # step 2: create the entry 76 # step 2: create the entry
165 Private method to create a CA certificate entry. 168 Private method to create a CA certificate entry.
166 169
167 @param cert certificate to insert (QSslCertificate) 170 @param cert certificate to insert (QSslCertificate)
168 """ 171 """
169 # step 1: extract the info to be shown 172 # step 1: extract the info to be shown
170 organisation = str( 173 organisation = Utilities.decodeString(
171 QByteArray(cert.subjectInfo(QSslCertificate.Organization)), 174 cert.subjectInfo(QSslCertificate.Organization))
172 encoding = "utf-8")
173 if organisation is None or organisation == "": 175 if organisation is None or organisation == "":
174 organisation = self.trUtf8("(Unknown)") 176 organisation = self.trUtf8("(Unknown)")
175 commonName = cert.subjectInfo(QSslCertificate.CommonName) 177 commonName = Utilities.decodeString(
178 cert.subjectInfo(QSslCertificate.CommonName))
176 if commonName is None or commonName == "": 179 if commonName is None or commonName == "":
177 commonName = self.trUtf8("(Unknown common name)") 180 commonName = self.trUtf8("(Unknown common name)")
178 expiryDate = cert.expiryDate().toString("yyyy-MM-dd") 181 expiryDate = cert.expiryDate().toString("yyyy-MM-dd")
179 182
180 # step 2: create the entry 183 # step 2: create the entry

eric ide

mercurial