MXS-2483: Move SSL functionality into SSLProvider

The class is intended to be inherited by objects that need an SSL context
and a configuration. In practice this will be servers and listeners.

The SSLContext is stored in a rworker_local shared_ptr that makes it
possible to update safely. As the copying is always done behind a lock the
cached local value always holds a valid SSLContext instance for the
duration of all function calls.

Using the pImpl idiom, the routingworker.hh header is not exposed in the
ssl.hh header. This allows the SSLProvider class to be inherited more
easily.
This commit is contained in:
Markus Mäkelä
2019-05-21 11:15:36 +03:00
parent 8a4b58d52c
commit cb72b2a5cc
2 changed files with 82 additions and 1 deletions

View File

@ -58,6 +58,9 @@ ssl_method_type_t string_to_ssl_method_type(const char* str);
extern const MXS_ENUM_VALUE ssl_version_values[];
// The concrete implementation of the SSLProvider class (hides the dependency on routingworker.hh)
class SSLProviderImp;
namespace maxscale
{
@ -134,4 +137,19 @@ private:
SSLContext(const SSLConfig& cfg);
bool init();
};
// A SSL connection provider (incoming or outgoing). Used by servers and listeners.
class SSLProvider
{
public:
const mxs::SSLConfig& config() const;
mxs::SSLContext* context() const;
void set_context(std::unique_ptr<mxs::SSLContext> ssl);
SSLProvider(std::unique_ptr<mxs::SSLContext>&& context);
~SSLProvider();
private:
std::unique_ptr<SSLProviderImp> m_imp;
};
}