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."),
('ssl-strict',
SettingValue(typ.Bool(), 'true'),
SettingValue(typ.BoolAsk(), 'ask'),
"Whether to validate SSL handshakes."),
('dns-prefetch',

View File

@ -265,6 +265,26 @@ class Bool(BaseType):
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):
"""Base class for an integer setting.

View File

@ -101,14 +101,24 @@ class NetworkManager(QNetworkAccessManager):
reply: The QNetworkReply that is encountering the errors.
errors: A list of errors.
"""
if config.get('network', 'ssl-strict'):
return
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()
ssl_strict = config.get('network', 'ssl-strict')
if ssl_strict == 'ask':
err_string = '\n'.join('- ' + err.errorString() for err in errors)
answer = message.ask(
self._win_id,
'SSL errors - continue?\n{}'.format(err_string),
mode=usertypes.PromptMode.yesno)
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')
def on_authentication_required(self, _reply, authenticator):