66 def __populateServerCertificatesTree(self): |
66 def __populateServerCertificatesTree(self): |
67 """ |
67 """ |
68 Private slot to populate the server certificates tree. |
68 Private slot to populate the server certificates tree. |
69 """ |
69 """ |
70 certificateDict = Preferences.toDict( |
70 certificateDict = Preferences.toDict( |
71 Preferences.Prefs.settings.value("Ssl/CaCertificatesDict")) |
71 Preferences.Prefs.settings.value("Ssl/CaCertificatesDict")) |
72 for server in certificateDict: |
72 for server in certificateDict: |
73 for cert in QSslCertificate.fromData(certificateDict[server]): |
73 for cert in QSslCertificate.fromData(certificateDict[server]): |
74 self.__createServerCertificateEntry(server, cert) |
74 self.__createServerCertificateEntry(server, cert) |
75 |
75 |
76 self.serversCertificatesTree.expandAll() |
76 self.serversCertificatesTree.expandAll() |
156 self.trUtf8("""<p>Shall the server certificate really be""" |
156 self.trUtf8("""<p>Shall the server certificate really be""" |
157 """ deleted?</p><p>{0}</p>""" |
157 """ deleted?</p><p>{0}</p>""" |
158 """<p>If the server certificate is deleted, the""" |
158 """<p>If the server certificate is deleted, the""" |
159 """ normal security checks will be reinstantiated""" |
159 """ normal security checks will be reinstantiated""" |
160 """ and the server has to present a valid""" |
160 """ and the server has to present a valid""" |
161 """ certificate.</p>""")\ |
161 """ certificate.</p>""") |
162 .format(itm.text(0))) |
162 .format(itm.text(0))) |
163 if res: |
163 if res: |
164 server = itm.text(1) |
164 server = itm.text(1) |
165 cert = self.serversCertificatesTree.currentItem().data( |
165 cert = self.serversCertificatesTree.currentItem().data( |
166 0, self.CertRole) |
166 0, self.CertRole) |
167 |
167 |
173 self.serversCertificatesTree.takeTopLevelItem( |
173 self.serversCertificatesTree.takeTopLevelItem( |
174 self.serversCertificatesTree.indexOfTopLevelItem(parent)) |
174 self.serversCertificatesTree.indexOfTopLevelItem(parent)) |
175 |
175 |
176 # delete the certificate from the user certificate store |
176 # delete the certificate from the user certificate store |
177 certificateDict = Preferences.toDict( |
177 certificateDict = Preferences.toDict( |
178 Preferences.Prefs.settings.value("Ssl/CaCertificatesDict")) |
178 Preferences.Prefs.settings.value("Ssl/CaCertificatesDict")) |
179 if server in certificateDict: |
179 if server in certificateDict: |
180 certs = QSslCertificate.fromData(certificateDict[server]) |
180 certs = QSslCertificate.fromData(certificateDict[server]) |
181 if cert in certs: |
181 if cert in certs: |
182 certs.remove(cert) |
182 certs.remove(cert) |
183 if certs: |
183 if certs: |
222 self, |
222 self, |
223 self.trUtf8("Import Certificate"), |
223 self.trUtf8("Import Certificate"), |
224 self.trUtf8( |
224 self.trUtf8( |
225 """<p>The certificate <b>{0}</b> already exists.""" |
225 """<p>The certificate <b>{0}</b> already exists.""" |
226 """ Skipping.</p>""") |
226 """ Skipping.</p>""") |
227 .format(Utilities.decodeString(commonStr))) |
227 .format(Utilities.decodeString(commonStr))) |
228 else: |
228 else: |
229 pems.append(cert.toPem() + '\n') |
229 pems.append(cert.toPem() + '\n') |
230 if server not in certificateDict: |
230 if server not in certificateDict: |
231 certificateDict[server] = QByteArray() |
231 certificateDict[server] = QByteArray() |
232 certificateDict[server].append(pems) |
232 certificateDict[server].append(pems) |
254 """ |
254 """ |
255 Private method to update the default SSL configuration. |
255 Private method to update the default SSL configuration. |
256 """ |
256 """ |
257 caList = self.__getSystemCaCertificates() |
257 caList = self.__getSystemCaCertificates() |
258 certificateDict = Preferences.toDict( |
258 certificateDict = Preferences.toDict( |
259 Preferences.Prefs.settings.value("Ssl/CaCertificatesDict")) |
259 Preferences.Prefs.settings.value("Ssl/CaCertificatesDict")) |
260 for server in certificateDict: |
260 for server in certificateDict: |
261 for cert in QSslCertificate.fromData(certificateDict[server]): |
261 for cert in QSslCertificate.fromData(certificateDict[server]): |
262 if cert not in caList: |
262 if cert not in caList: |
263 caList.append(cert) |
263 caList.append(cert) |
264 sslCfg = QSslConfiguration.defaultConfiguration() |
264 sslCfg = QSslConfiguration.defaultConfiguration() |
364 self.trUtf8("Delete CA Certificate"), |
364 self.trUtf8("Delete CA Certificate"), |
365 self.trUtf8( |
365 self.trUtf8( |
366 """<p>Shall the CA certificate really be deleted?</p>""" |
366 """<p>Shall the CA certificate really be deleted?</p>""" |
367 """<p>{0}</p>""" |
367 """<p>{0}</p>""" |
368 """<p>If the CA certificate is deleted, the browser""" |
368 """<p>If the CA certificate is deleted, the browser""" |
369 """ will not trust any certificate issued by this CA.</p>""")\ |
369 """ will not trust any certificate issued by this CA.</p>""") |
370 .format(itm.text(0))) |
370 .format(itm.text(0))) |
371 if res: |
371 if res: |
372 cert = self.caCertificatesTree.currentItem().data(0, self.CertRole) |
372 cert = self.caCertificatesTree.currentItem().data(0, self.CertRole) |
373 |
373 |
374 # delete the selected entry and its parent entry, |
374 # delete the selected entry and its parent entry, |
375 # if it was the only one |
375 # if it was the only one |
478 self, |
478 self, |
479 self.trUtf8("Export Certificate"), |
479 self.trUtf8("Export Certificate"), |
480 self.trUtf8( |
480 self.trUtf8( |
481 """<p>The certificate could not be written""" |
481 """<p>The certificate could not be written""" |
482 """ to file <b>{0}</b></p><p>Error: {1}</p>""") |
482 """ to file <b>{0}</b></p><p>Error: {1}</p>""") |
483 .format(fname, f.errorString())) |
483 .format(fname, f.errorString())) |
484 return |
484 return |
485 |
485 |
486 if fname.endswith(".pem"): |
486 if fname.endswith(".pem"): |
487 crt = cert.toPem() |
487 crt = cert.toPem() |
488 else: |
488 else: |
510 self, |
510 self, |
511 self.trUtf8("Export Certificate"), |
511 self.trUtf8("Export Certificate"), |
512 self.trUtf8( |
512 self.trUtf8( |
513 """<p>The certificate could not be read from file""" |
513 """<p>The certificate could not be read from file""" |
514 """ <b>{0}</b></p><p>Error: {1}</p>""") |
514 """ <b>{0}</b></p><p>Error: {1}</p>""") |
515 .format(fname, f.errorString())) |
515 .format(fname, f.errorString())) |
516 return [] |
516 return [] |
517 |
517 |
518 crt = f.readAll() |
518 crt = f.readAll() |
519 f.close() |
519 f.close() |
520 cert = QSslCertificate.fromData(crt, QSsl.Pem) |
520 cert = QSslCertificate.fromData(crt, QSsl.Pem) |