From 4ae3a4e3cdcbffb77b4a329c70e6e8071cb4b161 Mon Sep 17 00:00:00 2001 From: "Felix (xq) Queißner" Date: Fri, 19 Jun 2020 21:24:16 +0200 Subject: Fixes bug in client certificate handling --- README.md | 1 - src/browsertab.cpp | 32 +++++++++++++++----------------- src/browsertab.hpp | 2 ++ 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 94b60a5..f2d611f 100644 --- a/README.md +++ b/README.md @@ -152,7 +152,6 @@ ln -s /path/to/kristall . - [ ] Rename/delete/merge groups - [ ] Import/export PEM certificates and keys - [ ] Add a "scope" option to certificates so users can restrict the scope where the certificate is valid -- Fix bug: Somehow auto-disable of client-cert doesn't work ### 0.4 - The colorful release - [ ] Implement dual-colored icon theme diff --git a/src/browsertab.cpp b/src/browsertab.cpp index eb34ae3..1c0a99b 100644 --- a/src/browsertab.cpp +++ b/src/browsertab.cpp @@ -763,10 +763,7 @@ bool BrowserTab::trySetClientCertificate(const QString &query) if (dialog.exec() != QDialog::Accepted) { - for(auto & handler : this->protocol_handlers) { - handler->disableClientCertificate(); - } - this->ui->enable_client_cert_button->setChecked(false); + this->disableClientCertificate(); return false; } @@ -775,7 +772,7 @@ bool BrowserTab::trySetClientCertificate(const QString &query) if (not current_identitiy.isValid()) { QMessageBox::warning(this, "Kristall", "Failed to generate temporary crypto-identitiy"); - this->ui->enable_client_cert_button->setChecked(false); + this->disableClientCertificate(); return false; } @@ -796,12 +793,7 @@ void BrowserTab::resetClientCertificate() } } - this->current_identitiy = CryptoIdentity(); - - for(auto & handler : this->protocol_handlers) { - handler->disableClientCertificate(); - } - this->ui->enable_client_cert_button->setChecked(false); + this->disableClientCertificate(); } void BrowserTab::addProtocolHandler(std::unique_ptr &&handler) @@ -838,12 +830,10 @@ bool BrowserTab::startRequest(const QUrl &url, ProtocolHandler::RequestOptions o ); if(answer != QMessageBox::Yes) return false; - this->current_handler->disableClientCertificate(); - this->ui->enable_client_cert_button->setChecked(false); + this->disableClientCertificate(); } } else { - this->current_handler->disableClientCertificate(); - this->ui->enable_client_cert_button->setChecked(false); + this->disableClientCertificate(); } if(this->current_identitiy.isValid() and (url.host() != this->current_location.host())) { @@ -855,8 +845,7 @@ bool BrowserTab::startRequest(const QUrl &url, ProtocolHandler::RequestOptions o QMessageBox::No ); if(answer != QMessageBox::Yes) { - this->current_handler->disableClientCertificate(); - this->ui->enable_client_cert_button->setChecked(false); + this->disableClientCertificate(); } } @@ -869,6 +858,15 @@ bool BrowserTab::startRequest(const QUrl &url, ProtocolHandler::RequestOptions o return this->current_handler->startRequest(url, options); } +void BrowserTab::disableClientCertificate() +{ + for(auto & handler : this->protocol_handlers) { + handler->disableClientCertificate(); + } + this->ui->enable_client_cert_button->setChecked(false); + this->current_identitiy = CryptoIdentity(); +} + void BrowserTab::on_text_browser_customContextMenuRequested(const QPoint &pos) { QMenu menu; diff --git a/src/browsertab.hpp b/src/browsertab.hpp index 41126f2..e06a7d8 100644 --- a/src/browsertab.hpp +++ b/src/browsertab.hpp @@ -128,6 +128,8 @@ private: } bool startRequest(QUrl const & url, ProtocolHandler::RequestOptions options); + + void disableClientCertificate(); public: Ui::BrowserTab *ui; -- cgit v1.2.3