| 17 | { |
| 18 | |
| 19 | MySQLHandlerFactory::MySQLHandlerFactory(IServer & server_, bool secure_required_, const ProfileEvents::Event & read_event_, const ProfileEvents::Event & write_event_) |
| 20 | : server(server_) |
| 21 | , log(getLogger("MySQLHandlerFactory")) |
| 22 | #if USE_SSL |
| 23 | , keypair(KeyPair::generateRSA()) |
| 24 | #endif |
| 25 | , secure_required(secure_required_) |
| 26 | , read_event(read_event_) |
| 27 | , write_event(write_event_) |
| 28 | { |
| 29 | #if USE_SSL |
| 30 | try |
| 31 | { |
| 32 | Poco::Net::SSLManager::instance().defaultServerContext(); |
| 33 | } |
| 34 | catch (...) |
| 35 | { |
| 36 | LOG_TRACE(log, "Failed to create SSL context. SSL will be disabled. Error: {}", getCurrentExceptionMessage(false)); |
| 37 | ssl_enabled = false; |
| 38 | } |
| 39 | |
| 40 | /// Reading RSA keys for SHA256 authentication plugin. |
| 41 | try |
| 42 | { |
| 43 | const Poco::Util::LayeredConfiguration & config = Poco::Util::Application::instance().config(); |
| 44 | |
| 45 | String private_key_file_property = "openSSL.server.privateKeyFile"; |
| 46 | String private_key_file = config.getString(private_key_file_property); |
| 47 | |
| 48 | keypair = KeyPair::fromFile(private_key_file); |
| 49 | } |
| 50 | catch (...) |
| 51 | { |
| 52 | LOG_TRACE(log, "Failed to read RSA key pair from server certificate. Error: {}", getCurrentExceptionMessage(false)); |
| 53 | LOG_TRACE(log, "Generating new RSA key pair."); |
| 54 | |
| 55 | keypair = KeyPair::generateRSA(); |
| 56 | } |
| 57 | #endif |
| 58 | } |
| 59 | |
| 60 | Poco::Net::TCPServerConnection * MySQLHandlerFactory::createConnectionImpl(const Poco::Net::StreamSocket & socket, TCPServer & tcp_server) |
| 61 | { |
nothing calls this directly
no test coverage detected