Seastar
High performance C++ framework for concurrent servers
|
Public Types | |
using | connection = seastar::httpd::connection |
using | server_credentials_ptr = shared_ptr< seastar::tls::server_credentials > |
Public Member Functions | |
http_server (const sstring &name) | |
void | set_tls_credentials (server_credentials_ptr credentials) |
set tls credentials for the server Setting the tls credentials will set the http-server to work in https mode. More... | |
size_t | get_content_length_limit () const |
void | set_content_length_limit (size_t limit) |
bool | get_content_streaming () const |
void | set_content_streaming (bool b) |
future | listen (socket_address addr, server_credentials_ptr credentials) |
future | listen (socket_address addr, listen_options lo, server_credentials_ptr credentials) |
future | listen (socket_address addr, listen_options lo) |
future | listen (socket_address addr) |
future | stop () |
future | do_accepts (int which) |
future | do_accepts (int which, bool with_tls) |
uint64_t | total_connections () const |
uint64_t | current_connections () const |
uint64_t | requests_served () const |
uint64_t | read_errors () const |
uint64_t | reply_errors () const |
Static Public Member Functions | |
static sstring | http_date () |
Public Attributes | |
routes | _routes |
void seastar::httpd::http_server::set_tls_credentials | ( | server_credentials_ptr | credentials | ) |
set tls credentials for the server Setting the tls credentials will set the http-server to work in https mode.
To use the https, create server credentials and pass it to the server before it starts.
Use case example using seastar threads for clarity:
distributed<http_server> server; // typical server
seastar::shared_ptr<seastar::tls::credentials_builder> creds = seastar::make_shared<seastar::tls::credentials_builder>(); sstring ms_cert = "MyCertificate.crt"; sstring ms_key = "MyKey.key";
creds->set_dh_level(seastar::tls::dh_params::level::MEDIUM);
creds->set_x509_key_file(ms_cert, ms_key, seastar::tls::x509_crt_format::PEM).get(); creds->set_system_trust().get();
server.invoke_on_all([creds](http_server& server) { server.set_tls_credentials(creds->build_server_credentials()); return make_ready_future<>(); }).get();