Add an ssl-strict=ask option. Closes #16.

This commit is contained in:
Florian Bruhin 2014-11-30 21:57:37 +01:00
parent e3dfaa6a4b
commit 1ceb8ac74d
3 changed files with 39 additions and 9 deletions

View File

@ -251,7 +251,7 @@ DATA = collections.OrderedDict([
"`http://...` URL."), "`http://...` URL."),
('ssl-strict', ('ssl-strict',
SettingValue(typ.Bool(), 'true'), SettingValue(typ.BoolAsk(), 'ask'),
"Whether to validate SSL handshakes."), "Whether to validate SSL handshakes."),
('dns-prefetch', ('dns-prefetch',

View File

@ -265,6 +265,26 @@ class Bool(BaseType):
return [('true', ''), ('false', '')] return [('true', ''), ('false', '')]
class BoolAsk(Bool):
"""A yes/no/ask question."""
def transform(self, value):
if value.lower() == 'ask':
return 'ask'
else:
return super().transform(value)
def validate(self, value):
if value.lower() == 'ask':
return
else:
super().validate(value)
def complete(self):
return [('true', ''), ('false', ''), ('ask', '')]
class Int(BaseType): class Int(BaseType):
"""Base class for an integer setting. """Base class for an integer setting.

View File

@ -101,14 +101,24 @@ class NetworkManager(QNetworkAccessManager):
reply: The QNetworkReply that is encountering the errors. reply: The QNetworkReply that is encountering the errors.
errors: A list of errors. errors: A list of errors.
""" """
if config.get('network', 'ssl-strict'): ssl_strict = config.get('network', 'ssl-strict')
return if ssl_strict == 'ask':
for err in errors: err_string = '\n'.join('- ' + err.errorString() for err in errors)
# FIXME we might want to use warn here (non-fatal error) answer = message.ask(
# https://github.com/The-Compiler/qutebrowser/issues/114 self._win_id,
message.error(self._win_id, 'SSL errors - continue?\n{}'.format(err_string),
'SSL error: {}'.format(err.errorString())) mode=usertypes.PromptMode.yesno)
reply.ignoreSslErrors() 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()
@pyqtSlot('QNetworkReply', 'QAuthenticator') @pyqtSlot('QNetworkReply', 'QAuthenticator')
def on_authentication_required(self, _reply, authenticator): def on_authentication_required(self, _reply, authenticator):