1 #include <websocketpp/common/connection_hdl.hpp> 5 #define ASIO_STANDALONE 14 const std::string& name,
const std::function<
void(
WebSocketLogLevel,
char const*)>& logHandler,
17 return std::make_unique<foxglove::Server<foxglove::WebSocketTls>>(name, logHandler, options);
19 return std::make_unique<foxglove::Server<foxglove::WebSocketNoTls>>(name, logHandler, options);
25 _server.get_alog().write(
APP,
"Server running without TLS");
30 _server.set_tls_init_handler([
this](
ConnHandle hdl) {
33 namespace asio = websocketpp::lib::asio;
34 auto ctx = websocketpp::lib::make_shared<asio::ssl::context>(asio::ssl::context::sslv23);
37 ctx->set_options(asio::ssl::context::default_workarounds | asio::ssl::context::no_tlsv1 |
38 asio::ssl::context::no_sslv2 | asio::ssl::context::no_sslv3);
39 ctx->use_certificate_chain_file(_options.certfile);
40 ctx->use_private_key_file(_options.keyfile, asio::ssl::context::pem);
44 constexpr
char ciphers[] =
45 "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:" 46 "ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+" 47 "AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-" 48 "AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-" 49 "ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-" 50 "AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:" 53 if (SSL_CTX_set_cipher_list(ctx->native_handle(), ciphers) != 1) {
54 _server.get_elog().write(
RECOVERABLE,
"Error setting cipher list");
56 }
catch (
const std::exception& ex) {
58 std::string(
"Exception in TLS handshake: ") + ex.what());
static const websocketpp::log::level APP
static std::unique_ptr< ServerInterface< ConnectionHandle > > createServer(const std::string &name, const std::function< void(WebSocketLogLevel, char const *)> &logHandler, const ServerOptions &options)
static const websocketpp::log::level RECOVERABLE
websocketpp::connection_hdl ConnHandle