Add ability to ignore SSL errors
parent
9c6539c2ab
commit
068539c85a
|
@ -53,7 +53,7 @@ else()
|
|||
find_package(Qt5LinguistTools "${QT_MINIMUM_VERSION}" REQUIRED)
|
||||
endif()
|
||||
|
||||
find_package(lxqt-build-tools ${LXQTBT_MINIMUM_VERSION} REQUIRED)
|
||||
find_package(lxqt2-build-tools ${LXQTBT_MINIMUM_VERSION} REQUIRED)
|
||||
|
||||
if(USE_UTF8PROC)
|
||||
find_package(Utf8Proc REQUIRED)
|
||||
|
|
10
src/main.cpp
10
src/main.cpp
|
@ -53,6 +53,12 @@ int main(int argc, char *argv[])
|
|||
QCommandLineOption disableWebSecurityOption("disable-web-security", "Disable web security and allow custom URL schemes");
|
||||
parser.addOption(disableWebSecurityOption);
|
||||
|
||||
QCommandLineOption noSandboxOption("no-sandbox", "Disable Chromium sandbox to allow running as root");
|
||||
parser.addOption(noSandboxOption);
|
||||
|
||||
QCommandLineOption ignoreSslErrors("ignore-ssl-errors", "Ignore SSL certificate errors");
|
||||
parser.addOption(ignoreSslErrors);
|
||||
|
||||
QCommandLineOption helpOption = parser.addHelpOption();
|
||||
|
||||
OGCommandLineOptions &options = OGCommandLineOptions::getInstance();
|
||||
|
@ -76,6 +82,10 @@ int main(int argc, char *argv[])
|
|||
options.setNewTabBehavior(OGCommandLineOptions::NewTabBehavior::Ignore);
|
||||
}
|
||||
|
||||
if (parser.isSet(ignoreSslErrors)) {
|
||||
options.setIgnoreSslErrors(true);
|
||||
}
|
||||
|
||||
QStringList positional = parser.positionalArguments();
|
||||
if ( positional.length() > 0) {
|
||||
options.setUrl( positional[0 ] );
|
||||
|
|
|
@ -127,6 +127,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
connect(m_web,SIGNAL(loadFinished(bool)),this,SLOT(slotWebLoadFinished(bool)));
|
||||
connect(m_web,SIGNAL(loadProgress(int)),this,SLOT(slotWebLoadProgress(int)));
|
||||
connect(m_web,SIGNAL(urlChanged(const QUrl&)),this,SLOT(slotUrlChanged(const QUrl&)));
|
||||
|
||||
// Ignore SSL errors.
|
||||
|
||||
|
||||
|
@ -180,6 +181,9 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
//QStringList arguments=QCoreApplication::arguments();
|
||||
|
||||
m_web->setPage( new OGWebPage(this));
|
||||
connect(m_web->page(), &QWebEnginePage::certificateError, this, &MainWindow::slotCertificateErrors);
|
||||
|
||||
|
||||
|
||||
OGCommandLineOptions &options = OGCommandLineOptions::getInstance();
|
||||
QUrl url = QUrl(options.getUrl());
|
||||
|
@ -341,6 +345,18 @@ void MainWindow::slotSslErrors(QNetworkReply* reply)
|
|||
reply->ignoreSslErrors();
|
||||
}
|
||||
|
||||
void MainWindow::slotCertificateErrors(const QWebEngineCertificateError &certificateError) {
|
||||
qWarning() << "SSL error:" << certificateError.description();
|
||||
|
||||
OGCommandLineOptions &options = OGCommandLineOptions::getInstance();
|
||||
if (options.getIgnoreSslErrors()) {
|
||||
qInfo() << "Ignoring SSL errors";
|
||||
|
||||
auto mutableError = const_cast<QWebEngineCertificateError&>(certificateError);
|
||||
mutableError.acceptCertificate();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::slotProcessStarted()
|
||||
{
|
||||
startProgressBar();
|
||||
|
|
|
@ -58,6 +58,8 @@ class MainWindow : public QMainWindow
|
|||
void slotWebLoadFinished(bool ok);
|
||||
void slotWebLoadProgress(int progress);
|
||||
void slotSslErrors(QNetworkReply* reply);
|
||||
void slotCertificateErrors(const QWebEngineCertificateError &certificateError);
|
||||
|
||||
|
||||
// Funciones que manejan cada vez que el proceso hace algo
|
||||
void slotProcessStarted();
|
||||
|
|
|
@ -35,6 +35,10 @@ class OGCommandLineOptions {
|
|||
NewTabBehavior getNewTabBehavior() const { return _newTabBehavior; }
|
||||
void setNewTabBehavior(NewTabBehavior nt) { _newTabBehavior = nt; }
|
||||
|
||||
bool getIgnoreSslErrors() const { return _ignoreSslErrors; }
|
||||
void setIgnoreSslErrors(bool value) { _ignoreSslErrors = value; }
|
||||
|
||||
|
||||
private:
|
||||
OGCommandLineOptions() {
|
||||
|
||||
|
@ -42,4 +46,6 @@ private:
|
|||
|
||||
QString _url;
|
||||
NewTabBehavior _newTabBehavior{ReplacePage};
|
||||
|
||||
bool _ignoreSslErrors = false;
|
||||
};
|
Loading…
Reference in New Issue