Skip to content

Commit

Permalink
fix: return error for bad argument sslmode
Browse files Browse the repository at this point in the history
  • Loading branch information
everpcpc committed Oct 31, 2023
1 parent 8151d51 commit 8c54f07
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ impl ConnectionArgs {
}
}
if self.tls {
query.append_pair("sslmode", "enable");
query.append_pair("sslmode", "require");
} else {
query.append_pair("sslmode", "disable");
}
Expand Down
13 changes: 9 additions & 4 deletions core/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,16 @@ impl APIClient {
"warehouse" => {
client.warehouse = Arc::new(Mutex::new(Some(v.to_string())));
}
"sslmode" => {
if v == "disable" {
scheme = "http";
"sslmode" => match v.as_ref() {
"disable" => scheme = "http",
"require" => scheme = "https",
_ => {
return Err(Error::BadArgument(format!(
"Invalid value for sslmode: {}",
v
)))
}
}
},
"tls_ca_file" => {
client.tls_ca_file = Some(v.to_string());
}
Expand Down
16 changes: 13 additions & 3 deletions driver/src/flight_sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,22 @@ impl Args {
match k.as_ref() {
"tenant" => args.tenant = Some(v.to_string()),
"warehouse" => args.warehouse = Some(v.to_string()),
"sslmode" => {
if v == "disable" {
"sslmode" => match v.as_ref() {
"disable" => {
scheme = "http";
args.tls = false;
}
}
"require" => {
scheme = "https";
args.tls = true;
}
_ => {
return Err(Error::BadArgument(format!(
"Invalid value for sslmode: {}",
v.as_ref()
)))
}
},
"tls_ca_file" => args.tls_ca_file = Some(v.to_string()),
"connect_timeout" => args.connect_timeout = Duration::from_secs(v.parse()?),
"query_timeout" => args.query_timeout = Duration::from_secs(v.parse()?),
Expand Down

0 comments on commit 8c54f07

Please sign in to comment.