E5Network/E5SslCertificatesDialog.py

changeset 5736
000ea446ff4b
parent 5389
9b1c800daff3
child 6048
82ad8ec9548c
equal deleted inserted replaced
5735:f606dbe20be6 5736:000ea446ff4b
8 """ 8 """
9 9
10 from __future__ import unicode_literals 10 from __future__ import unicode_literals
11 11
12 from PyQt5.QtCore import pyqtSlot, Qt, QByteArray, QFile, QFileInfo, \ 12 from PyQt5.QtCore import pyqtSlot, Qt, QByteArray, QFile, QFileInfo, \
13 QIODevice, qVersion 13 QIODevice
14 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem 14 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem
15 try: 15 try:
16 from PyQt5.QtNetwork import QSslCertificate, QSslSocket, \ 16 from PyQt5.QtNetwork import QSslCertificate, QSslSocket, \
17 QSslConfiguration, QSsl 17 QSslConfiguration, QSsl
18 except ImportError: 18 except ImportError:
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
29 30
30 31
31 class E5SslCertificatesDialog(QDialog, Ui_E5SslCertificatesDialog): 32 class E5SslCertificatesDialog(QDialog, Ui_E5SslCertificatesDialog):
32 """ 33 """
33 Class implementing a dialog to show and edit all certificates. 34 Class implementing a dialog to show and edit all certificates.
84 85
85 @param server server name of the certificate (string) 86 @param server server name of the certificate (string)
86 @param cert certificate to insert (QSslCertificate) 87 @param cert certificate to insert (QSslCertificate)
87 """ 88 """
88 # step 1: extract the info to be shown 89 # step 1: extract the info to be shown
89 if qVersion() >= "5.0.0": 90 if qVersionTuple() >= (5, 0, 0):
90 organisation = Utilities.decodeString( 91 organisation = Utilities.decodeString(
91 ", ".join(cert.subjectInfo(QSslCertificate.Organization))) 92 ", ".join(cert.subjectInfo(QSslCertificate.Organization)))
92 commonName = Utilities.decodeString( 93 commonName = Utilities.decodeString(
93 ", ".join(cert.subjectInfo(QSslCertificate.CommonName))) 94 ", ".join(cert.subjectInfo(QSslCertificate.CommonName)))
94 else: 95 else:
211 sCerts = [] 212 sCerts = []
212 213
213 pems = QByteArray() 214 pems = QByteArray()
214 for cert in certs: 215 for cert in certs:
215 if cert in sCerts: 216 if cert in sCerts:
216 if qVersion() >= "5.0.0": 217 if qVersionTuple() >= (5, 0, 0):
217 commonStr = ", ".join( 218 commonStr = ", ".join(
218 cert.subjectInfo(QSslCertificate.CommonName)) 219 cert.subjectInfo(QSslCertificate.CommonName))
219 else: 220 else:
220 commonStr = cert.subjectInfo( 221 commonStr = cert.subjectInfo(
221 QSslCertificate.CommonName) 222 QSslCertificate.CommonName)
295 Private method to create a CA certificate entry. 296 Private method to create a CA certificate entry.
296 297
297 @param cert certificate to insert (QSslCertificate) 298 @param cert certificate to insert (QSslCertificate)
298 """ 299 """
299 # step 1: extract the info to be shown 300 # step 1: extract the info to be shown
300 if qVersion() >= "5.0.0": 301 if qVersionTuple() >= (5, 0, 0):
301 organisation = Utilities.decodeString( 302 organisation = Utilities.decodeString(
302 ", ".join(cert.subjectInfo(QSslCertificate.Organization))) 303 ", ".join(cert.subjectInfo(QSslCertificate.Organization)))
303 commonName = Utilities.decodeString( 304 commonName = Utilities.decodeString(
304 ", ".join(cert.subjectInfo(QSslCertificate.CommonName))) 305 ", ".join(cert.subjectInfo(QSslCertificate.CommonName)))
305 else: 306 else:
401 certs = self.__importCertificate() 402 certs = self.__importCertificate()
402 if certs: 403 if certs:
403 caCerts = self.__getSystemCaCertificates() 404 caCerts = self.__getSystemCaCertificates()
404 for cert in certs: 405 for cert in certs:
405 if cert in caCerts: 406 if cert in caCerts:
406 if qVersion() >= "5.0.0": 407 if qVersionTuple() >= (5, 0, 0):
407 commonStr = ", ".join( 408 commonStr = ", ".join(
408 cert.subjectInfo(QSslCertificate.CommonName)) 409 cert.subjectInfo(QSslCertificate.CommonName))
409 else: 410 else:
410 commonStr = cert.subjectInfo( 411 commonStr = cert.subjectInfo(
411 QSslCertificate.CommonName) 412 QSslCertificate.CommonName)

eric ide

mercurial