summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-11-22 18:00:02 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-01-24 12:06:32 +0000
commiteb2076b5e3ac9cdbe05342da60a18760440b52c7 (patch)
tree6df2f3f2587fb74601327c9391cfe11bc420f443
parentbe0fb77baf98f773928b4ff9d08a13c83f189564 (diff)
Add support for client-certificate selection to QML
Task-number: QTBUG-69363 Change-Id: I54d1df17d82bf2297f43762b0ba86a080bafee23 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r--examples/webengine/quicknanobrowser/BrowserWindow.qml6
-rw-r--r--src/core/client_cert_select_controller.cpp34
-rw-r--r--src/core/client_cert_select_controller.h2
-rw-r--r--src/webengine/api/qquickwebengineclientcertificateselection.cpp239
-rw-r--r--src/webengine/api/qquickwebengineclientcertificateselection_p.h135
-rw-r--r--src/webengine/api/qquickwebengineview.cpp13
-rw-r--r--src/webengine/api/qquickwebengineview_p.h6
-rw-r--r--src/webengine/doc/src/webengineview_lgpl.qdoc16
-rw-r--r--src/webengine/module.pro2
-rw-r--r--src/webengine/plugin/plugin.cpp7
-rw-r--r--tests/auto/quick/publicapi/tst_publicapi.cpp5
11 files changed, 455 insertions, 10 deletions
diff --git a/examples/webengine/quicknanobrowser/BrowserWindow.qml b/examples/webengine/quicknanobrowser/BrowserWindow.qml
index 8d62482da..c0cb4283f 100644
--- a/examples/webengine/quicknanobrowser/BrowserWindow.qml
+++ b/examples/webengine/quicknanobrowser/BrowserWindow.qml
@@ -57,7 +57,7 @@ import QtQuick.Controls.Styles 1.0
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.0
import QtQuick.Window 2.1
-import QtWebEngine 1.7
+import QtWebEngine 1.9
ApplicationWindow {
id: browserWindow
@@ -490,6 +490,10 @@ ApplicationWindow {
tabs.removeTab(tabs.currentIndex);
}
+ onSelectClientCertificate: function(selection) {
+ selection.certificates[0].select();
+ }
+
Timer {
id: reloadTimer
interval: 0
diff --git a/src/core/client_cert_select_controller.cpp b/src/core/client_cert_select_controller.cpp
index 7d08d57c1..580dae826 100644
--- a/src/core/client_cert_select_controller.cpp
+++ b/src/core/client_cert_select_controller.cpp
@@ -76,17 +76,40 @@ ClientCertSelectController::~ClientCertSelectController()
void ClientCertSelectController::selectNone()
{
if (m_selected) {
- qWarning() << "ClientCertSelectController::selectNone() certicate already selected";
+ qWarning() << "ClientCertSelectController::selectNone() certificate already selected";
return;
}
m_selected = true;
m_delegate->ContinueWithCertificate(nullptr, nullptr);
}
+void ClientCertSelectController::select(int index)
+{
+ if (m_selected) {
+ qWarning() << "ClientCertSelectController::select() certificate already selected";
+ return;
+ }
+ for (auto &certInfo : m_clientCerts) {
+ if (index == 0) {
+ m_selected = true;
+ scoped_refptr<net::X509Certificate> cert = certInfo->certificate();
+ net::ClientCertIdentity::SelfOwningAcquirePrivateKey(
+ std::move(certInfo),
+ base::Bind(&content::ClientCertificateDelegate::ContinueWithCertificate,
+ base::Passed(std::move(m_delegate)), std::move(cert)));
+ return;
+ }
+ std::vector<std::string> pem_encoded;
+ if (certInfo->certificate()->GetPEMEncodedChain(&pem_encoded))
+ --index;
+ }
+ qWarning() << "ClientCertSelectController::select() index out of range:" << index;
+}
+
void ClientCertSelectController::select(const QSslCertificate &certificate)
{
if (m_selected) {
- qWarning() << "ClientCertSelectController::select() certicate already selected";
+ qWarning() << "ClientCertSelectController::select() certificate already selected";
return;
}
QByteArray derCertificate = certificate.toDer();
@@ -109,13 +132,14 @@ void ClientCertSelectController::select(const QSslCertificate &certificate)
QVector<QSslCertificate> ClientCertSelectController::certificates() const
{
- QVector<QSslCertificate> out;
+ if (!m_certificates.isEmpty())
+ return m_certificates;
for (auto &cert : m_clientCerts) {
std::vector<std::string> pem_encoded;
if (cert->certificate()->GetPEMEncodedChain(&pem_encoded))
- out.append(QSslCertificate(QByteArray::fromStdString(pem_encoded.front())));
+ m_certificates.append(QSslCertificate(QByteArray::fromStdString(pem_encoded.front())));
}
- return out;
+ return m_certificates;
}
#endif // !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
diff --git a/src/core/client_cert_select_controller.h b/src/core/client_cert_select_controller.h
index 46324ee90..8f4f78d94 100644
--- a/src/core/client_cert_select_controller.h
+++ b/src/core/client_cert_select_controller.h
@@ -83,6 +83,7 @@ public:
#if !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
void selectNone();
void select(const QSslCertificate &certificate);
+ void select(int index);
QVector<QSslCertificate> certificates() const;
#endif
@@ -91,6 +92,7 @@ private:
QUrl m_hostAndPort;
std::vector<std::unique_ptr<net::ClientCertIdentity>> m_clientCerts;
std::unique_ptr<content::ClientCertificateDelegate> m_delegate;
+ mutable QVector<QSslCertificate> m_certificates;
bool m_selected;
};
diff --git a/src/webengine/api/qquickwebengineclientcertificateselection.cpp b/src/webengine/api/qquickwebengineclientcertificateselection.cpp
new file mode 100644
index 000000000..56cf1ff64
--- /dev/null
+++ b/src/webengine/api/qquickwebengineclientcertificateselection.cpp
@@ -0,0 +1,239 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickwebengineclientcertificateselection_p.h"
+
+#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
+
+#include "client_cert_select_controller.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype WebEngineClientCertificateOption
+ \instantiates QQuickWebEngineClientCertificateOption
+ \inqmlmodule QtWebEngine
+ \since QtWebEngine 1.9
+ \brief Represents a client certificate option.
+
+ \sa {WebEngineClientCertificateSelection::certificates} {WebEngineClientCertificateSelection.certificates}
+*/
+
+QQuickWebEngineClientCertificateOption::QQuickWebEngineClientCertificateOption() = default;
+
+QQuickWebEngineClientCertificateOption::QQuickWebEngineClientCertificateOption(QQuickWebEngineClientCertificateSelection *selection, int index)
+ : QObject(), m_selection(selection), m_index(index)
+{}
+
+QQuickWebEngineClientCertificateOption::QQuickWebEngineClientCertificateOption(const QQuickWebEngineClientCertificateOption &other)
+ : QObject(), m_selection(other.m_selection), m_index(other.m_index)
+{}
+
+QQuickWebEngineClientCertificateOption &QQuickWebEngineClientCertificateOption::operator=(const QQuickWebEngineClientCertificateOption &other)
+{
+ m_selection = other.m_selection;
+ m_index = other.m_index;
+ return *this;
+}
+
+/*!
+ \qmlproperty string WebEngineClientCertificateOption::issuer
+ \brief The issuer of the certificate.
+*/
+
+QString QQuickWebEngineClientCertificateOption::issuer() const
+{
+ return m_selection->d_ptr->certificates().at(m_index).issuerDisplayName();
+}
+
+/*!
+ \qmlproperty string WebEngineClientCertificateOption::subject
+ \brief The subject of the certificate.
+*/
+QString QQuickWebEngineClientCertificateOption::subject() const
+{
+ return m_selection->d_ptr->certificates().at(m_index).subjectDisplayName();
+}
+
+/*!
+ \qmlproperty datetime WebEngineClientCertificateOption::effectiveDate
+ \brief The date and time when the certificate becomes valid.
+*/
+QDateTime QQuickWebEngineClientCertificateOption::effectiveDate() const
+{
+ return m_selection->d_ptr->certificates().at(m_index).effectiveDate();
+}
+
+/*!
+ \qmlproperty datetime WebEngineClientCertificateOption::expiryDate
+ \brief The date and time when the certificate becomes invalid.
+*/
+QDateTime QQuickWebEngineClientCertificateOption::expiryDate() const
+{
+ return m_selection->d_ptr->certificates().at(m_index).expiryDate();
+}
+
+/*!
+ \qmlproperty bool WebEngineClientCertificateOption::isSelfSigned
+ \brief Whether the certificate is only self-signed.
+*/
+bool QQuickWebEngineClientCertificateOption::isSelfSigned() const
+{
+ return m_selection->d_ptr->certificates().at(m_index).isSelfSigned();
+}
+
+/*!
+ \qmlmethod void WebEngineClientCertificateOption::select()
+
+ Selects this client certificate option.
+*/
+void QQuickWebEngineClientCertificateOption::select()
+{
+ m_selection->select(m_index);
+}
+
+/*!
+ \qmltype WebEngineClientCertificateSelection
+ \instantiates QQuickWebEngineClientCertificateSelection
+ \inqmlmodule QtWebEngine
+ \since QtWebEngine 1.9
+ \brief Provides a selection of client certificates.
+
+ When a web site requests an SSL client certificate, and one or more certificates
+ are found in the system's client certificate store, this type provides access to
+ the certificates to choose from, as well as a method for selecting one.
+
+ The selection is asynchronous. If no certificate is selected and no copy of the
+ object is kept alive, loading will continue without a certificate.
+
+ \sa {WebEngineView::selectClientCertificate}{WebEngineView.selectClientCertificate}
+*/
+
+QQuickWebEngineClientCertificateSelection::QQuickWebEngineClientCertificateSelection(QSharedPointer<ClientCertSelectController> selectController)
+ : QObject(), d_ptr(selectController)
+{}
+
+int QQuickWebEngineClientCertificateSelection::certificates_count(
+ QQmlListProperty<QQuickWebEngineClientCertificateOption> *p)
+{
+ Q_ASSERT(p && p->object);
+ QQuickWebEngineClientCertificateSelection *d = static_cast<QQuickWebEngineClientCertificateSelection *>(p->object);
+ return d->m_certificates.size();
+}
+
+QQuickWebEngineClientCertificateOption *QQuickWebEngineClientCertificateSelection::certificates_at(
+ QQmlListProperty<QQuickWebEngineClientCertificateOption> *p, int idx)
+{
+ Q_ASSERT(p && p->object);
+ QQuickWebEngineClientCertificateSelection *d = static_cast<QQuickWebEngineClientCertificateSelection *>(p->object);
+ if (idx < 0 || idx >= d->m_certificates.size())
+ return nullptr;
+ return &d->m_certificates[idx];
+}
+
+/*!
+ \qmlproperty list<WebEngineClientCertificateOption> WebEngineClientCertificateSelection::certificates
+ \brief The client certificates available to choose from.
+*/
+
+QQmlListProperty<QQuickWebEngineClientCertificateOption> QQuickWebEngineClientCertificateSelection::certificates()
+{
+ if (m_certificates.empty()) {
+ QVector<QSslCertificate> certificates = d_ptr->certificates();
+ for (int i = 0; i < certificates.count(); ++i)
+ m_certificates.push_back(QQuickWebEngineClientCertificateOption(this, i));
+ }
+
+ return QQmlListProperty<QQuickWebEngineClientCertificateOption>(
+ this, nullptr,
+ certificates_count,
+ certificates_at);
+}
+
+/*!
+ \qmlmethod void WebEngineClientCertificateSelection::select(WebEngineClientCertificateOption certificate)
+
+ Selects the client certificate \a certificate. The certificate must be one
+ of the offered certificates.
+
+ \sa selectNone()
+*/
+void QQuickWebEngineClientCertificateSelection::select(const QQuickWebEngineClientCertificateOption *certificate)
+{
+ select(certificate->m_index);
+}
+
+/*!
+ \qmlmethod void WebEngineClientCertificateSelection::select(int index)
+
+ Selects the client certificate at the index \a index in the list of offered certificates.
+
+ \sa selectNone()
+*/
+void QQuickWebEngineClientCertificateSelection::select(int index)
+{
+ d_ptr->select(index);
+}
+
+/*!
+ \qmlmethod void WebEngineClientCertificateSelection::selectNone()
+
+ Continues without using any of the offered certificates. This is the same
+ action as taken when destroying the last copy of this object if no
+ selection has been made.
+
+ \sa select()
+*/
+void QQuickWebEngineClientCertificateSelection::selectNone()
+{
+ d_ptr->selectNone();
+}
+
+/*!
+ \qmlproperty url WebEngineClientCertificateSelection::host
+ \brief The host and port of the server requesting the client certificate.
+*/
+QUrl QQuickWebEngineClientCertificateSelection::host() const
+{
+ return d_ptr->hostAndPort();
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
diff --git a/src/webengine/api/qquickwebengineclientcertificateselection_p.h b/src/webengine/api/qquickwebengineclientcertificateselection_p.h
new file mode 100644
index 000000000..7f5a26296
--- /dev/null
+++ b/src/webengine/api/qquickwebengineclientcertificateselection_p.h
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKWEBENGINECERTSELECTION_P_H
+#define QQUICKWEBENGINECERTSELECTION_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtWebEngine/private/qtwebengineglobal_p.h>
+
+#include <QtCore/QDateTime>
+#include <QtCore/QObject>
+#include <QtCore/QSharedPointer>
+#include <QtCore/QUrl>
+#include <QtCore/QVector>
+#include <QtQml/QQmlListProperty>
+
+#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
+
+QT_BEGIN_NAMESPACE
+
+class ClientCertSelectController;
+class QQuickWebEngineClientCertificateSelection;
+
+class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineClientCertificateOption : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QString issuer READ issuer CONSTANT FINAL)
+ Q_PROPERTY(QString subject READ subject CONSTANT FINAL)
+ Q_PROPERTY(QDateTime effectiveDate READ effectiveDate CONSTANT FINAL)
+ Q_PROPERTY(QDateTime expiryDate READ expiryDate CONSTANT FINAL)
+ Q_PROPERTY(bool isSelfSigned READ isSelfSigned CONSTANT FINAL)
+
+public:
+ QQuickWebEngineClientCertificateOption();
+ QQuickWebEngineClientCertificateOption(const QQuickWebEngineClientCertificateOption &);
+ QQuickWebEngineClientCertificateOption &operator=(const QQuickWebEngineClientCertificateOption &);
+
+ QString issuer() const;
+ QString subject() const;
+ QDateTime effectiveDate() const;
+ QDateTime expiryDate() const;
+ bool isSelfSigned() const;
+
+ Q_INVOKABLE void select();
+
+private:
+ friend class QQuickWebEngineClientCertificateSelection;
+ QQuickWebEngineClientCertificateOption(QQuickWebEngineClientCertificateSelection *selection, int index);
+
+ QQuickWebEngineClientCertificateSelection *m_selection;
+ int m_index;
+};
+
+class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineClientCertificateSelection : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QUrl host READ host CONSTANT FINAL)
+ Q_PROPERTY(QQmlListProperty<QQuickWebEngineClientCertificateOption> certificates READ certificates CONSTANT FINAL)
+
+public:
+ QQuickWebEngineClientCertificateSelection() = default;
+
+ QUrl host() const;
+
+ Q_INVOKABLE void select(int idx);
+ Q_INVOKABLE void select(const QQuickWebEngineClientCertificateOption *certificate);
+ Q_INVOKABLE void selectNone();
+ QQmlListProperty<QQuickWebEngineClientCertificateOption> certificates();
+
+private:
+ friend class QQuickWebEngineViewPrivate;
+ friend class QQuickWebEngineClientCertificateOption;
+
+ static int certificates_count(QQmlListProperty<QQuickWebEngineClientCertificateOption> *p);
+ static QQuickWebEngineClientCertificateOption *certificates_at(QQmlListProperty<QQuickWebEngineClientCertificateOption> *p, int idx);
+
+ explicit QQuickWebEngineClientCertificateSelection(QSharedPointer<ClientCertSelectController>);
+
+ mutable QVector<QQuickWebEngineClientCertificateOption> m_certificates;
+ QSharedPointer<ClientCertSelectController> d_ptr;
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QQuickWebEngineClientCertificateOption *)
+Q_DECLARE_METATYPE(QQmlListProperty<QQuickWebEngineClientCertificateOption>)
+Q_DECLARE_METATYPE(QQuickWebEngineClientCertificateSelection *)
+
+#endif
+
+#endif // QQUICKWEBENGINECERTSELECTION_P_H
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index 353f55974..a6913e2a7 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -49,6 +49,7 @@
#include "qquickwebengineaction_p_p.h"
#include "qquickwebenginehistory_p.h"
#include "qquickwebenginecertificateerror_p.h"
+#include "qquickwebengineclientcertificateselection_p.h"
#include "qquickwebenginecontextmenurequest_p.h"
#include "qquickwebenginedialogrequests_p.h"
#include "qquickwebenginefaviconprovider_p_p.h"
@@ -299,9 +300,17 @@ void QQuickWebEngineViewPrivate::allowCertificateError(const QSharedPointer<Cert
m_certificateErrorControllers.append(errorController);
}
-void QQuickWebEngineViewPrivate::selectClientCert(const QSharedPointer<ClientCertSelectController> &)
+void QQuickWebEngineViewPrivate::selectClientCert(const QSharedPointer<ClientCertSelectController> &controller)
{
- // Doing nothing will free the select-controller and perform default continue.
+#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
+ Q_Q(QQuickWebEngineView);
+ QQuickWebEngineClientCertificateSelection *certSelection = new QQuickWebEngineClientCertificateSelection(controller);
+ // mark the object for gc by creating temporary jsvalue
+ qmlEngine(q)->newQObject(certSelection);
+ Q_EMIT q->selectClientCertificate(certSelection);
+#else
+ Q_UNUSED(controller);
+#endif
}
void QQuickWebEngineViewPrivate::runGeolocationPermissionRequest(const QUrl &url)
diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h
index 2528be3f8..3a40abf0a 100644
--- a/src/webengine/api/qquickwebengineview_p.h
+++ b/src/webengine/api/qquickwebengineview_p.h
@@ -52,10 +52,10 @@
//
#include <QtWebEngine/private/qtwebengineglobal_p.h>
-#include "qquickwebenginescript.h"
#include <QQuickItem>
#include <QtGui/qcolor.h>
+#include "qquickwebenginescript.h"
QT_BEGIN_NAMESPACE
@@ -64,6 +64,7 @@ class QQuickContextMenuBuilder;
class QQuickWebEngineAction;
class QQuickWebEngineAuthenticationDialogRequest;
class QQuickWebEngineCertificateError;
+class QQuickWebEngineClientCertificateSelection;
class QQuickWebEngineColorDialogRequest;
class QQuickWebEngineContextMenuRequest;
class QQuickWebEngineFaviconProvider;
@@ -103,7 +104,7 @@ private:
const bool m_toggleOn;
};
-#define LATEST_WEBENGINEVIEW_REVISION 7
+#define LATEST_WEBENGINEVIEW_REVISION 9
class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
Q_OBJECT
@@ -549,6 +550,7 @@ Q_SIGNALS:
Q_REVISION(7) void devToolsViewChanged();
Q_REVISION(7) void registerProtocolHandlerRequested(const QWebEngineRegisterProtocolHandlerRequest &request);
Q_REVISION(8) void printRequested();
+ Q_REVISION(9) void selectClientCertificate(QQuickWebEngineClientCertificateSelection *clientCertSelection);
#if QT_CONFIG(webengine_testsupport)
void testSupportChanged();
diff --git a/src/webengine/doc/src/webengineview_lgpl.qdoc b/src/webengine/doc/src/webengineview_lgpl.qdoc
index 0e25e16f3..d96aabc97 100644
--- a/src/webengine/doc/src/webengineview_lgpl.qdoc
+++ b/src/webengine/doc/src/webengineview_lgpl.qdoc
@@ -1475,3 +1475,19 @@
\sa printToPdf
*/
+
+/*!
+ \qmlsignal WebEngineView::selectClientCertificate(WebEngineClientCertificateSelection clientCertificateSelection)
+ \since QtWebEngine 1.9
+
+ This signal is emitted when a web site requests an SSL client certificate, and one or more were
+ found in the system's client certificate store.
+
+ Handling the signal is asynchronous, and loading will be waiting until a certificate is selected,
+ or the last copy of \a clientCertificateSelection is destroyed.
+
+ If the signal is not handled, \a clientCertificateSelection is automatically destroyed, and loading
+ will continue without a client certificate.
+
+ \sa WebEngineClientCertificateSelection
+*/
diff --git a/src/webengine/module.pro b/src/webengine/module.pro
index b74d63d93..5bc196049 100644
--- a/src/webengine/module.pro
+++ b/src/webengine/module.pro
@@ -17,6 +17,7 @@ INCLUDEPATH += $$PWD api ../core ../core/api
SOURCES = \
api/qquickwebengineaction.cpp \
api/qquickwebenginecertificateerror.cpp \
+ api/qquickwebengineclientcertificateselection.cpp \
api/qquickwebenginecontextmenurequest.cpp \
api/qquickwebenginedialogrequests.cpp \
api/qquickwebenginedownloaditem.cpp \
@@ -41,6 +42,7 @@ HEADERS = \
api/qquickwebengineaction_p.h \
api/qquickwebengineaction_p_p.h \
api/qquickwebenginecertificateerror_p.h \
+ api/qquickwebengineclientcertificateselection_p.h \
api/qquickwebenginecontextmenurequest_p.h \
api/qquickwebenginedialogrequests_p.h \
api/qquickwebenginedownloaditem_p.h \
diff --git a/src/webengine/plugin/plugin.cpp b/src/webengine/plugin/plugin.cpp
index 9fab3e9ce..b5adef8ab 100644
--- a/src/webengine/plugin/plugin.cpp
+++ b/src/webengine/plugin/plugin.cpp
@@ -41,6 +41,7 @@
#include <QtWebEngine/QQuickWebEngineProfile>
#include <QtWebEngine/private/qquickwebenginecertificateerror_p.h>
+#include <QtWebEngine/private/qquickwebengineclientcertificateselection_p.h>
#include <QtWebEngine/private/qquickwebenginecontextmenurequest_p.h>
#include <QtWebEngine/private/qquickwebenginedialogrequests_p.h>
#include <QtWebEngine/private/qquickwebenginedownloaditem_p.h>
@@ -90,6 +91,7 @@ public:
qmlRegisterType<QQuickWebEngineView, 6>(uri, 1, 6, "WebEngineView");
qmlRegisterType<QQuickWebEngineView, 7>(uri, 1, 7, "WebEngineView");
qmlRegisterType<QQuickWebEngineView, 8>(uri, 1, 8, "WebEngineView");
+ qmlRegisterType<QQuickWebEngineView, 9>(uri, 1, 9, "WebEngineView");
qmlRegisterType<QQuickWebEngineProfile>(uri, 1, 1, "WebEngineProfile");
qmlRegisterType<QQuickWebEngineProfile, 1>(uri, 1, 2, "WebEngineProfile");
qmlRegisterType<QQuickWebEngineProfile, 2>(uri, 1, 3, "WebEngineProfile");
@@ -153,6 +155,11 @@ public:
qmlRegisterUncreatableType<QWebEngineRegisterProtocolHandlerRequest>(uri, 1, 7, "RegisterProtocolHandlerRequest",
msgUncreatableType("RegisterProtocolHandlerRequest"));
qmlRegisterUncreatableType<QQuickWebEngineAction>(uri, 1, 8, "WebEngineAction", msgUncreatableType("WebEngineAction"));
+ qmlRegisterUncreatableType<QQuickWebEngineClientCertificateSelection>(uri, 1, 9, "WebEngineClientCertificateSelection",
+ tr("Cannot create a separate instance of WebEngineClientCertificateSelection"));
+ qmlRegisterUncreatableType<QQuickWebEngineClientCertificateOption>(uri, 1, 9, "WebEngineClientCertificateOption",
+ tr("Cannot create a separate instance of WebEngineClientCertificateOption"));
+
}
private:
diff --git a/tests/auto/quick/publicapi/tst_publicapi.cpp b/tests/auto/quick/publicapi/tst_publicapi.cpp
index 0e48e280d..4cbadfdaa 100644
--- a/tests/auto/quick/publicapi/tst_publicapi.cpp
+++ b/tests/auto/quick/publicapi/tst_publicapi.cpp
@@ -40,6 +40,7 @@
#include <private/qquickwebengineview_p.h>
#include <private/qquickwebengineaction_p.h>
#include <private/qquickwebenginecertificateerror_p.h>
+#include <private/qquickwebengineclientcertificateselection_p.h>
#include <private/qquickwebenginedialogrequests_p.h>
#include <private/qquickwebenginedownloaditem_p.h>
#include <private/qquickwebenginehistory_p.h>
@@ -60,6 +61,8 @@ static const QList<const QMetaObject *> typesToCheck = QList<const QMetaObject *
<< &QQuickWebEngineView::staticMetaObject
<< &QQuickWebEngineAction::staticMetaObject
<< &QQuickWebEngineCertificateError::staticMetaObject
+ << &QQuickWebEngineClientCertificateOption::staticMetaObject
+ << &QQuickWebEngineClientCertificateSelection::staticMetaObject
<< &QQuickWebEngineDownloadItem::staticMetaObject
<< &QQuickWebEngineHistory::staticMetaObject
<< &QQuickWebEngineHistoryListModel::staticMetaObject
@@ -86,6 +89,8 @@ static QList<const char *> knownEnumNames = QList<const char *>();
static const QStringList hardcodedTypes = QStringList()
<< "QJSValue"
<< "QQmlListProperty<QQuickWebEngineScript>"
+ << "QQmlListProperty<QQuickWebEngineClientCertificateOption>"
+ << "const QQuickWebEngineClientCertificateOption*"
<< "QQmlWebChannel*"
// Ignore the testSupport types without making a fuss.
<< "QQuickWebEngineTestSupport*"