How can I ignore and enable/disable SSL certificate errors through C++ in QWebEngineView? I found that QWebEnginePage has the virtual method certificateError but it is not accessible through QWebEngineView?
My solution now is to derive from QWebEnginePage, overwrite the method certificateError and pass an instance of the derived class to QWebEngineView with a call of setPage. Here is an example if someone is interested.
webpage.h
#ifndef WEBPAGE_H
#define WEBPAGE_H
#include <QWebEnginePage>
class WebPage : public QWebEnginePage
{
Q_OBJECT
public:
explicit WebPage(QWidget *parent = 0);
protected:
bool certificateError(const QWebEngineCertificateError &error) override;
};
#endif // WEBPAGE_H
webpage.cpp
#include "webpage.h"
WebPage::WebPage(QWidget *parent) :
QWebEnginePage(parent)
{
}
bool WebPage::certificateError(const QWebEngineCertificateError &error)
{
// TODO: conditional treatment
return error.isOverridable();
}
Usage:
auto webView = new QWebEngineView(this);
auto webPage = new WebPage(this);
webView->setPage(webPage);