Skip to content

Commit

Permalink
macos specific lookup for ca path
Browse files Browse the repository at this point in the history
  • Loading branch information
hafenkran committed Nov 13, 2024
1 parent 3daf510 commit 9eb1c83
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/bigquery_attach.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static unique_ptr<FunctionData> AttachBind(ClientContext &context,
vector<string> &names) {
auto table_string = input.inputs[0].GetValue<string>();
auto dataset_ref = BigqueryUtils::ParseTableString(table_string);
if (dataset_ref.table_id.empty()) {
if (!dataset_ref.table_id.empty()) {
throw ParserException("Invalid attach statement: %s", table_string);
}

Expand Down
16 changes: 14 additions & 2 deletions src/include/bigquery_settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ inline std::string DetectCAPath() {
return std::string(path);
}
}
#elif defined(__APPLE__)
if (const char *ca_path_env = std::getenv("SSL_CERT_FILE"); ca_path_env != nullptr) {
return std::string(ca_path_env);
}
const char *mac_ca_paths[] = {
"/etc/ssl/cert.pem",
"/usr/local/etc/openssl/cert.pem" //
};
for (const char *path : mac_ca_paths) {
if (std::ifstream(path).good()) {
return std::string(path);
}
}
#endif
return ca_path;
}
Expand Down Expand Up @@ -68,8 +81,7 @@ struct BigquerySettings {
curl_ca_bundle_path = DetectCAPath();
}
if (curl_ca_bundle_path.empty()) {
throw BinderException(
"Curl CA bundle path not found. Try setting the 'bq_curl_ca_bundle_path' option.");
throw BinderException("Curl CA bundle path not found. Try setting the 'bq_curl_ca_bundle_path' option.");
}
return curl_ca_bundle_path;
}
Expand Down

0 comments on commit 9eb1c83

Please sign in to comment.