summaryrefslogtreecommitdiffstats
path: root/src/Core
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2008-09-06 03:15:06 +0200
committerMatthias Schiffer <matthias@gamezock.de>2008-09-06 03:15:06 +0200
commit7d5b81e9936b1c778fd6408f3f22478e9ab9486b (patch)
tree671e3f323d7298a5a0887302d6f1a397f5e0c1cd /src/Core
parentb961ec7011bb50785dbbc271592b84f3ebae6432 (diff)
downloadmad-7d5b81e9936b1c778fd6408f3f22478e9ab9486b.tar
mad-7d5b81e9936b1c778fd6408f3f22478e9ab9486b.zip
X.509-basierte TLS-Verbindung funktioniert
Diffstat (limited to 'src/Core')
-rw-r--r--src/Core/ConfigManager.cpp16
-rw-r--r--src/Core/ConfigManager.h9
-rw-r--r--src/Core/ConnectionManager.cpp9
-rw-r--r--src/Core/ConnectionManager.h4
4 files changed, 29 insertions, 9 deletions
diff --git a/src/Core/ConfigManager.cpp b/src/Core/ConfigManager.cpp
index b4c81bc..5f40afd 100644
--- a/src/Core/ConfigManager.cpp
+++ b/src/Core/ConfigManager.cpp
@@ -42,6 +42,18 @@ bool ConfigManager::parseLine(const std::vector<std::string> &section, const std
// TODO Logging
}
}
+ else if(Common::Util::tolower(key) == "x509trustfile") {
+ x509TrustFile = value;
+ }
+ else if(Common::Util::tolower(key) == "x509crlfile") {
+ x509CrlFile = value;
+ }
+ else if(Common::Util::tolower(key) == "x509certfile") {
+ x509CertFile = value;
+ }
+ else if(Common::Util::tolower(key) == "x509keyfile") {
+ x509KeyFile = value;
+ }
else {
// TODO Logging
@@ -71,9 +83,5 @@ ConfigManager::ConfigManager() {
loadFile("mad-core.conf");
}
-ConfigManager::~ConfigManager() {
- // TODO Auto-generated destructor stub
-}
-
}
}
diff --git a/src/Core/ConfigManager.h b/src/Core/ConfigManager.h
index 6a5cf2c..3b23750 100644
--- a/src/Core/ConfigManager.h
+++ b/src/Core/ConfigManager.h
@@ -24,6 +24,7 @@
#include <Common/ConfigManager.h>
#include <Net/IPAddress.h>
#include <vector>
+#include <string>
namespace Mad {
namespace Core {
@@ -39,15 +40,21 @@ class ConfigManager : public Common::ConfigManager {
std::vector<Net::IPAddress> listeners;
std::vector<DaemonInfo> daemons;
+ std::string x509TrustFile, x509CrlFile, x509CertFile, x509KeyFile;
+
protected:
virtual bool parseLine(const std::vector<std::string> &section, const std::string &key, const std::string &value);
public:
ConfigManager();
- virtual ~ConfigManager();
const std::vector<Net::IPAddress>& getListenerAddresses() const {return listeners;}
const std::vector<DaemonInfo>& getDaemonList() const {return daemons;}
+
+ const std::string& getX509TrustFile() const {return x509TrustFile;}
+ const std::string& getX509CrlFile() const {return x509CrlFile;}
+ const std::string& getX509CertFile() const {return x509CertFile;}
+ const std::string& getX509KeyFile() const {return x509KeyFile;}
};
}
diff --git a/src/Core/ConnectionManager.cpp b/src/Core/ConnectionManager.cpp
index b1cfd40..a537539 100644
--- a/src/Core/ConnectionManager.cpp
+++ b/src/Core/ConnectionManager.cpp
@@ -18,6 +18,7 @@
*/
#include "ConnectionManager.h"
+#include "ConfigManager.h"
#include "RequestHandler/CertificateRequestHandler.h"
#include <Net/ServerConnection.h>
#include <Net/Packet.h>
@@ -51,12 +52,14 @@ void ConnectionManager::refreshPollfds() {
}
}
-ConnectionManager::ConnectionManager(const std::vector<Net::IPAddress> &listenerAddresses) : requestManager(true) {
+ConnectionManager::ConnectionManager(const ConfigManager& configManager) : requestManager(true) {
requestManager.registerPacketType<RequestHandler::CertificateRequestHandler>(Net::Packet::TYPE_CERT_REQ);
+ const std::vector<Net::IPAddress> &listenerAddresses = configManager.getListenerAddresses();
+
if(listenerAddresses.empty()) {
try {
- listeners.push_back(new Net::Listener());
+ listeners.push_back(new Net::Listener(configManager.getX509CertFile(), configManager.getX509KeyFile()));
}
catch(Net::Exception &e) {
// TODO: Log error
@@ -65,7 +68,7 @@ ConnectionManager::ConnectionManager(const std::vector<Net::IPAddress> &listener
else {
for(std::vector<Net::IPAddress>::const_iterator address = listenerAddresses.begin(); address != listenerAddresses.end(); ++address) {
try {
- listeners.push_back(new Net::Listener(*address));
+ listeners.push_back(new Net::Listener(configManager.getX509CertFile(), configManager.getX509KeyFile(), *address));
}
catch(Net::Exception &e) {
// TODO: Log error
diff --git a/src/Core/ConnectionManager.h b/src/Core/ConnectionManager.h
index 54d5d5e..7429a44 100644
--- a/src/Core/ConnectionManager.h
+++ b/src/Core/ConnectionManager.h
@@ -37,6 +37,8 @@ class Packet;
namespace Core {
+class ConfigManager;
+
class ConnectionManager {
private:
// Prevent shallow copy
@@ -56,7 +58,7 @@ class ConnectionManager {
void refreshPollfds();
public:
- ConnectionManager(const std::vector<Net::IPAddress> &listenerAddresses);
+ ConnectionManager(const ConfigManager& configManager);
virtual ~ConnectionManager();
bool wait(int timeout) {