2017-08-06 18:36:14 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <boost/asio.hpp>
|
|
|
|
#include <boost/lexical_cast.hpp>
|
|
|
|
#include <thread>
|
|
|
|
#include <array>
|
|
|
|
#include <iomanip>
|
|
|
|
|
2017-08-06 19:54:41 +00:00
|
|
|
#include <boost/bind.hpp>
|
|
|
|
|
2017-08-07 00:37:08 +00:00
|
|
|
#include <boost/thread.hpp>
|
|
|
|
|
2018-08-25 18:23:54 +00:00
|
|
|
|
2017-08-06 18:36:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-25 19:32:06 +00:00
|
|
|
#include "http/server.hpp"
|
2017-08-06 18:36:14 +00:00
|
|
|
|
2018-08-25 19:32:06 +00:00
|
|
|
int main()
|
2017-08-06 18:36:14 +00:00
|
|
|
{
|
|
|
|
|
2018-08-25 19:32:06 +00:00
|
|
|
try
|
2017-08-06 18:36:14 +00:00
|
|
|
{
|
|
|
|
|
2018-08-25 19:32:06 +00:00
|
|
|
boost::asio::ssl::context sslContext(boost::asio::ssl::context::tls_server);
|
2017-08-07 02:26:32 +00:00
|
|
|
|
2018-08-25 19:32:06 +00:00
|
|
|
SSL_CTX_set_cipher_list(sslContext.native_handle(), "EECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS");
|
2017-08-06 18:36:14 +00:00
|
|
|
|
2018-08-25 19:32:06 +00:00
|
|
|
sslContext.set_options(boost::asio::ssl::context::default_workarounds
|
|
|
|
| boost::asio::ssl::context::verify_none
|
|
|
|
| boost::asio::ssl::context::no_sslv2
|
|
|
|
| boost::asio::ssl::context::no_sslv3
|
|
|
|
| boost::asio::ssl::context::no_tlsv1
|
|
|
|
| boost::asio::ssl::context::single_dh_use
|
|
|
|
);
|
2017-08-06 18:36:14 +00:00
|
|
|
|
2018-08-25 19:32:06 +00:00
|
|
|
std::function<std::string(std::size_t, boost::asio::ssl::context_base::password_purpose)> f = [](std::size_t, boost::asio::ssl::context_base::password_purpose) -> std::string { return ""; };
|
|
|
|
sslContext.set_password_callback(f);
|
2017-08-06 18:36:14 +00:00
|
|
|
|
2018-08-25 19:32:06 +00:00
|
|
|
sslContext.use_certificate_chain_file("server.crt");
|
2017-08-06 18:36:14 +00:00
|
|
|
|
2018-08-25 19:32:06 +00:00
|
|
|
sslContext.use_private_key_file("server.key", boost::asio::ssl::context::pem);
|
2017-08-06 18:36:14 +00:00
|
|
|
|
2018-08-25 19:32:06 +00:00
|
|
|
sslContext.use_tmp_dh_file("dh2048.pem");
|
2018-08-25 18:23:54 +00:00
|
|
|
|
2017-08-06 18:36:14 +00:00
|
|
|
|
2018-08-25 18:23:54 +00:00
|
|
|
// Initialise the server.
|
2018-08-25 19:32:06 +00:00
|
|
|
http::server::server s("0.0.0.0", "8043", "./html/", sslContext);
|
2017-08-06 18:36:14 +00:00
|
|
|
|
2018-08-25 18:23:54 +00:00
|
|
|
// Run the server until stopped.
|
|
|
|
s.run();
|
|
|
|
}
|
|
|
|
catch (std::exception& e)
|
|
|
|
{
|
|
|
|
std::cerr << "exception: " << e.what() << "\n";
|
|
|
|
}
|
2017-08-06 18:36:14 +00:00
|
|
|
|
2018-08-25 18:23:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2017-08-06 19:54:41 +00:00
|
|
|
|
|
|
|
|
2018-08-25 18:23:54 +00:00
|
|
|
|