mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-24 23:18:46 +02:00
setup the domain-server HTTPS server
This commit is contained in:
parent
260966915a
commit
96de0c1af1
4 changed files with 25 additions and 6 deletions
|
@ -55,7 +55,7 @@ DomainServer::DomainServer(int argc, char* argv[]) :
|
||||||
|
|
||||||
_argumentVariantMap = HifiConfigVariantMap::mergeCLParametersWithJSONConfig(arguments());
|
_argumentVariantMap = HifiConfigVariantMap::mergeCLParametersWithJSONConfig(arguments());
|
||||||
|
|
||||||
if (optionallySetupDTLS()) {
|
if (optionallySetupTLS()) {
|
||||||
// we either read a certificate and private key or were not passed one, good to load assignments
|
// we either read a certificate and private key or were not passed one, good to load assignments
|
||||||
// and set up the node list
|
// and set up the node list
|
||||||
qDebug() << "Setting up LimitedNodeList and assignments.";
|
qDebug() << "Setting up LimitedNodeList and assignments.";
|
||||||
|
@ -88,7 +88,7 @@ DomainServer::~DomainServer() {
|
||||||
gnutls_global_deinit();
|
gnutls_global_deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DomainServer::optionallySetupDTLS() {
|
bool DomainServer::optionallySetupTLS() {
|
||||||
if (readX509KeyAndCertificate()) {
|
if (readX509KeyAndCertificate()) {
|
||||||
if (_x509Credentials) {
|
if (_x509Credentials) {
|
||||||
qDebug() << "Generating Diffie-Hellman parameters.";
|
qDebug() << "Generating Diffie-Hellman parameters.";
|
||||||
|
@ -159,6 +159,22 @@ bool DomainServer::readX509KeyAndCertificate() {
|
||||||
|
|
||||||
qDebug() << "Successfully read certificate and private key.";
|
qDebug() << "Successfully read certificate and private key.";
|
||||||
|
|
||||||
|
// we need to also pass this certificate and private key to the HTTPS manager
|
||||||
|
// this is used for Oauth callbacks when authorizing users against a data server
|
||||||
|
|
||||||
|
QFile certFile(certPath);
|
||||||
|
certFile.open(QIODevice::ReadOnly);
|
||||||
|
|
||||||
|
QFile keyFile(keyPath);
|
||||||
|
keyFile.open(QIODevice::ReadOnly);
|
||||||
|
|
||||||
|
QSslCertificate sslCertificate(&certFile);
|
||||||
|
QSslKey privateKey(&keyFile, QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey, keyPassphraseString.toUtf8());
|
||||||
|
|
||||||
|
_httpsManager = new HTTPSManager(DOMAIN_SERVER_HTTPS_PORT, sslCertificate, privateKey, QString(), this, this);
|
||||||
|
|
||||||
|
qDebug() << "TCP server listening for HTTPS connections on" << DOMAIN_SERVER_HTTPS_PORT;
|
||||||
|
|
||||||
} else if (!certPath.isEmpty() || !keyPath.isEmpty()) {
|
} else if (!certPath.isEmpty() || !keyPath.isEmpty()) {
|
||||||
qDebug() << "Missing certificate or private key. domain-server will now quit.";
|
qDebug() << "Missing certificate or private key. domain-server will now quit.";
|
||||||
QMetaObject::invokeMethod(this, "quit", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(this, "quit", Qt::QueuedConnection);
|
||||||
|
|
|
@ -53,7 +53,7 @@ private slots:
|
||||||
void readAvailableDTLSDatagrams();
|
void readAvailableDTLSDatagrams();
|
||||||
private:
|
private:
|
||||||
void setupNodeListAndAssignments(const QUuid& sessionUUID = QUuid::createUuid());
|
void setupNodeListAndAssignments(const QUuid& sessionUUID = QUuid::createUuid());
|
||||||
bool optionallySetupDTLS();
|
bool optionallySetupTLS();
|
||||||
bool readX509KeyAndCertificate();
|
bool readX509KeyAndCertificate();
|
||||||
|
|
||||||
void processDatagram(const QByteArray& receivedPacket, const HifiSockAddr& senderSockAddr);
|
void processDatagram(const QByteArray& receivedPacket, const HifiSockAddr& senderSockAddr);
|
||||||
|
|
|
@ -15,10 +15,11 @@
|
||||||
|
|
||||||
#include "HTTPSManager.h"
|
#include "HTTPSManager.h"
|
||||||
|
|
||||||
HTTPSManager::HTTPSManager(quint16 port, const QString& documentRoot, HTTPRequestHandler* requestHandler, QObject* parent) :
|
HTTPSManager::HTTPSManager(quint16 port, const QSslCertificate& certificate, const QSslKey& privateKey,
|
||||||
|
const QString& documentRoot, HTTPRequestHandler* requestHandler, QObject* parent) :
|
||||||
HTTPManager(port, documentRoot, requestHandler, parent),
|
HTTPManager(port, documentRoot, requestHandler, parent),
|
||||||
_certificate(),
|
_certificate(certificate),
|
||||||
_privateKey()
|
_privateKey(privateKey)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,8 @@ class HTTPSManager : public HTTPManager {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
HTTPSManager(quint16 port,
|
HTTPSManager(quint16 port,
|
||||||
|
const QSslCertificate& certificate,
|
||||||
|
const QSslKey& privateKey,
|
||||||
const QString& documentRoot,
|
const QString& documentRoot,
|
||||||
HTTPRequestHandler* requestHandler = NULL, QObject* parent = 0);
|
HTTPRequestHandler* requestHandler = NULL, QObject* parent = 0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue