eric6/E5Network/E5SslCertificatesDialog.py

branch
without_py2_and_pyqt4
changeset 7198
684261ef2165
parent 6942
2602857055c5
child 7229
53054eb5b15a
equal deleted inserted replaced
7197:331569d44b19 7198:684261ef2165
24 24
25 import Preferences 25 import Preferences
26 import Utilities 26 import Utilities
27 import UI.PixmapCache 27 import UI.PixmapCache
28 import Globals 28 import Globals
29 from Globals import qVersionTuple
30 29
31 30
32 class E5SslCertificatesDialog(QDialog, Ui_E5SslCertificatesDialog): 31 class E5SslCertificatesDialog(QDialog, Ui_E5SslCertificatesDialog):
33 """ 32 """
34 Class implementing a dialog to show and edit all certificates. 33 Class implementing a dialog to show and edit all certificates.
85 84
86 @param server server name of the certificate (string) 85 @param server server name of the certificate (string)
87 @param cert certificate to insert (QSslCertificate) 86 @param cert certificate to insert (QSslCertificate)
88 """ 87 """
89 # step 1: extract the info to be shown 88 # step 1: extract the info to be shown
90 if qVersionTuple() >= (5, 0, 0): 89 organisation = Utilities.decodeString(
91 organisation = Utilities.decodeString( 90 ", ".join(cert.subjectInfo(QSslCertificate.Organization)))
92 ", ".join(cert.subjectInfo(QSslCertificate.Organization))) 91 commonName = Utilities.decodeString(
93 commonName = Utilities.decodeString( 92 ", ".join(cert.subjectInfo(QSslCertificate.CommonName)))
94 ", ".join(cert.subjectInfo(QSslCertificate.CommonName)))
95 else:
96 organisation = Utilities.decodeString(
97 cert.subjectInfo(QSslCertificate.Organization))
98 commonName = Utilities.decodeString(
99 cert.subjectInfo(QSslCertificate.CommonName))
100 if organisation is None or organisation == "": 93 if organisation is None or organisation == "":
101 organisation = self.tr("(Unknown)") 94 organisation = self.tr("(Unknown)")
102 if commonName is None or commonName == "": 95 if commonName is None or commonName == "":
103 commonName = self.tr("(Unknown common name)") 96 commonName = self.tr("(Unknown common name)")
104 expiryDate = cert.expiryDate().toString("yyyy-MM-dd") 97 expiryDate = cert.expiryDate().toString("yyyy-MM-dd")
214 sCerts = [] 207 sCerts = []
215 208
216 pems = QByteArray() 209 pems = QByteArray()
217 for cert in certs: 210 for cert in certs:
218 if cert in sCerts: 211 if cert in sCerts:
219 if qVersionTuple() >= (5, 0, 0): 212 commonStr = ", ".join(
220 commonStr = ", ".join( 213 cert.subjectInfo(QSslCertificate.CommonName))
221 cert.subjectInfo(QSslCertificate.CommonName))
222 else:
223 commonStr = cert.subjectInfo(
224 QSslCertificate.CommonName)
225 E5MessageBox.warning( 214 E5MessageBox.warning(
226 self, 215 self,
227 self.tr("Import Certificate"), 216 self.tr("Import Certificate"),
228 self.tr( 217 self.tr(
229 """<p>The certificate <b>{0}</b> already exists.""" 218 """<p>The certificate <b>{0}</b> already exists."""
298 Private method to create a CA certificate entry. 287 Private method to create a CA certificate entry.
299 288
300 @param cert certificate to insert (QSslCertificate) 289 @param cert certificate to insert (QSslCertificate)
301 """ 290 """
302 # step 1: extract the info to be shown 291 # step 1: extract the info to be shown
303 if qVersionTuple() >= (5, 0, 0): 292 organisation = Utilities.decodeString(
304 organisation = Utilities.decodeString( 293 ", ".join(cert.subjectInfo(QSslCertificate.Organization)))
305 ", ".join(cert.subjectInfo(QSslCertificate.Organization))) 294 commonName = Utilities.decodeString(
306 commonName = Utilities.decodeString( 295 ", ".join(cert.subjectInfo(QSslCertificate.CommonName)))
307 ", ".join(cert.subjectInfo(QSslCertificate.CommonName)))
308 else:
309 organisation = Utilities.decodeString(
310 cert.subjectInfo(QSslCertificate.Organization))
311 commonName = Utilities.decodeString(
312 cert.subjectInfo(QSslCertificate.CommonName))
313 if organisation is None or organisation == "": 296 if organisation is None or organisation == "":
314 organisation = self.tr("(Unknown)") 297 organisation = self.tr("(Unknown)")
315 if commonName is None or commonName == "": 298 if commonName is None or commonName == "":
316 commonName = self.tr("(Unknown common name)") 299 commonName = self.tr("(Unknown common name)")
317 expiryDate = cert.expiryDate().toString("yyyy-MM-dd") 300 expiryDate = cert.expiryDate().toString("yyyy-MM-dd")
405 certs = self.__importCertificate() 388 certs = self.__importCertificate()
406 if certs: 389 if certs:
407 caCerts = self.__getSystemCaCertificates() 390 caCerts = self.__getSystemCaCertificates()
408 for cert in certs: 391 for cert in certs:
409 if cert in caCerts: 392 if cert in caCerts:
410 if qVersionTuple() >= (5, 0, 0): 393 commonStr = ", ".join(
411 commonStr = ", ".join( 394 cert.subjectInfo(QSslCertificate.CommonName))
412 cert.subjectInfo(QSslCertificate.CommonName))
413 else:
414 commonStr = cert.subjectInfo(
415 QSslCertificate.CommonName)
416 E5MessageBox.warning( 395 E5MessageBox.warning(
417 self, 396 self,
418 self.tr("Import Certificate"), 397 self.tr("Import Certificate"),
419 self.tr( 398 self.tr(
420 """<p>The certificate <b>{0}</b> already exists.""" 399 """<p>The certificate <b>{0}</b> already exists."""

eric ide

mercurial