def certificateError(self, error): """Handle certificate errors coming from Qt.""" self.certificate_error.emit() url = error.url() error = certificateerror.CertificateErrorWrapper(error) log.webview.debug("Certificate error: {}".format(error)) url_string = url.toDisplayString() error_page = jinja.render( 'error.html', title="Error loading page: {}".format(url_string), url=url_string, error=str(error), icon='') if error.is_overridable(): ignore = shared.ignore_certificate_errors( url, [error], abort_on=[self.loadStarted, self.shutting_down]) else: log.webview.error("Non-overridable certificate error: " "{}".format(error)) ignore = False # We can't really know when to show an error page, as the error might # have happened when loading some resource. # However, self.url() is not available yet and self.requestedUrl() # might not match the URL we get from the error - so we just apply a # heuristic here. # See https://bugreports.qt.io/browse/QTBUG-56207 log.webview.debug("ignore {}, URL {}, requested {}".format( ignore, url, self.requestedUrl())) if not ignore and url.matches(self.requestedUrl(), QUrl.RemoveScheme): self.setHtml(error_page) return ignore
def certificateError(self, error): """Handle certificate errors coming from Qt.""" error = certificateerror.CertificateErrorWrapper(error) self.certificate_error.emit(error) return error.ignore