1 #include <websocketpp/common/connection_hdl.hpp>
12 const std::string& name,
const std::function<
void(
WebSocketLogLevel,
char const*)>& logHandler,
15 return std::make_unique<foxglove::Server<foxglove::WebSocketTls>>(name, logHandler, options);
17 return std::make_unique<foxglove::Server<foxglove::WebSocketNoTls>>(name, logHandler, options);
23 _server.get_alog().write(
APP,
"Server running without TLS");
28 _server.set_tls_init_handler([
this](
ConnHandle hdl) {
31 namespace asio = websocketpp::lib::asio;
32 auto ctx = websocketpp::lib::make_shared<asio::ssl::context>(asio::ssl::context::sslv23);
35 ctx->set_options(asio::ssl::context::default_workarounds | asio::ssl::context::no_tlsv1 |
36 asio::ssl::context::no_sslv2 | asio::ssl::context::no_sslv3);
37 ctx->use_certificate_chain_file(_options.certfile);
38 ctx->use_private_key_file(_options.keyfile, asio::ssl::context::pem);
42 constexpr
char ciphers[] =
43 "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:"
44 "ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+"
45 "AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-"
46 "AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-"
47 "ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-"
48 "AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:"
51 if (SSL_CTX_set_cipher_list(ctx->native_handle(), ciphers) != 1) {
52 _server.get_elog().write(
RECOVERABLE,
"Error setting cipher list");
54 }
catch (
const std::exception& ex) {
56 std::string(
"Exception in TLS handshake: ") + ex.what());