// Copyright © 2013 sss //. // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. //. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. //. // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "headers.h" server::server(boost::asio::io_service& io_service, short port) : io_service_(io_service), acceptor_(io_service, tcp::endpoint(boost::asio::ip::address_v4(), port)), context_(boost::asio::ssl::context::sslv23) { context_.set_options(boost::asio::ssl::context::default_workarounds | boost::asio::ssl::context::no_sslv2); context_.set_password_callback(boost::bind(&server::get_password, this)); context_.use_certificate_chain_file("/etc/restarter_server/serv.crt"); context_.use_rsa_private_key_file("/etc/restarter_server/serv.key", boost::asio::ssl::context::pem); context_.load_verify_file("/etc/restarter_server/ca.crt"); context_.set_verify_mode(boost::asio::ssl::verify_peer | boost::asio::ssl::verify_client_once); start_accept(); } void server::start_accept() { session* new_session = new session(io_service_, context_); acceptor_.async_accept(new_session->socket(), boost::bind(&server::handle_accept, this, new_session, boost::asio::placeholders::error)); } void server::handle_accept(session* new_session, const boost::system::error_code& error) { if (!error) { new_session->start(); } else { delete new_session; } start_accept(); } std::string server::get_password() const //TODO: add key password support { return ""; }