Allow to load/use ECDSA certificate in webUI.

Limit max read size
Improve messages in dialogs
Refactor
This commit is contained in:
Chocobo1 2017-02-16 16:57:48 +08:00
parent 54e99f2510
commit 759bf4d73d
3 changed files with 48 additions and 36 deletions

View file

@ -26,13 +26,14 @@
* exception statement from your version.
*/
#include "base/preferences.h"
#include "base/logger.h"
#include "webui.h"
#include "base/http/server.h"
#include "base/logger.h"
#include "base/net/dnsupdater.h"
#include "base/net/portforwarder.h"
#include "base/preferences.h"
#include "webapplication.h"
#include "webui.h"
WebUI::WebUI(QObject *parent)
: QObject(parent)
@ -65,11 +66,15 @@ void WebUI::init()
#ifndef QT_NO_OPENSSL
if (pref->isWebUiHttpsEnabled()) {
QList<QSslCertificate> certs = QSslCertificate::fromData(pref->getWebUiHttpsCertificate());
QSslKey key;
key = QSslKey(pref->getWebUiHttpsKey(), QSsl::Rsa);
bool certsIsNull = std::any_of(certs.begin(), certs.end(), [](QSslCertificate c) { return c.isNull(); });
if (!certsIsNull && !certs.empty() && !key.isNull())
const QByteArray keyRaw = pref->getWebUiHttpsKey();
QSslKey key(keyRaw, QSsl::Rsa);
if (key.isNull())
key = QSslKey(keyRaw, QSsl::Ec);
const QList<QSslCertificate> certs = QSslCertificate::fromData(pref->getWebUiHttpsCertificate());
const bool areCertsValid = !certs.empty() && std::all_of(certs.begin(), certs.end(), [](QSslCertificate c) { return !c.isNull(); });
if (!key.isNull() && areCertsValid)
httpServer_->enableHttps(certs, key);
else
httpServer_->disableHttps();