summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-05-02 23:46:06 +0200
committermadmaxoft <github@xoft.cz>2014-05-02 23:46:32 +0200
commit3942ebdcb6e62d8b2fb85fad9144a993a78477a6 (patch)
tree458ff43d704800175e1b0e1ef766946664025522
parentMade the cert generation script executable on Linux (diff)
downloadcuberite-3942ebdcb6e62d8b2fb85fad9144a993a78477a6.tar
cuberite-3942ebdcb6e62d8b2fb85fad9144a993a78477a6.tar.gz
cuberite-3942ebdcb6e62d8b2fb85fad9144a993a78477a6.tar.bz2
cuberite-3942ebdcb6e62d8b2fb85fad9144a993a78477a6.tar.lz
cuberite-3942ebdcb6e62d8b2fb85fad9144a993a78477a6.tar.xz
cuberite-3942ebdcb6e62d8b2fb85fad9144a993a78477a6.tar.zst
cuberite-3942ebdcb6e62d8b2fb85fad9144a993a78477a6.zip
-rw-r--r--src/HTTPServer/HTTPServer.cpp49
1 files changed, 31 insertions, 18 deletions
diff --git a/src/HTTPServer/HTTPServer.cpp b/src/HTTPServer/HTTPServer.cpp
index c45044c66..b78a538a2 100644
--- a/src/HTTPServer/HTTPServer.cpp
+++ b/src/HTTPServer/HTTPServer.cpp
@@ -126,6 +126,24 @@ cHTTPServer::cHTTPServer(void) :
m_ListenThreadIPv6(*this, cSocket::IPv6, "WebServer IPv6"),
m_Callbacks(NULL)
{
+}
+
+
+
+
+
+cHTTPServer::~cHTTPServer()
+{
+ Stop();
+}
+
+
+
+
+
+bool cHTTPServer::Initialize(const AString & a_PortsIPv4, const AString & a_PortsIPv6)
+{
+ // Read the HTTPS cert + key:
AString CertFile = cFile::ReadWholeFile("webadmin/httpscert.crt");
AString KeyFile = cFile::ReadWholeFile("webadmin/httpskey.pem");
if (!CertFile.empty() && !KeyFile.empty())
@@ -139,32 +157,27 @@ cHTTPServer::cHTTPServer(void) :
if (res2 != 0)
{
// Reading the private key failed, reset the cert:
- LOGWARNING("WebAdmin: Cannot read HTTPS certificate private key: -0x%x", -res2);
+ LOGWARNING("WebServer: Cannot read HTTPS certificate private key: -0x%x", -res2);
m_Cert.reset();
}
}
else
{
- LOGWARNING("WebAdmin: Cannot read HTTPS certificate: -0x%x", -res);
+ LOGWARNING("WebServer: Cannot read HTTPS certificate: -0x%x", -res);
}
}
-}
-
-
-
-
-cHTTPServer::~cHTTPServer()
-{
- Stop();
-}
-
-
-
-
-
-bool cHTTPServer::Initialize(const AString & a_PortsIPv4, const AString & a_PortsIPv6)
-{
+ // Notify the admin about the HTTPS / HTTP status
+ if (m_Cert.get() == NULL)
+ {
+ LOGWARNING("WebServer: The server is running in unsecure HTTP mode.");
+ }
+ else
+ {
+ LOGINFO("WebServer: The server is running in secure HTTPS mode.");
+ }
+
+ // Open up requested ports:
bool HasAnyPort;
HasAnyPort = m_ListenThreadIPv4.Initialize(a_PortsIPv4);
HasAnyPort = m_ListenThreadIPv6.Initialize(a_PortsIPv6) || HasAnyPort;