diff --git a/README b/README index 8351c50b..654e307c 100644 --- a/README +++ b/README @@ -1,7 +1,7 @@ I) DEPENCIES -libboost-dev libextractor-dev libavcodec-dev libwt-dev +libboost-dev libextractor-dev libavcodec-dev libwt-dev libprotobuf-dev libconfig++-dev Warning: your distrib may provide an outdated wt library. Using the latest Wt (>= 3.3.3) is highly recommended (http://www.webtoolkit.eu/wt) @@ -32,7 +32,9 @@ Generate a self signed certificate: IV) RUNNING In the build directory: -# ./lms --docroot=../ui --approot=../ui/approot --https-port=5081 --https-address=0.0.0.0 --ssl-certificate=./certUI.pem --ssl-private-key ./privkeyUI.pem --ssl-tmp-dh dh2048.pem +# ./lms lms.conf + +Create the lms.conf file using the etc/lms.sample.conf Depending of your SSL parameters, you may be asked for the PEM passphrase to unlock the private key. diff --git a/TODO b/TODO index 413bbbb7..c5d8295a 100644 --- a/TODO +++ b/TODO @@ -4,8 +4,6 @@ - Use our own WIOService [Services] -- [UI] generate argc/argv from a config file (crypto, port info, db path) -- [Remote] use config file to get crypto, port info, db path - consider using external web server instead of builtin httpd (new FCGI service?) [Users] diff --git a/config/ConfigReader.cpp b/config/ConfigReader.cpp index a01d01ae..0fc57102 100644 --- a/config/ConfigReader.cpp +++ b/config/ConfigReader.cpp @@ -33,6 +33,9 @@ ConfigReader::getRemoteServerConfig(Service::RemoteServerService::Config& config config.port = static_cast(_config.lookup("remote.listen-endpoint.port")); config.address = boost::asio::ip::address::from_string((const char*)_config.lookup("remote.listen-endpoint.addr")); + config.sslCertificatePath = _config.lookup("remote.ssl-crypto.cert"); + config.sslPrivateKeyPath = _config.lookup("remote.ssl-crypto.key"); + config.sslTempDhPath = _config.lookup("remote.ssl-crypto.dh"); config.dbPath = _config.lookup("main.db"); } diff --git a/etc/lms.conf.sample b/etc/lms.conf.sample index 91bcc974..a0f76963 100644 --- a/etc/lms.conf.sample +++ b/etc/lms.conf.sample @@ -36,9 +36,9 @@ remote = { } ssl-crypto = { - cert = ""; - key = ""; - dh = ""; + cert = "/var/lms/certs/certRemote.pem"; + key = "/var/lms/private/privkeyRemote.pem"; + dh = "/var/lms/dh/dh2048.pem"; } } diff --git a/remote/server/Server.cpp b/remote/server/Server.cpp index 7726629a..84c0aecb 100644 --- a/remote/server/Server.cpp +++ b/remote/server/Server.cpp @@ -9,14 +9,18 @@ namespace Remote { namespace Server { -Server::Server(const endpoint_type& bindEndpoint, boost::filesystem::path dbPath) +Server::Server(const endpoint_type& bindEndpoint, + boost::filesystem::path certPath, + boost::filesystem::path privKeyPath, + boost::filesystem::path dhPath, + boost::filesystem::path dbPath) : _acceptor(_ioService, bindEndpoint, true /*SO_REUSEADDR*/), _connectionManager(), _context(boost::asio::ssl::context::tlsv1_server), _dbPath(dbPath) { - _ioService.setThreadCount(1); + _ioService.setThreadCount(1); // TODO parametrize _context.set_options( boost::asio::ssl::context::default_workarounds // TODO check this thing | boost::asio::ssl::context::single_dh_use @@ -24,9 +28,9 @@ _dbPath(dbPath) | boost::asio::ssl::context::no_sslv3 ); // context_.set_password_callback(boost::bind(&server::get_password, this)); - _context.use_certificate_chain_file("cert.pem"); // TODO parametrize - _context.use_private_key_file("privkey.pem", boost::asio::ssl::context::pem); // TODO parametrize - _context.use_tmp_dh_file("dh2048.pem"); // TODO parametrize + _context.use_certificate_chain_file(certPath.string()); + _context.use_private_key_file(privKeyPath.string(), boost::asio::ssl::context::pem); + _context.use_tmp_dh_file(dhPath.string()); } void diff --git a/remote/server/Server.hpp b/remote/server/Server.hpp index 07634762..4370b0ec 100644 --- a/remote/server/Server.hpp +++ b/remote/server/Server.hpp @@ -26,7 +26,11 @@ class Server typedef boost::asio::ip::tcp::endpoint endpoint_type; // Serve up data from the given database - Server(const endpoint_type& bindEndpoint, boost::filesystem::path dbPath); + Server(const endpoint_type& bindEndpoint, + boost::filesystem::path certPath, + boost::filesystem::path privKeyPath, + boost::filesystem::path dhPath, + boost::filesystem::path dbPath); // Run the server's io_service loop. void start(); diff --git a/service/RemoteServerService.cpp b/service/RemoteServerService.cpp index 313cddd7..f4619eb3 100644 --- a/service/RemoteServerService.cpp +++ b/service/RemoteServerService.cpp @@ -4,7 +4,11 @@ namespace Service { RemoteServerService::RemoteServerService(const Config& config) -: _server(boost::asio::ip::tcp::endpoint(config.address, config.port), config.dbPath) +: _server(boost::asio::ip::tcp::endpoint(config.address, config.port), + config.sslCertificatePath, + config.sslPrivateKeyPath, + config.sslTempDhPath, + config.dbPath) { } diff --git a/service/RemoteServerService.hpp b/service/RemoteServerService.hpp index 3ab0697f..cf550ba6 100644 --- a/service/RemoteServerService.hpp +++ b/service/RemoteServerService.hpp @@ -18,6 +18,9 @@ class RemoteServerService : public Service bool enable; boost::asio::ip::address address; unsigned short port; + boost::filesystem::path sslCertificatePath; + boost::filesystem::path sslPrivateKeyPath; + boost::filesystem::path sslTempDhPath; boost::filesystem::path dbPath; };