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 |
10 |
11 from PyQt5.QtCore import pyqtSlot, Qt, QByteArray, QFile, QFileInfo, \ |
11 from PyQt5.QtCore import ( |
12 QIODevice |
12 pyqtSlot, Qt, QByteArray, QFile, QFileInfo, QIODevice |
|
13 ) |
13 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem |
14 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem |
14 try: |
15 try: |
15 from PyQt5.QtNetwork import QSslCertificate, QSslSocket, \ |
16 from PyQt5.QtNetwork import ( |
16 QSslConfiguration, QSsl |
17 QSslCertificate, QSslSocket, QSslConfiguration, QSsl |
|
18 ) |
17 except ImportError: |
19 except ImportError: |
18 pass |
20 pass |
19 |
21 |
20 from E5Gui import E5MessageBox, E5FileDialog |
22 from E5Gui import E5MessageBox, E5FileDialog |
21 |
23 |
127 def on_serversViewButton_clicked(self): |
129 def on_serversViewButton_clicked(self): |
128 """ |
130 """ |
129 Private slot to show data of the selected server certificate. |
131 Private slot to show data of the selected server certificate. |
130 """ |
132 """ |
131 try: |
133 try: |
132 from E5Network.E5SslCertificatesInfoDialog import \ |
134 from E5Network.E5SslCertificatesInfoDialog import ( |
133 E5SslCertificatesInfoDialog |
135 E5SslCertificatesInfoDialog |
|
136 ) |
134 cert = QSslCertificate.fromData( |
137 cert = QSslCertificate.fromData( |
135 self.serversCertificatesTree.currentItem().data( |
138 self.serversCertificatesTree.currentItem().data( |
136 0, self.CertRole)) |
139 0, self.CertRole)) |
137 dlg = E5SslCertificatesInfoDialog(cert, self) |
140 dlg = E5SslCertificatesInfoDialog(cert, self) |
138 dlg.exec_() |
141 dlg.exec_() |
236 """ |
239 """ |
237 Private slot to export the selected server certificate. |
240 Private slot to export the selected server certificate. |
238 """ |
241 """ |
239 cert = self.serversCertificatesTree.currentItem().data( |
242 cert = self.serversCertificatesTree.currentItem().data( |
240 0, self.CertRole) |
243 0, self.CertRole) |
241 fname = self.serversCertificatesTree.currentItem().text(0)\ |
244 fname = ( |
242 .replace(" ", "").replace("\t", "") |
245 self.serversCertificatesTree.currentItem().text(0).replace(" ", "") |
|
246 .replace("\t", "") |
|
247 ) |
243 self.__exportCertificate(fname, cert) |
248 self.__exportCertificate(fname, cert) |
244 |
249 |
245 def __updateDefaultConfiguration(self): |
250 def __updateDefaultConfiguration(self): |
246 """ |
251 """ |
247 Private method to update the default SSL configuration. |
252 Private method to update the default SSL configuration. |
329 def on_caViewButton_clicked(self): |
334 def on_caViewButton_clicked(self): |
330 """ |
335 """ |
331 Private slot to show data of the selected CA certificate. |
336 Private slot to show data of the selected CA certificate. |
332 """ |
337 """ |
333 try: |
338 try: |
334 from E5Network.E5SslCertificatesInfoDialog import \ |
339 from E5Network.E5SslCertificatesInfoDialog import ( |
335 E5SslCertificatesInfoDialog |
340 E5SslCertificatesInfoDialog |
|
341 ) |
336 cert = QSslCertificate.fromData( |
342 cert = QSslCertificate.fromData( |
337 self.caCertificatesTree.currentItem().data(0, self.CertRole)) |
343 self.caCertificatesTree.currentItem().data(0, self.CertRole)) |
338 dlg = E5SslCertificatesInfoDialog(cert, self) |
344 dlg = E5SslCertificatesInfoDialog(cert, self) |
339 dlg.exec_() |
345 dlg.exec_() |
340 except ImportError: |
346 except ImportError: |
416 def on_caExportButton_clicked(self): |
422 def on_caExportButton_clicked(self): |
417 """ |
423 """ |
418 Private slot to export the selected CA certificate. |
424 Private slot to export the selected CA certificate. |
419 """ |
425 """ |
420 cert = self.caCertificatesTree.currentItem().data(0, self.CertRole) |
426 cert = self.caCertificatesTree.currentItem().data(0, self.CertRole) |
421 fname = self.caCertificatesTree.currentItem().text(0)\ |
427 fname = ( |
422 .replace(" ", "").replace("\t", "") |
428 self.caCertificatesTree.currentItem().text(0).replace(" ", "") |
|
429 .replace("\t", "") |
|
430 ) |
423 self.__exportCertificate(fname, cert) |
431 self.__exportCertificate(fname, cert) |
424 |
432 |
425 def __exportCertificate(self, name, cert): |
433 def __exportCertificate(self, name, cert): |
426 """ |
434 """ |
427 Private slot to export a certificate. |
435 Private slot to export a certificate. |