Sun, 12 Dec 2010 17:22:24 +0100
Improved the SSL certificate handling.
--- a/APIs/Python3/eric5.api Sat Dec 11 19:26:19 2010 +0100 +++ b/APIs/Python3/eric5.api Sun Dec 12 17:22:24 2010 +0100 @@ -4385,6 +4385,7 @@ eric5.Preferences.syncPreferences?4(prefClass = Prefs) eric5.Preferences.toBool?4(value) eric5.Preferences.toByteArray?4(value) +eric5.Preferences.toDict?4(value) eric5.Preferences.toList?4(value) eric5.Project.AddDirectoryDialog.AddDirectoryDialog.getData?4() eric5.Project.AddDirectoryDialog.AddDirectoryDialog.on_filterComboBox_highlighted?4(fileType)
--- a/Documentation/Help/source.qhp Sat Dec 11 19:26:19 2010 +0100 +++ b/Documentation/Help/source.qhp Sun Dec 12 17:22:24 2010 +0100 @@ -2974,6 +2974,7 @@ <keyword name="syncPreferences" id="syncPreferences" ref="eric5.Preferences.__init__.html#syncPreferences" /> <keyword name="toBool" id="toBool" ref="eric5.Preferences.__init__.html#toBool" /> <keyword name="toByteArray" id="toByteArray" ref="eric5.Preferences.__init__.html#toByteArray" /> + <keyword name="toDict" id="toDict" ref="eric5.Preferences.__init__.html#toDict" /> <keyword name="toList" id="toList" ref="eric5.Preferences.__init__.html#toList" /> <keyword name="PreferencesLexer (Module)" id="PreferencesLexer (Module)" ref="eric5.Preferences.PreferencesLexer.html" /> <keyword name="PreferencesLexer" id="PreferencesLexer" ref="eric5.Preferences.PreferencesLexer.html#PreferencesLexer" />
--- a/Documentation/Source/eric5.Helpviewer.Download.DownloadManager.html Sat Dec 11 19:26:19 2010 +0100 +++ b/Documentation/Source/eric5.Helpviewer.Download.DownloadManager.html Sun Dec 12 17:22:24 2010 +0100 @@ -91,7 +91,7 @@ <td>Private slot to handle the context menu request for the bookmarks tree.</td> </tr><tr> <td><a href="#DownloadManager.__load">__load</a></td> -<td>Public method to load the download settings.</td> +<td>Private method to load the download settings.</td> </tr><tr> <td><a href="#DownloadManager.__updateItemCount">__updateItemCount</a></td> <td>Private method to update the count label.</td> @@ -229,7 +229,7 @@ <h4>DownloadManager.__load</h4> <b>__load</b>(<i></i>) <p> - Public method to load the download settings. + Private method to load the download settings. </p><a NAME="DownloadManager.__updateItemCount" ID="DownloadManager.__updateItemCount"></a> <h4>DownloadManager.__updateItemCount</h4> <b>__updateItemCount</b>(<i></i>)
--- a/Documentation/Source/eric5.Preferences.__init__.html Sat Dec 11 19:26:19 2010 +0100 +++ b/Documentation/Source/eric5.Preferences.__init__.html Sun Dec 12 17:22:24 2010 +0100 @@ -329,6 +329,9 @@ <td><a href="#toByteArray">toByteArray</a></td> <td>Module function to convert a value to a byte array.</td> </tr><tr> +<td><a href="#toDict">toDict</a></td> +<td>Module function to convert a value to a dictionary.</td> +</tr><tr> <td><a href="#toList">toList</a></td> <td>Module function to convert a value to a list.</td> </tr> @@ -2124,6 +2127,24 @@ </dl> <div align="right"><a href="#top">Up</a></div> <hr /><hr /> +<a NAME="toDict" ID="toDict"></a> +<h2>toDict</h2> +<b>toDict</b>(<i>value</i>) +<p> + Module function to convert a value to a dictionary. +</p><dl> +<dt><i>value</i></dt> +<dd> +value to be converted +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +converted data +</dd> +</dl> +<div align="right"><a href="#top">Up</a></div> +<hr /><hr /> <a NAME="toList" ID="toList"></a> <h2>toList</h2> <b>toList</b>(<i>value</i>)
--- a/Helpviewer/Download/DownloadManager.py Sat Dec 11 19:26:19 2010 +0100 +++ b/Helpviewer/Download/DownloadManager.py Sun Dec 12 17:22:24 2010 +0100 @@ -293,7 +293,7 @@ def __load(self): """ - Public method to load the download settings. + Private method to load the download settings. """ if self.__loaded: return
--- a/Helpviewer/HelpBrowserWV.py Sat Dec 11 19:26:19 2010 +0100 +++ b/Helpviewer/HelpBrowserWV.py Sun Dec 12 17:22:24 2010 +0100 @@ -343,7 +343,7 @@ """ Public slot to show some SSL information for the loaded page. """ - if self.__sslInfo is not None and self.__sslInfo.isValid(): + if self.__sslInfo is not None: dlg = SslInfoDialog(self.__sslInfo, self.view()) dlg.exec_() else:
--- a/Helpviewer/Network/NetworkAccessManager.py Sat Dec 11 19:26:19 2010 +0100 +++ b/Helpviewer/Network/NetworkAccessManager.py Sun Dec 12 17:22:24 2010 +0100 @@ -74,10 +74,12 @@ if SSL_AVAILABLE: sslCfg = QSslConfiguration.defaultConfiguration() caList = sslCfg.caCertificates() - caNew = QSslCertificate.fromData(Preferences.toByteArray( - Preferences.Prefs.settings.value("Help/CaCertificates"))) - for cert in caNew: - caList.append(cert) + certificateDict = Preferences.toDict( + Preferences.Prefs.settings.value("Help/CaCertificatesDict")) + for server in certificateDict: + for cert in QSslCertificate.fromData(certificateDict[server]): + if cert not in caList: + caList.append(cert) sslCfg.setCaCertificates(caList) QSslConfiguration.setDefaultConfiguration(sslCfg) @@ -193,19 +195,28 @@ @param reply reference to the reply object (QNetworkReply) @param errors list of SSL errors (list of QSslError) """ - caMerge = QSslCertificate.fromData(Preferences.toByteArray( - Preferences.Prefs.settings.value("Help/CaCertificates"))) + caMerge = {} + certificateDict = Preferences.toDict( + Preferences.Prefs.settings.value("Help/CaCertificatesDict")) + for server in certificateDict: + caMerge[server] = QSslCertificate.fromData(certificateDict[server]) caNew = [] errorStrings = [] + url = reply.url() + server = url.host() + if url.port() != -1: + server += ":{0:d}".format(url.port()) for err in errors: if err.error() == QSslError.NoError: continue - if err.certificate() in caMerge: + if server in caMerge and err.certificate() in caMerge[server]: continue errorStrings.append(err.errorString()) if not err.certificate().isNull(): - caNew.append(err.certificate()) + cert = err.certificate() + if cert not in caNew: + caNew.append(cert) if not errorStrings: reply.ignoreSslErrors() return @@ -230,8 +241,10 @@ """Do you want to accept all these certificates?</p>""")\ .format("".join(certinfos))) if ret: + if server not in caMerge: + caMerge[server] = [] for cert in caNew: - caMerge.append(cert) + caMerge[server].append(cert) sslCfg = QSslConfiguration.defaultConfiguration() caList = sslCfg.caCertificates() @@ -241,12 +254,22 @@ QSslConfiguration.setDefaultConfiguration(sslCfg) reply.setSslConfiguration(sslCfg) - pems = QByteArray() - for cert in caMerge: - pems.append(cert.toPem() + '\n') - Preferences.Prefs.settings.setValue("Help/CaCertificates", pems) + certificateDict = {} + for server in caMerge: + pems = QByteArray() + for cert in caMerge[server]: + pems.append(cert.toPem() + '\n') + certificateDict[server] = pems + Preferences.Prefs.settings.setValue("Help/CaCertificatesDict", + certificateDict) + else: + reply.abort() + return reply.ignoreSslErrors() + + else: + reply.abort() def __certToString(self, cert): """
--- a/Preferences/__init__.py Sat Dec 11 19:26:19 2010 +0100 +++ b/Preferences/__init__.py Sun Dec 12 17:22:24 2010 +0100 @@ -1848,6 +1848,7 @@ prefClass.settings.setValue("Help/" + key, value.name()) elif key == "WebSearchKeywords": # value is list of tuples of (keyword, engine name) + prefClass.settings.remove("Help/" + key) prefClass.settings.beginWriteArray("Help/" + key, len(value)) index = 0 for v in value: @@ -1857,7 +1858,8 @@ index += 1 prefClass.settings.endArray() elif key == "DownloadManagerDownloads": - # value is list of tuples of (URL, save location, done flag) + # value is list of tuples of (URL, save location, done flag, page url) + prefClass.settings.remove("Help/" + key) prefClass.settings.beginWriteArray("Help/" + key, len(value)) index = 0 for v in value: @@ -2303,6 +2305,18 @@ return QtCore.QByteArray() else: return value + +def toDict(value): + """ + Module function to convert a value to a dictionary. + + @param value value to be converted + @return converted data + """ + if value is None: + return {} + else: + return value initPreferences() initRecentSettings()