Route app network TLS policy through platform services
This commit is contained in:
15
src/app.cpp
15
src/app.cpp
@@ -298,9 +298,8 @@ void App::download(std::string url, std::string dest_filepath, std::function<voi
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_data_write);
|
||||
#ifdef __ANDROID__
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
#endif
|
||||
if (disables_network_tls_verification())
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
if (progress)
|
||||
{
|
||||
curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, progress_callback_download);
|
||||
@@ -334,9 +333,8 @@ bool App::check_license()
|
||||
//curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_data_handler);
|
||||
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 2L);
|
||||
#ifdef __ANDROID__
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
#endif
|
||||
if (disables_network_tls_verification())
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
|
||||
auto err = curl_easy_perform(curl);
|
||||
curl_easy_cleanup(curl);
|
||||
@@ -375,9 +373,8 @@ void App::upload(std::string filename, std::string name, std::function<void(floa
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &res);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_data_handler);
|
||||
#ifdef __ANDROID__
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
#endif
|
||||
if (disables_network_tls_verification())
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
if (progress)
|
||||
{
|
||||
curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, progress_callback_upload);
|
||||
|
||||
@@ -186,6 +186,7 @@ public:
|
||||
void pick_file_save(std::vector<std::string> types, std::function<void(std::string path)> callback);
|
||||
[[nodiscard]] bool uses_prepared_file_writes() const;
|
||||
[[nodiscard]] bool uses_work_directory_document_export_collections() const;
|
||||
[[nodiscard]] bool disables_network_tls_verification() const;
|
||||
void pick_dir(std::function<void(std::string path)> callback);
|
||||
void display_file(std::string path);
|
||||
void share_file(std::string path);
|
||||
|
||||
@@ -191,6 +191,11 @@ bool App::uses_work_directory_document_export_collections() const
|
||||
return active_platform_services().uses_work_directory_document_export_collections();
|
||||
}
|
||||
|
||||
bool App::disables_network_tls_verification() const
|
||||
{
|
||||
return active_platform_services().disables_network_tls_verification();
|
||||
}
|
||||
|
||||
void App::pick_dir(std::function<void(std::string path)> callback)
|
||||
{
|
||||
redraw = true;
|
||||
|
||||
@@ -65,6 +65,7 @@ public:
|
||||
virtual void pick_directory(PickedPathCallback callback) = 0;
|
||||
[[nodiscard]] virtual bool uses_prepared_file_writes() = 0;
|
||||
[[nodiscard]] virtual bool uses_work_directory_document_export_collections() = 0;
|
||||
[[nodiscard]] virtual bool disables_network_tls_verification() = 0;
|
||||
[[nodiscard]] virtual PreparedFileTarget prepare_writable_file(
|
||||
std::string_view type,
|
||||
std::string_view default_name,
|
||||
|
||||
@@ -449,6 +449,15 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
[[nodiscard]] bool disables_network_tls_verification() override
|
||||
{
|
||||
#ifdef __ANDROID__
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
[[nodiscard]] pp::platform::PreparedFileTarget prepare_writable_file(
|
||||
std::string_view type,
|
||||
std::string_view default_name,
|
||||
|
||||
@@ -458,6 +458,11 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool disables_network_tls_verification() override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
[[nodiscard]] pp::platform::PreparedFileTarget prepare_writable_file(
|
||||
std::string_view type,
|
||||
std::string_view default_name,
|
||||
|
||||
Reference in New Issue
Block a user