100 if commonName is None or commonName == "": |
100 if commonName is None or commonName == "": |
101 commonName = self.trUtf8("(Unknown common name)") |
101 commonName = self.trUtf8("(Unknown common name)") |
102 expiryDate = cert.expiryDate().toString("yyyy-MM-dd") |
102 expiryDate = cert.expiryDate().toString("yyyy-MM-dd") |
103 |
103 |
104 # step 2: create the entry |
104 # step 2: create the entry |
105 items = self.serversCertificatesTree.findItems(organisation, |
105 items = self.serversCertificatesTree.findItems( |
|
106 organisation, |
106 Qt.MatchFixedString | Qt.MatchCaseSensitive) |
107 Qt.MatchFixedString | Qt.MatchCaseSensitive) |
107 if len(items) == 0: |
108 if len(items) == 0: |
108 parent = QTreeWidgetItem( |
109 parent = QTreeWidgetItem( |
109 self.serversCertificatesTree, [organisation]) |
110 self.serversCertificatesTree, [organisation]) |
110 else: |
111 else: |
147 def on_serversDeleteButton_clicked(self): |
148 def on_serversDeleteButton_clicked(self): |
148 """ |
149 """ |
149 Private slot to delete the selected server certificate. |
150 Private slot to delete the selected server certificate. |
150 """ |
151 """ |
151 itm = self.serversCertificatesTree.currentItem() |
152 itm = self.serversCertificatesTree.currentItem() |
152 res = E5MessageBox.yesNo(self, |
153 res = E5MessageBox.yesNo( |
|
154 self, |
153 self.trUtf8("Delete Server Certificate"), |
155 self.trUtf8("Delete Server Certificate"), |
154 self.trUtf8("""<p>Shall the server certificate really be""" |
156 self.trUtf8("""<p>Shall the server certificate really be""" |
155 """ deleted?</p><p>{0}</p>""" |
157 """ deleted?</p><p>{0}</p>""" |
156 """<p>If the server certificate is deleted, the""" |
158 """<p>If the server certificate is deleted, the""" |
157 """ normal security checks will be reinstantiated""" |
159 """ normal security checks will be reinstantiated""" |
183 for cert in certs: |
185 for cert in certs: |
184 pems.append(cert.toPem() + '\n') |
186 pems.append(cert.toPem() + '\n') |
185 certificateDict[server] = pems |
187 certificateDict[server] = pems |
186 else: |
188 else: |
187 del certificateDict[server] |
189 del certificateDict[server] |
188 Preferences.Prefs.settings.setValue("Ssl/CaCertificatesDict", |
190 Preferences.Prefs.settings.setValue( |
|
191 "Ssl/CaCertificatesDict", |
189 certificateDict) |
192 certificateDict) |
190 |
193 |
191 # delete the certificate from the default certificates |
194 # delete the certificate from the default certificates |
192 self.__updateDefaultConfiguration() |
195 self.__updateDefaultConfiguration() |
193 |
196 |
213 commonStr = ", ".join( |
216 commonStr = ", ".join( |
214 cert.subjectInfo(QSslCertificate.CommonName)) |
217 cert.subjectInfo(QSslCertificate.CommonName)) |
215 else: |
218 else: |
216 commonStr = cert.subjectInfo( |
219 commonStr = cert.subjectInfo( |
217 QSslCertificate.CommonName) |
220 QSslCertificate.CommonName) |
218 E5MessageBox.warning(self, |
221 E5MessageBox.warning( |
|
222 self, |
219 self.trUtf8("Import Certificate"), |
223 self.trUtf8("Import Certificate"), |
220 self.trUtf8( |
224 self.trUtf8( |
221 """<p>The certificate <b>{0}</b> already exists.""" |
225 """<p>The certificate <b>{0}</b> already exists.""" |
222 """ Skipping.</p>""") |
226 """ Skipping.</p>""") |
223 .format(Utilities.decodeString(commonStr))) |
227 .format(Utilities.decodeString(commonStr))) |
224 else: |
228 else: |
225 pems.append(cert.toPem() + '\n') |
229 pems.append(cert.toPem() + '\n') |
226 if server not in certificateDict: |
230 if server not in certificateDict: |
227 certificateDict[server] = QByteArray() |
231 certificateDict[server] = QByteArray() |
228 certificateDict[server].append(pems) |
232 certificateDict[server].append(pems) |
229 Preferences.Prefs.settings.setValue("Ssl/CaCertificatesDict", |
233 Preferences.Prefs.settings.setValue( |
|
234 "Ssl/CaCertificatesDict", |
230 certificateDict) |
235 certificateDict) |
231 |
236 |
232 self.serversCertificatesTree.clear() |
237 self.serversCertificatesTree.clear() |
233 self.__populateServerCertificatesTree() |
238 self.__populateServerCertificatesTree() |
234 |
239 |
306 if commonName is None or commonName == "": |
311 if commonName is None or commonName == "": |
307 commonName = self.trUtf8("(Unknown common name)") |
312 commonName = self.trUtf8("(Unknown common name)") |
308 expiryDate = cert.expiryDate().toString("yyyy-MM-dd") |
313 expiryDate = cert.expiryDate().toString("yyyy-MM-dd") |
309 |
314 |
310 # step 2: create the entry |
315 # step 2: create the entry |
311 items = self.caCertificatesTree.findItems(organisation, |
316 items = self.caCertificatesTree.findItems( |
|
317 organisation, |
312 Qt.MatchFixedString | Qt.MatchCaseSensitive) |
318 Qt.MatchFixedString | Qt.MatchCaseSensitive) |
313 if len(items) == 0: |
319 if len(items) == 0: |
314 parent = QTreeWidgetItem(self.caCertificatesTree, [organisation]) |
320 parent = QTreeWidgetItem(self.caCertificatesTree, [organisation]) |
315 else: |
321 else: |
316 parent = items[0] |
322 parent = items[0] |
351 def on_caDeleteButton_clicked(self): |
357 def on_caDeleteButton_clicked(self): |
352 """ |
358 """ |
353 Private slot to delete the selected CA certificate. |
359 Private slot to delete the selected CA certificate. |
354 """ |
360 """ |
355 itm = self.caCertificatesTree.currentItem() |
361 itm = self.caCertificatesTree.currentItem() |
356 res = E5MessageBox.yesNo(self, |
362 res = E5MessageBox.yesNo( |
|
363 self, |
357 self.trUtf8("Delete CA Certificate"), |
364 self.trUtf8("Delete CA Certificate"), |
358 self.trUtf8( |
365 self.trUtf8( |
359 """<p>Shall the CA certificate really be deleted?</p>""" |
366 """<p>Shall the CA certificate really be deleted?</p>""" |
360 """<p>{0}</p>""" |
367 """<p>{0}</p>""" |
361 """<p>If the CA certificate is deleted, the browser""" |
368 """<p>If the CA certificate is deleted, the browser""" |
399 commonStr = ", ".join( |
406 commonStr = ", ".join( |
400 cert.subjectInfo(QSslCertificate.CommonName)) |
407 cert.subjectInfo(QSslCertificate.CommonName)) |
401 else: |
408 else: |
402 commonStr = cert.subjectInfo( |
409 commonStr = cert.subjectInfo( |
403 QSslCertificate.CommonName) |
410 QSslCertificate.CommonName) |
404 E5MessageBox.warning(self, |
411 E5MessageBox.warning( |
|
412 self, |
405 self.trUtf8("Import Certificate"), |
413 self.trUtf8("Import Certificate"), |
406 self.trUtf8( |
414 self.trUtf8( |
407 """<p>The certificate <b>{0}</b> already exists.""" |
415 """<p>The certificate <b>{0}</b> already exists.""" |
408 """ Skipping.</p>""") |
416 """ Skipping.</p>""") |
409 .format(Utilities.decodeString(commonStr))) |
417 .format(Utilities.decodeString(commonStr))) |
453 if not ext or ext not in ["pem", "der"]: |
461 if not ext or ext not in ["pem", "der"]: |
454 ex = selectedFilter.split("(*")[1].split(")")[0] |
462 ex = selectedFilter.split("(*")[1].split(")")[0] |
455 if ex: |
463 if ex: |
456 fname += ex |
464 fname += ex |
457 if QFileInfo(fname).exists(): |
465 if QFileInfo(fname).exists(): |
458 res = E5MessageBox.yesNo(self, |
466 res = E5MessageBox.yesNo( |
|
467 self, |
459 self.trUtf8("Export Certificate"), |
468 self.trUtf8("Export Certificate"), |
460 self.trUtf8("<p>The file <b>{0}</b> already exists." |
469 self.trUtf8("<p>The file <b>{0}</b> already exists." |
461 " Overwrite it?</p>").format(fname), |
470 " Overwrite it?</p>").format(fname), |
462 icon=E5MessageBox.Warning) |
471 icon=E5MessageBox.Warning) |
463 if not res: |
472 if not res: |
464 return |
473 return |
465 |
474 |
466 f = QFile(fname) |
475 f = QFile(fname) |
467 if not f.open(QIODevice.WriteOnly): |
476 if not f.open(QIODevice.WriteOnly): |
468 E5MessageBox.critical(self, |
477 E5MessageBox.critical( |
|
478 self, |
469 self.trUtf8("Export Certificate"), |
479 self.trUtf8("Export Certificate"), |
470 self.trUtf8( |
480 self.trUtf8( |
471 """<p>The certificate could not be written""" |
481 """<p>The certificate could not be written""" |
472 """ to file <b>{0}</b></p><p>Error: {1}</p>""") |
482 """ to file <b>{0}</b></p><p>Error: {1}</p>""") |
473 .format(fname, f.errorString())) |
483 .format(fname, f.errorString())) |
494 "All Files (*)")) |
504 "All Files (*)")) |
495 |
505 |
496 if fname: |
506 if fname: |
497 f = QFile(fname) |
507 f = QFile(fname) |
498 if not f.open(QIODevice.ReadOnly): |
508 if not f.open(QIODevice.ReadOnly): |
499 E5MessageBox.critical(self, |
509 E5MessageBox.critical( |
|
510 self, |
500 self.trUtf8("Export Certificate"), |
511 self.trUtf8("Export Certificate"), |
501 self.trUtf8( |
512 self.trUtf8( |
502 """<p>The certificate could not be read from file""" |
513 """<p>The certificate could not be read from file""" |
503 """ <b>{0}</b></p><p>Error: {1}</p>""") |
514 """ <b>{0}</b></p><p>Error: {1}</p>""") |
504 .format(fname, f.errorString())) |
515 .format(fname, f.errorString())) |