2018-06-20 23:44:47 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace communication {
|
|
|
|
|
|
|
|
/**
|
2020-10-20 18:55:13 +08:00
|
|
|
* Create this object in each `main` file that uses the Communication stack. It
|
2018-06-20 23:44:47 +08:00
|
|
|
* is used to initialize all libraries (primarily OpenSSL) and to fix some
|
|
|
|
* issues also related to OpenSSL (handling of SIGPIPE).
|
|
|
|
*
|
2020-10-20 18:55:13 +08:00
|
|
|
* We define a struct to take advantage of RAII so that the proper cleanup
|
|
|
|
* is called after we are finished using the SSL connection.
|
|
|
|
*
|
2018-06-20 23:44:47 +08:00
|
|
|
* Description of OpenSSL init can be seen here:
|
|
|
|
* https://wiki.openssl.org/index.php/Library_Initialization
|
|
|
|
*
|
2020-10-20 18:55:13 +08:00
|
|
|
* NOTE: This object must be created **exactly** once.
|
2018-06-20 23:44:47 +08:00
|
|
|
*/
|
2020-10-20 18:55:13 +08:00
|
|
|
struct SSLInit {
|
|
|
|
SSLInit();
|
|
|
|
|
|
|
|
SSLInit(const SSLInit &) = delete;
|
|
|
|
SSLInit(SSLInit &&) = delete;
|
|
|
|
SSLInit &operator=(const SSLInit &) = delete;
|
|
|
|
SSLInit &operator=(SSLInit &&) = delete;
|
|
|
|
~SSLInit();
|
|
|
|
};
|
|
|
|
|
2018-06-20 23:44:47 +08:00
|
|
|
} // namespace communication
|