|
|
@ -975,8 +975,8 @@ void OptionsDialog::loadOptions() |
|
|
|
m_ui->spinWebUiPort->setValue(pref->getWebUiPort()); |
|
|
|
m_ui->spinWebUiPort->setValue(pref->getWebUiPort()); |
|
|
|
m_ui->checkWebUIUPnP->setChecked(pref->useUPnPForWebUIPort()); |
|
|
|
m_ui->checkWebUIUPnP->setChecked(pref->useUPnPForWebUIPort()); |
|
|
|
m_ui->checkWebUiHttps->setChecked(pref->isWebUiHttpsEnabled()); |
|
|
|
m_ui->checkWebUiHttps->setChecked(pref->isWebUiHttpsEnabled()); |
|
|
|
setSslCertificate(pref->getWebUiHttpsCertificate(), false); |
|
|
|
setSslCertificate(pref->getWebUiHttpsCertificate()); |
|
|
|
setSslKey(pref->getWebUiHttpsKey(), false); |
|
|
|
setSslKey(pref->getWebUiHttpsKey()); |
|
|
|
m_ui->textWebUiUsername->setText(pref->getWebUiUsername()); |
|
|
|
m_ui->textWebUiUsername->setText(pref->getWebUiUsername()); |
|
|
|
m_ui->textWebUiPassword->setText(pref->getWebUiPassword()); |
|
|
|
m_ui->textWebUiPassword->setText(pref->getWebUiPassword()); |
|
|
|
m_ui->checkBypassLocalAuth->setChecked(!pref->isWebUiLocalAuthEnabled()); |
|
|
|
m_ui->checkBypassLocalAuth->setChecked(!pref->isWebUiLocalAuthEnabled()); |
|
|
@ -1508,26 +1508,32 @@ void OptionsDialog::showConnectionTab() |
|
|
|
|
|
|
|
|
|
|
|
void OptionsDialog::on_btnWebUiCrt_clicked() |
|
|
|
void OptionsDialog::on_btnWebUiCrt_clicked() |
|
|
|
{ |
|
|
|
{ |
|
|
|
QString filename = QFileDialog::getOpenFileName(this, QString(), QString(), tr("SSL Certificate") + QString(" (*.crt *.pem)")); |
|
|
|
const QString filename = QFileDialog::getOpenFileName(this, tr("Import SSL certificate"), QString(), tr("SSL Certificate") + QLatin1String(" (*.crt *.pem)")); |
|
|
|
if (filename.isNull()) |
|
|
|
if (filename.isEmpty()) |
|
|
|
return; |
|
|
|
return; |
|
|
|
QFile file(filename); |
|
|
|
|
|
|
|
if (file.open(QIODevice::ReadOnly)) { |
|
|
|
QFile cert(filename); |
|
|
|
setSslCertificate(file.readAll()); |
|
|
|
if (!cert.open(QIODevice::ReadOnly)) |
|
|
|
file.close(); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool success = setSslCertificate(cert.read(1024 * 1024)); |
|
|
|
|
|
|
|
if (!success) |
|
|
|
|
|
|
|
QMessageBox::warning(this, tr("Invalid certificate"), tr("This is not a valid SSL certificate.")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void OptionsDialog::on_btnWebUiKey_clicked() |
|
|
|
void OptionsDialog::on_btnWebUiKey_clicked() |
|
|
|
{ |
|
|
|
{ |
|
|
|
QString filename = QFileDialog::getOpenFileName(this, QString(), QString(), tr("SSL Key") + QString(" (*.key *.pem)")); |
|
|
|
const QString filename = QFileDialog::getOpenFileName(this, tr("Import SSL key"), QString(), tr("SSL key") + QLatin1String(" (*.key *.pem)")); |
|
|
|
if (filename.isNull()) |
|
|
|
if (filename.isEmpty()) |
|
|
|
return; |
|
|
|
return; |
|
|
|
QFile file(filename); |
|
|
|
|
|
|
|
if (file.open(QIODevice::ReadOnly)) { |
|
|
|
QFile key(filename); |
|
|
|
setSslKey(file.readAll()); |
|
|
|
if (!key.open(QIODevice::ReadOnly)) |
|
|
|
file.close(); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool success = setSslKey(key.read(1024 * 1024)); |
|
|
|
|
|
|
|
if (!success) |
|
|
|
|
|
|
|
QMessageBox::warning(this, tr("Invalid key"), tr("This is not a valid SSL key.")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void OptionsDialog::on_registerDNSBtn_clicked() |
|
|
|
void OptionsDialog::on_registerDNSBtn_clicked() |
|
|
@ -1635,41 +1641,42 @@ QString OptionsDialog::languageToLocalizedString(const QLocale &locale) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void OptionsDialog::setSslKey(const QByteArray &key, bool interactive) |
|
|
|
bool OptionsDialog::setSslKey(const QByteArray &key) |
|
|
|
{ |
|
|
|
{ |
|
|
|
#ifndef QT_NO_OPENSSL |
|
|
|
#ifndef QT_NO_OPENSSL |
|
|
|
if (!key.isEmpty() && !QSslKey(key, QSsl::Rsa).isNull()) { |
|
|
|
// try different formats
|
|
|
|
|
|
|
|
const bool isKeyValid = (!QSslKey(key, QSsl::Rsa).isNull() || !QSslKey(key, QSsl::Ec).isNull()); |
|
|
|
|
|
|
|
if (isKeyValid) { |
|
|
|
m_ui->lblSslKeyStatus->setPixmap(QPixmap(":/icons/qbt-theme/security-high.png").scaledToHeight(20, Qt::SmoothTransformation)); |
|
|
|
m_ui->lblSslKeyStatus->setPixmap(QPixmap(":/icons/qbt-theme/security-high.png").scaledToHeight(20, Qt::SmoothTransformation)); |
|
|
|
m_sslKey = key; |
|
|
|
m_sslKey = key; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
m_ui->lblSslKeyStatus->setPixmap(QPixmap(":/icons/qbt-theme/security-low.png").scaledToHeight(20, Qt::SmoothTransformation)); |
|
|
|
m_ui->lblSslKeyStatus->setPixmap(QPixmap(":/icons/qbt-theme/security-low.png").scaledToHeight(20, Qt::SmoothTransformation)); |
|
|
|
m_sslKey.clear(); |
|
|
|
m_sslKey.clear(); |
|
|
|
if (interactive) |
|
|
|
|
|
|
|
QMessageBox::warning(this, tr("Invalid key"), tr("This is not a valid SSL key.")); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return isKeyValid; |
|
|
|
#else |
|
|
|
#else |
|
|
|
Q_UNUSED(key); |
|
|
|
Q_UNUSED(key); |
|
|
|
Q_UNUSED(interactive); |
|
|
|
return false; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void OptionsDialog::setSslCertificate(const QByteArray &cert, bool interactive) |
|
|
|
bool OptionsDialog::setSslCertificate(const QByteArray &cert) |
|
|
|
{ |
|
|
|
{ |
|
|
|
#ifndef QT_NO_OPENSSL |
|
|
|
#ifndef QT_NO_OPENSSL |
|
|
|
if (!cert.isEmpty() && !QSslCertificate(cert).isNull()) { |
|
|
|
const bool isCertValid = !QSslCertificate(cert).isNull(); |
|
|
|
|
|
|
|
if (isCertValid) { |
|
|
|
m_ui->lblSslCertStatus->setPixmap(QPixmap(":/icons/qbt-theme/security-high.png").scaledToHeight(20, Qt::SmoothTransformation)); |
|
|
|
m_ui->lblSslCertStatus->setPixmap(QPixmap(":/icons/qbt-theme/security-high.png").scaledToHeight(20, Qt::SmoothTransformation)); |
|
|
|
m_sslCert = cert; |
|
|
|
m_sslCert = cert; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
m_ui->lblSslCertStatus->setPixmap(QPixmap(":/icons/qbt-theme/security-low.png").scaledToHeight(20, Qt::SmoothTransformation)); |
|
|
|
m_ui->lblSslCertStatus->setPixmap(QPixmap(":/icons/qbt-theme/security-low.png").scaledToHeight(20, Qt::SmoothTransformation)); |
|
|
|
m_sslCert.clear(); |
|
|
|
m_sslCert.clear(); |
|
|
|
if (interactive) |
|
|
|
|
|
|
|
QMessageBox::warning(this, tr("Invalid certificate"), tr("This is not a valid SSL certificate.")); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return isCertValid; |
|
|
|
#else |
|
|
|
#else |
|
|
|
Q_UNUSED(cert); |
|
|
|
Q_UNUSED(cert); |
|
|
|
Q_UNUSED(interactive); |
|
|
|
return false; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|