diff --git a/doc/changelog.asciidoc b/doc/changelog.asciidoc
index 9b318a07a..ac1a9f898 100644
--- a/doc/changelog.asciidoc
+++ b/doc/changelog.asciidoc
@@ -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
~~~~~~~
diff --git a/qutebrowser/browser/webengine/webenginetab.py b/qutebrowser/browser/webengine/webenginetab.py
index 60a9379d4..3965c00cf 100644
--- a/qutebrowser/browser/webengine/webenginetab.py
+++ b/qutebrowser/browser/webengine/webenginetab.py
@@ -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 = ('Subject: {subj}
'
+ 'Issuer: {issuer}
'
+ 'Serial: {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 += ('
Note: 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