feat: add ClickHouse TLS connection support
This commit is contained in:
1 parent
5fae9808a2
commit
fe2ecd60d2
14 files changed
+219
-11
No files matched your search
@@ -150,6 +150,7 @@ mod tests {
|
||||
proxy_username: String::new(),
|
||||
proxy_password: String::new(),
|
||||
ssl: false,
|
||||
ca_cert_path: String::new(),
|
||||
sysdba: false,
|
||||
oracle_connection_type: None,
|
||||
connection_string: Some(
|
||||
@@ -282,7 +283,12 @@ pub async fn test_connection(state: State<'_, Arc<AppState>>, config: Connection
|
||||
DatabaseType::ClickHouse => {
|
||||
let username = if config.username.is_empty() { None } else { Some(config.username.clone()) };
|
||||
let password = if config.password.is_empty() { None } else { Some(config.password.clone()) };
|
||||
let client = db::clickhouse_driver::ChClient::new(&url, username, password);
|
||||
let client = db::clickhouse_driver::ChClient::new_with_ca_cert(
|
||||
&url,
|
||||
username,
|
||||
password,
|
||||
Some(&config.ca_cert_path),
|
||||
)?;
|
||||
db::clickhouse_driver::test_connection(&client).await.map(|_| "Connection successful".to_string())
|
||||
}
|
||||
DatabaseType::SqlServer => {
|
||||
@@ -390,7 +396,12 @@ pub async fn connect_db(state: State<'_, Arc<AppState>>, config: ConnectionConfi
|
||||
let username = if db_config.username.is_empty() { None } else { Some(db_config.username.clone()) };
|
||||
let password = if db_config.password.is_empty() { None } else { Some(db_config.password.clone()) };
|
||||
log::info!("[connect_db] ClickHouse url={url} user={:?} has_pass={}", username, password.is_some());
|
||||
let client = db::clickhouse_driver::ChClient::new(&url, username, password);
|
||||
let client = db::clickhouse_driver::ChClient::new_with_ca_cert(
|
||||
&url,
|
||||
username,
|
||||
password,
|
||||
Some(&db_config.ca_cert_path),
|
||||
)?;
|
||||
db::clickhouse_driver::test_connection(&client).await?;
|
||||
PoolKind::ClickHouse(client)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user