Implement basic client certificate support
Certificate selection when there are multiple matches isn't implemented yet. See #3992, #3011, #4587.
This commit is contained in:
parent
0599e11dd4
commit
267537d58a
@ -35,6 +35,8 @@ Added
|
||||
are used for hints, and also allows adding custom hint groups.
|
||||
- New `:yank markdown` feature which yanks the current URL and title in
|
||||
markdown format.
|
||||
- Basic support for client certificates with Qt 5.12. Selecting the certificate
|
||||
to show when there are multiple matching certificates isn't implemented yet.
|
||||
|
||||
Changed
|
||||
~~~~~~~
|
||||
|
@ -1463,6 +1463,37 @@ class WebEngineTab(browsertab.AbstractTab):
|
||||
if reload_needed:
|
||||
self._reload_url = navigation.url
|
||||
|
||||
def _on_select_client_certificate(self, selection):
|
||||
"""Handle client certificates.
|
||||
|
||||
Currently, we simply pick the first available certificate and show an
|
||||
additional note if there are multiple matches.
|
||||
"""
|
||||
certificate = selection.certificates()[0]
|
||||
text = ('<b>Subject:</b> {subj}<br/>'
|
||||
'<b>Issuer:</b> {issuer}<br/>'
|
||||
'<b>Serial:</b> {serial}'.format(
|
||||
subj=html_utils.escape(certificate.subjectDisplayName()),
|
||||
issuer=html_utils.escape(certificate.issuerDisplayName()),
|
||||
serial=bytes(certificate.serialNumber()).decode('ascii')))
|
||||
if len(selection.certificates()) > 1:
|
||||
text += ('<br/><br/><b>Note:</b> Multiple matching certificates '
|
||||
'were found, but certificate selection is not '
|
||||
'implemented yet!')
|
||||
urlstr = selection.host().host()
|
||||
|
||||
present = message.ask(
|
||||
title='Present client certificate to {}?'.format(urlstr),
|
||||
text=text,
|
||||
mode=usertypes.PromptMode.yesno,
|
||||
abort_on=[self.shutting_down, self.load_started],
|
||||
url=urlstr)
|
||||
|
||||
if present:
|
||||
selection.select(certificate)
|
||||
else:
|
||||
selection.selectNone()
|
||||
|
||||
def _connect_signals(self):
|
||||
view = self._widget
|
||||
page = view.page()
|
||||
@ -1479,6 +1510,8 @@ class WebEngineTab(browsertab.AbstractTab):
|
||||
page.navigation_request.connect(self._on_navigation_request)
|
||||
try:
|
||||
page.printRequested.connect(self._on_print_requested)
|
||||
page.selectClientCertificate.connect(
|
||||
self._on_select_client_certificate)
|
||||
except AttributeError:
|
||||
# Added in Qt 5.12
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user