| 68 | } |
| 69 | |
| 70 | PostgreSQLHandler::PostgreSQLHandler( |
| 71 | const Poco::Net::StreamSocket & socket_, |
| 72 | #if USE_SSL |
| 73 | const std::string & prefix_, |
| 74 | #endif |
| 75 | IServer & server_, |
| 76 | TCPServer & tcp_server_, |
| 77 | bool ssl_enabled_, |
| 78 | bool secure_required_, |
| 79 | Int32 connection_id_, |
| 80 | std::vector<std::shared_ptr<PostgreSQLProtocol::PGAuthentication::AuthenticationMethod>> & auth_methods_, |
| 81 | const ProfileEvents::Event & read_event_, |
| 82 | const ProfileEvents::Event & write_event_) |
| 83 | : Poco::Net::TCPServerConnection(socket_) |
| 84 | #if USE_SSL |
| 85 | , config(server_.config()) |
| 86 | , prefix(prefix_) |
| 87 | #endif |
| 88 | , server(server_) |
| 89 | , tcp_server(tcp_server_) |
| 90 | , ssl_enabled(ssl_enabled_) |
| 91 | , secure_required(secure_required_) |
| 92 | , connection_id(connection_id_) |
| 93 | , read_event(read_event_) |
| 94 | , write_event(write_event_) |
| 95 | , authentication_manager(auth_methods_) |
| 96 | , prepared_statements_manager(std::nullopt) |
| 97 | { |
| 98 | changeIO(socket()); |
| 99 | |
| 100 | #if USE_SSL |
| 101 | params.privateKeyFile = config.getString(prefix + Poco::Net::SSLManager::CFG_PRIV_KEY_FILE, ""); |
| 102 | params.certificateFile = config.getString(prefix + Poco::Net::SSLManager::CFG_CERTIFICATE_FILE, params.privateKeyFile); |
| 103 | if (!params.privateKeyFile.empty() && !params.certificateFile.empty()) |
| 104 | { |
| 105 | params.caLocation = config.getString(prefix + Poco::Net::SSLManager::CFG_CA_LOCATION, ""); |
| 106 | if (params.caLocation.empty()) |
| 107 | { |
| 108 | auto ctx = Poco::Net::SSLManager::instance().defaultServerContext(); |
| 109 | params.caLocation = ctx->getCAPaths().caLocation; |
| 110 | } |
| 111 | |
| 112 | params.verificationMode = Poco::Net::SSLManager::VAL_VER_MODE; |
| 113 | if (config.hasProperty(prefix + Poco::Net::SSLManager::CFG_VER_MODE)) |
| 114 | { |
| 115 | std::string mode = config.getString(prefix + Poco::Net::SSLManager::CFG_VER_MODE); |
| 116 | params.verificationMode = Poco::Net::Utility::convertVerificationMode(mode); |
| 117 | } |
| 118 | |
| 119 | params.verificationDepth = config.getInt(prefix + Poco::Net::SSLManager::CFG_VER_DEPTH, Poco::Net::SSLManager::VAL_VER_DEPTH); |
| 120 | params.loadDefaultCAs |
| 121 | = config.getBool(prefix + Poco::Net::SSLManager::CFG_ENABLE_DEFAULT_CA, Poco::Net::SSLManager::VAL_ENABLE_DEFAULT_CA); |
| 122 | params.cipherList = config.getString(prefix + Poco::Net::SSLManager::CFG_CIPHER_LIST, Poco::Net::SSLManager::VAL_CIPHER_LIST); |
| 123 | params.cipherList |
| 124 | = config.getString(prefix + Poco::Net::SSLManager::CFG_CYPHER_LIST, params.cipherList); // for backwards compatibility |
| 125 | |
| 126 | bool require_tlsv1 = config.getBool(prefix + Poco::Net::SSLManager::CFG_REQUIRE_TLSV1, false); |
| 127 | bool require_tlsv1_1 = config.getBool(prefix + Poco::Net::SSLManager::CFG_REQUIRE_TLSV1_1, false); |
nothing calls this directly
no test coverage detected