From 7169d0260984c810543bd19918d80243c98796a3 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 26 Jan 2015 13:15:08 +0100 Subject: [PATCH 1/2] Support running qutebrowser without SSL. --- qutebrowser/utils/version.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/qutebrowser/utils/version.py b/qutebrowser/utils/version.py index c781ca210..e41631ca7 100644 --- a/qutebrowser/utils/version.py +++ b/qutebrowser/utils/version.py @@ -29,7 +29,10 @@ import collections from PyQt5.QtCore import QT_VERSION_STR, PYQT_VERSION_STR, qVersion from PyQt5.QtWebKit import qWebKitVersion -from PyQt5.QtNetwork import QSslSocket +try: + from PyQt5.QtNetwork import QSslSocket +except ImportError: + QSslSocket = None import qutebrowser from qutebrowser.utils import log, utils @@ -206,11 +209,15 @@ def version(): 'PyQt: {}'.format(PYQT_VERSION_STR), ] lines += _module_versions() + + if QSslSocket is not None and QSslSocket.supportsSsl(): + ssl_version = QSslSocket.sslLibraryVersionString() + else: + ssl_version = 'unavailable' lines += [ 'Webkit: {}'.format(qWebKitVersion()), 'Harfbuzz: {}'.format(os.environ.get('QT_HARFBUZZ', 'system')), - 'SSL: {}'.format(QSslSocket.sslLibraryVersionString() if - QSslSocket.supportsSsl() else 'unavailable'), + 'SSL: {}'.format(ssl_version), '', 'Frozen: {}'.format(hasattr(sys, 'frozen')), 'Platform: {}, {}'.format(platform.platform(), From 4c87287f4e5d16eede126d027ea527ab725b2092 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 26 Jan 2015 13:23:41 +0100 Subject: [PATCH 2/2] Don't set up on_ssl_errors slot without SSL. --- qutebrowser/browser/network/networkmanager.py | 49 ++++++++++--------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/qutebrowser/browser/network/networkmanager.py b/qutebrowser/browser/network/networkmanager.py index a95c64387..3bf9e4c0f 100644 --- a/qutebrowser/browser/network/networkmanager.py +++ b/qutebrowser/browser/network/networkmanager.py @@ -152,33 +152,34 @@ class NetworkManager(QNetworkAccessManager): request.deleteLater() self.shutting_down.emit() - @pyqtSlot('QNetworkReply*', 'QList') - def on_ssl_errors(self, reply, errors): - """Decide if SSL errors should be ignored or not. + if SSL_AVAILABLE: + @pyqtSlot('QNetworkReply*', 'QList') + def on_ssl_errors(self, reply, errors): + """Decide if SSL errors should be ignored or not. - This slot is called on SSL/TLS errors by the self.sslErrors signal. + This slot is called on SSL/TLS errors by the self.sslErrors signal. - Args: - reply: The QNetworkReply that is encountering the errors. - errors: A list of errors. - """ - ssl_strict = config.get('network', 'ssl-strict') - if ssl_strict == 'ask': - err_string = '\n'.join('- ' + err.errorString() for err in errors) - answer = self._ask('SSL errors - continue?\n{}'.format(err_string), - mode=usertypes.PromptMode.yesno, - owner=reply) - if answer: + Args: + reply: The QNetworkReply that is encountering the errors. + errors: A list of errors. + """ + ssl_strict = config.get('network', 'ssl-strict') + if ssl_strict == 'ask': + err_string = '\n'.join('- ' + err.errorString() for err in + errors) + answer = self._ask('SSL errors - continue?\n{}'.format( + err_string), mode=usertypes.PromptMode.yesno, owner=reply) + if answer: + reply.ignoreSslErrors() + elif ssl_strict: + pass + else: + for err in errors: + # FIXME we might want to use warn here (non-fatal error) + # https://github.com/The-Compiler/qutebrowser/issues/114 + message.error(self._win_id, + 'SSL error: {}'.format(err.errorString())) reply.ignoreSslErrors() - elif ssl_strict: - pass - else: - for err in errors: - # FIXME we might want to use warn here (non-fatal error) - # https://github.com/The-Compiler/qutebrowser/issues/114 - message.error(self._win_id, - 'SSL error: {}'.format(err.errorString())) - reply.ignoreSslErrors() @pyqtSlot('QNetworkReply', 'QAuthenticator') def on_authentication_required(self, reply, authenticator):