Skip to content

Commit

Permalink
Enc SSL cert
Browse files Browse the repository at this point in the history
Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma committed Nov 25, 2024
1 parent ef37cc8 commit 9933fdf
Show file tree
Hide file tree
Showing 6 changed files with 545 additions and 389 deletions.
36 changes: 34 additions & 2 deletions client/dialogs/SettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ SettingsDialog::SettingsDialog(int page, QWidget *parent)
ui->txtCdoc2UUID->setReadOnly(disabled);
ui->txtCdoc2Fetch->setReadOnly(disabled);
ui->txtCdoc2Post->setReadOnly(disabled);
ui->wgtCDoc2Cert->setHidden(disabled);
};
for(QJsonObject::const_iterator i = list.constBegin(); i != list.constEnd(); ++i)
ui->cmbCdoc2Name->addItem(i.value().toObject().value(QLatin1String("NAME")).toString(), i.key());
Expand All @@ -234,14 +235,40 @@ SettingsDialog::SettingsDialog(int page, QWidget *parent)
});
setCDoc2Values(cdoc2Service);
connect(ui->txtCdoc2UUID, &QLineEdit::textEdited, this, Settings::CDOC2_UUID);
connect(ui->txtCdoc2Fetch, &QLineEdit::textEdited, this, Settings::CDOC2_GET);
connect(ui->txtCdoc2Post, &QLineEdit::textEdited, this, Settings::CDOC2_POST);
connect(ui->txtCdoc2Fetch, &QLineEdit::textEdited, this, [this](const QString &url) {
Settings::CDOC2_GET = url;
if(url.isEmpty())
{
Settings::CDOC2_GET_CERT.clear();
Settings::CDOC2_POST_CERT.clear();
updateCDoc2Cert(QSslCertificate());
}
});
connect(ui->txtCdoc2Post, &QLineEdit::textEdited, this, [this](const QString &url) {
Settings::CDOC2_POST = url;
if(url.isEmpty())
{
Settings::CDOC2_GET_CERT.clear();
Settings::CDOC2_POST_CERT.clear();
updateCDoc2Cert(QSslCertificate());
}
});
#else
ui->cmbCdoc2Name->addItem(QStringLiteral("Default"));
ui->txtCdoc2UUID->setText(QStringLiteral("00000000-0000-0000-0000-000000000000"));
ui->txtCdoc2Fetch->setText(QStringLiteral(CDOC2_GET_URL));
ui->txtCdoc2Post->setText(QStringLiteral(CDOC2_POST_URL));
#endif
connect(ui->btInstallCDoc2Cert, &QPushButton::clicked, this, [this] {
QSslCertificate cert = selectCert(tr("Select encryption server certificate"),
tr("Encryption Service SSL certificate"));
if(cert.isNull())
return;
Settings::CDOC2_GET_CERT = cert.toDer().toBase64();
Settings::CDOC2_POST_CERT = cert.toDer().toBase64();
updateCDoc2Cert(cert);
});
updateCDoc2Cert(QSslCertificate(QByteArray::fromBase64(Settings::CDOC2_GET_CERT), QSsl::Der));

// pageProxy
connect(this, &SettingsDialog::finished, this, &SettingsDialog::saveProxy);
Expand Down Expand Up @@ -439,6 +466,11 @@ void SettingsDialog::updateCert(const QSslCertificate &c, QPushButton *btn, Cert
});
}

void SettingsDialog::updateCDoc2Cert(const QSslCertificate &c)
{
updateCert(c, ui->btShowCDoc2Cert, ui->txtCDoc2Cert);
}

void SettingsDialog::updateSiVaCert(const QSslCertificate &c)
{
updateCert(c, ui->btShowSiVaCert, ui->txtSiVaCert);
Expand Down
1 change: 1 addition & 0 deletions client/dialogs/SettingsDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class SettingsDialog final: public QDialog
QSslCertificate selectCert(const QString &label, const QString &format);
void selectLanguage();
void updateCert(const QSslCertificate &c, QPushButton *btn, CertLabel *lbl);
void updateCDoc2Cert(const QSslCertificate &c);
void updateSiVaCert(const QSslCertificate &c);
void updateTSACert(const QSslCertificate &c);
void updateVersion();
Expand Down
Loading

0 comments on commit 9933fdf

Please sign in to comment.