diff -r 707442ffadc3 -r dd1054be15aa eric6/WebBrowser/Network/NetworkManager.py --- a/eric6/WebBrowser/Network/NetworkManager.py Sat May 02 14:04:18 2020 +0200 +++ b/eric6/WebBrowser/Network/NetworkManager.py Sun May 31 17:26:14 2020 +0200 @@ -64,12 +64,14 @@ if SSL_AVAILABLE: self.__sslErrorHandler = E5SslErrorHandler(self) - self.sslErrors.connect(self.__sslErrorHandler.sslErrorsReplySlot) + self.sslErrors.connect(self.__sslErrorHandlingSlot) self.__temporarilyIgnoredSslErrors = {} self.__permanentlyIgnoredSslErrors = {} # dictionaries of permanently and temporarily ignored SSL errors + self.__insecureHosts = set() + self.__loaded = False self.__saveTimer = AutoSaver(self, self.__save) @@ -175,10 +177,15 @@ @return flag indicating to ignore this error @rtype bool """ + if Preferences.getWebBrowser("AlwaysRejectFaultyCertificates"): + return False + self.__load() host = error.url().host() + self.__insecureHosts.add(host) + if ( host in self.__temporarilyIgnoredSslErrors and error.error() in self.__temporarilyIgnoredSslErrors[host] @@ -196,11 +203,11 @@ E5MessageBox.Warning, title, self.tr("""<b>{0}</b>""" - """<p>The page you are trying to access has errors""" - """ in the SSL certificate.</p>""" - """<ul><li>{1}</li></ul>""" + """<p>The host <b>{1}</b> you are trying to access has""" + """ errors in the SSL certificate.</p>""" + """<ul><li>{2}</li></ul>""" """<p>Would you like to make an exception?</p>""") - .format(title, error.errorDescription()), + .format(title, host, error.errorDescription()), modal=True, parent=view) permButton = msgBox.addButton(self.tr("&Permanent accept"), E5MessageBox.AcceptRole) @@ -222,6 +229,40 @@ else: return False + def __sslErrorHandlingSlot(self, reply, errors): + """ + Private slot to handle SSL errors for a network reply. + + @param reply reference to the reply object + @type QNetworkReply + @param errors list of SSL errors + @type list of QSslError + """ + if Preferences.getWebBrowser("AlwaysRejectFaultyCertificates"): + return + + self.__load() + + host = reply.url().host() + if ( + host in self.__permanentlyIgnoredSslErrors or + host in self.__temporarilyIgnoredSslErrors + ): + reply.ignoreSslErrors() + else: + self.__sslErrorHandler.sslErrorsReply(reply, errors) + + def isInsecureHost(self, host): + """ + Public method to check a host against the list of insecure hosts. + + @param host name of the host to be checked + @type str + @return flag indicating an insecure host + @rtype bool + """ + return host in self.__insecureHosts + def authentication(self, url, auth, page=None): """ Public slot to handle an authentication request.