aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFelix (xq) Queißner <git@mq32.de>2020-06-20 00:17:05 +0200
committerFelix (xq) Queißner <git@mq32.de>2020-06-20 00:17:05 +0200
commit07bc3475f893430a59f91f65ea50d87ba21b5854 (patch)
treec86518df1b239ee4810c654d1049d4bfc52cb41d /src
parentefab40bf8d0fc71237bb80d4a786bcd6b1752d72 (diff)
downloadkristall-07bc3475f893430a59f91f65ea50d87ba21b5854.tar.gz
Patches by @tomasino, starts to implement the auto-enable/host filter feature for client certificates.
Diffstat (limited to 'src')
-rw-r--r--src/certificatemanagementdialog.cpp24
-rw-r--r--src/certificatemanagementdialog.hpp5
-rw-r--r--src/certificatemanagementdialog.ui32
-rw-r--r--src/cryptoidentity.hpp7
-rw-r--r--src/identitycollection.cpp7
-rw-r--r--src/settingsdialog.cpp2
-rw-r--r--src/ssltrust.cpp1
-rw-r--r--src/trustedhostcollection.cpp2
8 files changed, 75 insertions, 5 deletions
diff --git a/src/certificatemanagementdialog.cpp b/src/certificatemanagementdialog.cpp
index a14a9a4..9b8b095 100644
--- a/src/certificatemanagementdialog.cpp
+++ b/src/certificatemanagementdialog.cpp
@@ -53,6 +53,10 @@ void CertificateManagementDialog::on_certificates_selected(QModelIndex const& in
);
this->ui->cert_notes->setPlainText(cert.user_notes);
+ this->ui->cert_host_filter->setText(cert.host_filter);
+ this->ui->cert_auto_enable->setEnabled(not cert.host_filter.isEmpty());
+ this->ui->cert_auto_enable->setChecked(cert.auto_enable);
+
this->ui->delete_cert_button->setEnabled(true);
}
else
@@ -63,6 +67,8 @@ void CertificateManagementDialog::on_certificates_selected(QModelIndex const& in
this->ui->cert_expiration_date->setDateTime(QDateTime { });
this->ui->cert_livetime->setText("");
this->ui->cert_fingerprint->setPlainText("");
+ this->ui->cert_host_filter->setText("");
+ this->ui->cert_auto_enable->setChecked(false);
if(auto group_name = global_identities.group(index); not group_name.isEmpty()) {
this->ui->delete_cert_button->setEnabled(global_identities.canDeleteGroup(group_name));
@@ -150,3 +156,21 @@ void CertificateManagementDialog::on_create_cert_button_clicked()
dialog.groupName(),
id);
}
+
+void CertificateManagementDialog::on_cert_host_filter_textChanged(const QString &host_filter)
+{
+ if(this->selected_identity != nullptr) {
+ this->ui->cert_auto_enable->setEnabled(not host_filter.isEmpty());
+ this->selected_identity->host_filter = host_filter;
+ } else {
+ this->ui->cert_auto_enable->setEnabled(false);
+ }
+
+}
+
+void CertificateManagementDialog::on_cert_auto_enable_clicked(bool checked)
+{
+ if(this->selected_identity != nullptr) {
+ this->selected_identity->auto_enable = checked;
+ }
+}
diff --git a/src/certificatemanagementdialog.hpp b/src/certificatemanagementdialog.hpp
index b66b9cc..0d7178a 100644
--- a/src/certificatemanagementdialog.hpp
+++ b/src/certificatemanagementdialog.hpp
@@ -29,6 +29,11 @@ private slots:
void on_import_cert_button_clicked();
void on_create_cert_button_clicked();
+
+ void on_cert_host_filter_textChanged(const QString &arg1);
+
+ void on_cert_auto_enable_clicked(bool checked);
+
private:
void on_certificates_selected(const QModelIndex &index, QModelIndex const & previous);
private:
diff --git a/src/certificatemanagementdialog.ui b/src/certificatemanagementdialog.ui
index b4282f9..da17691 100644
--- a/src/certificatemanagementdialog.ui
+++ b/src/certificatemanagementdialog.ui
@@ -182,30 +182,54 @@
</property>
</widget>
</item>
- <item row="4" column="0">
+ <item row="6" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Fingerprint</string>
</property>
</widget>
</item>
- <item row="5" column="0">
+ <item row="7" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Notes</string>
</property>
</widget>
</item>
- <item row="4" column="1">
+ <item row="6" column="1">
<widget class="QPlainTextEdit" name="cert_fingerprint">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
- <item row="5" column="1">
+ <item row="7" column="1">
<widget class="QPlainTextEdit" name="cert_notes"/>
</item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>Host Filter</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QLineEdit" name="cert_host_filter">
+ <property name="placeholderText">
+ <string>gemini://*</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1">
+ <widget class="QCheckBox" name="cert_auto_enable">
+ <property name="toolTip">
+ <string>If this is checked, Kristall will automatically enable this certificate when visiting a URL matching the host filter</string>
+ </property>
+ <property name="text">
+ <string>Auto-Enable Certificate</string>
+ </property>
+ </widget>
+ </item>
</layout>
</item>
</layout>
diff --git a/src/cryptoidentity.hpp b/src/cryptoidentity.hpp
index 09e9489..b693427 100644
--- a/src/cryptoidentity.hpp
+++ b/src/cryptoidentity.hpp
@@ -25,6 +25,13 @@ struct CryptoIdentity
//! True for long-lived identities
bool is_persistent = false;
+ //! If not empty, Kristall will check
+ QString host_filter = "";
+
+ //! When this is set to true and the host_filter is not empty,
+ //! the certificate will be automatically enabled for hosts matching the filter.
+ bool auto_enable = false;
+
bool isValid() const {
return (not this->certificate.isNull()) and (not this->private_key.isNull());
}
diff --git a/src/identitycollection.cpp b/src/identitycollection.cpp
index 1cb55e8..2590cdf 100644
--- a/src/identitycollection.cpp
+++ b/src/identitycollection.cpp
@@ -35,6 +35,9 @@ void IdentityCollection::load(QSettings &settings)
id->identity.display_name = settings.value("display_name").toString();
id->identity.user_notes = settings.value("user_notes").toString();
+ id->identity.host_filter = settings.value("host_filter", "").toString();
+ id->identity.auto_enable = settings.value("auto_enable", false).toBool();
+
id->identity.certificate = QSslCertificate::fromData(
settings.value("certificate").toByteArray(),
QSsl::Der
@@ -87,8 +90,10 @@ void IdentityCollection::save(QSettings &settings) const
settings.setValue("user_notes", id.identity.user_notes);
settings.setValue("certificate", id.identity.certificate.toDer());
settings.setValue("private_key", id.identity.private_key.toDer());
- }
+ settings.setValue("host_filter", id.identity.host_filter);
+ settings.setValue("auto_enable", id.identity.auto_enable);
+ }
settings.endArray();
}
diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp
index d1c61c8..3c7f9d4 100644
--- a/src/settingsdialog.cpp
+++ b/src/settingsdialog.cpp
@@ -9,6 +9,8 @@
#include <QMessageBox>
#include <QDebug>
+#include <cassert>
+
#include "kristall.hpp"
SettingsDialog::SettingsDialog(QWidget *parent) :
diff --git a/src/ssltrust.cpp b/src/ssltrust.cpp
index c5b7895..bbbc360 100644
--- a/src/ssltrust.cpp
+++ b/src/ssltrust.cpp
@@ -1,6 +1,7 @@
#include "ssltrust.hpp"
#include <QDebug>
+#include <cassert>
void SslTrust::load(QSettings &settings)
{
diff --git a/src/trustedhostcollection.cpp b/src/trustedhostcollection.cpp
index ae8a929..57a45df 100644
--- a/src/trustedhostcollection.cpp
+++ b/src/trustedhostcollection.cpp
@@ -1,5 +1,7 @@
#include "trustedhostcollection.hpp"
+#include <cassert>
+
TrustedHostCollection::TrustedHostCollection(QObject *parent)
: QAbstractTableModel(parent)
{