Feat: Add SSL support for webserver + websocket (#612)

* Feat: Add SSL support for webserver + websocket

Finally, Hyperion reaches the SSL century!
- Uses by default a internal key and certificate to provide working HTTPS out-of-the-box
- Your browser won't like that, for a green ssl seal next to the browser address bar you need to use Let's Encrypt with a own legit domain. This is out of the scope of Hyperion
This commit is contained in:
brindosch
2019-08-21 16:09:28 +02:00
committed by GitHub
parent fe12b36fce
commit 8e5f3251b5
14 changed files with 268 additions and 12 deletions

View File

@@ -15,11 +15,24 @@ class BonjourServiceRegister;
class StaticFileServing;
class QtHttpServer;
/*
OPENSSL command that generated the embedded key and cert file
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes \
-keyout hyperion.key -out hyperion.crt -extensions san -config \
<(echo "[req]";
echo distinguished_name=req;
echo "[san]";
echo subjectAltName=DNS:hyperion-project.org,IP:127.0.0.1
) \
-subj /CN=hyperion-project.org
*/
class WebServer : public QObject {
Q_OBJECT
public:
WebServer (const QJsonDocument& config, QObject * parent = 0);
WebServer (const QJsonDocument& config, const bool& useSsl, QObject * parent = 0);
virtual ~WebServer (void);
@@ -67,6 +80,7 @@ public slots:
private:
QJsonDocument _config;
bool _useSsl;
Logger* _log;
QString _baseUrl;
quint16 _port;
@@ -74,8 +88,10 @@ private:
QtHttpServer* _server;
bool _inited = false;
const QString WEBSERVER_DEFAULT_PATH = ":/webconfig";
const quint16 WEBSERVER_DEFAULT_PORT = 8090;
const QString WEBSERVER_DEFAULT_PATH = ":/webconfig";
const QString WEBSERVER_DEFAULT_CRT_PATH = ":/hyperion.crt";
const QString WEBSERVER_DEFAULT_KEY_PATH = ":/hyperion.key";
quint16 WEBSERVER_DEFAULT_PORT = 8090;
BonjourServiceRegister * _serviceRegister = nullptr;
};