2019-03-16 02:08:21 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-09-11 11:21:54 +00:00
|
|
|
#include <Common/config.h>
|
2019-10-05 19:25:31 +00:00
|
|
|
#if USE_POCO_NETSSL && USE_SSL
|
2019-09-11 11:21:54 +00:00
|
|
|
|
2019-03-16 02:08:21 +00:00
|
|
|
#include <Poco/Net/TCPServerConnectionFactory.h>
|
2019-05-26 06:52:29 +00:00
|
|
|
#include <atomic>
|
|
|
|
#include <openssl/rsa.h>
|
2019-03-16 02:08:21 +00:00
|
|
|
#include "IServer.h"
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2019-04-29 06:37:39 +00:00
|
|
|
class MySQLHandlerFactory : public Poco::Net::TCPServerConnectionFactory
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
IServer & server;
|
|
|
|
Poco::Logger * log;
|
|
|
|
|
2019-05-26 19:30:23 +00:00
|
|
|
struct RSADeleter
|
|
|
|
{
|
2019-05-26 06:52:29 +00:00
|
|
|
void operator()(RSA * ptr) { RSA_free(ptr); }
|
|
|
|
};
|
|
|
|
using RSAPtr = std::unique_ptr<RSA, RSADeleter>;
|
2019-04-22 10:57:50 +00:00
|
|
|
|
2019-05-26 06:52:29 +00:00
|
|
|
RSAPtr public_key;
|
|
|
|
RSAPtr private_key;
|
2019-03-16 02:08:21 +00:00
|
|
|
|
2019-05-26 06:52:29 +00:00
|
|
|
bool ssl_enabled = true;
|
2019-04-22 10:57:50 +00:00
|
|
|
|
2019-05-26 06:52:29 +00:00
|
|
|
std::atomic<size_t> last_connection_id = 0;
|
|
|
|
public:
|
|
|
|
explicit MySQLHandlerFactory(IServer & server_);
|
2019-04-29 06:37:39 +00:00
|
|
|
|
2019-05-26 06:52:29 +00:00
|
|
|
void readRSAKeys();
|
2019-04-29 06:37:39 +00:00
|
|
|
|
2019-05-26 06:52:29 +00:00
|
|
|
void generateRSAKeys();
|
2019-04-29 06:37:39 +00:00
|
|
|
|
2019-05-26 06:52:29 +00:00
|
|
|
Poco::Net::TCPServerConnection * createConnection(const Poco::Net::StreamSocket & socket) override;
|
2019-04-29 06:37:39 +00:00
|
|
|
};
|
2019-03-16 02:08:21 +00:00
|
|
|
|
|
|
|
}
|
2019-09-11 11:21:54 +00:00
|
|
|
#endif
|