Makes credentials based on the server config.
| 178 | |
| 179 | /// Makes credentials based on the server config. |
| 180 | std::shared_ptr<grpc::ServerCredentials> makeCredentials(const Poco::Util::AbstractConfiguration & config) |
| 181 | { |
| 182 | if (config.getBool("grpc.enable_ssl", false)) |
| 183 | { |
| 184 | #if USE_SSL |
| 185 | grpc::SslServerCredentialsOptions options; |
| 186 | grpc::SslServerCredentialsOptions::PemKeyCertPair key_cert_pair; |
| 187 | key_cert_pair.private_key = readFile(config.getString("grpc.ssl_key_file")); |
| 188 | key_cert_pair.cert_chain = readFile(config.getString("grpc.ssl_cert_file")); |
| 189 | options.pem_key_cert_pairs.emplace_back(std::move(key_cert_pair)); |
| 190 | if (config.getBool("grpc.ssl_require_client_auth", false)) |
| 191 | { |
| 192 | options.client_certificate_request = GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY; |
| 193 | if (config.has("grpc.ssl_ca_cert_file")) |
| 194 | options.pem_root_certs = readFile(config.getString("grpc.ssl_ca_cert_file")); |
| 195 | } |
| 196 | return grpc::SslServerCredentials(options); |
| 197 | #else |
| 198 | throw DB::Exception(DB::ErrorCodes::SUPPORT_IS_DISABLED, "Can't use SSL in grpc, because ClickHouse was built without SSL library"); |
| 199 | #endif |
| 200 | } |
| 201 | return grpc::InsecureServerCredentials(); |
| 202 | } |
| 203 | |
| 204 | /// Transport compression makes gRPC library to compress packed Result messages before sending them through network. |
| 205 | struct TransportCompression |