Centralize legacy network TLS policy
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "pch.h"
|
||||
#include "log.h"
|
||||
#include "asset.h"
|
||||
#include "platform_api/network_tls_policy.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <Foundation/Foundation.h>
|
||||
@@ -187,9 +188,8 @@ bool Asset::open_url(const std::string& url, std::function<bool(float)> progress
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &tmp_data);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_data_handler_asset);
|
||||
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
|
||||
#ifdef __ANDROID__
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
#endif
|
||||
if (pp::platform::default_disables_network_tls_verification())
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
if (progress)
|
||||
{
|
||||
on_progress = progress;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "pch.h"
|
||||
#include "log.h"
|
||||
#include "app.h"
|
||||
#include "platform_api/network_tls_policy.h"
|
||||
|
||||
LogRemote LogRemote::I;
|
||||
|
||||
@@ -48,9 +49,8 @@ void LogRemote::net_init()
|
||||
//curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_data_handler);
|
||||
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 5L);
|
||||
#ifdef __ANDROID__
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
#endif
|
||||
if (pp::platform::default_disables_network_tls_verification())
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
#endif //CURL
|
||||
}
|
||||
std::string LogRemote::net_request(std::string cmd, std::string data /*= ""*/)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "node_message_box.h"
|
||||
#include "app.h"
|
||||
#include "image.h"
|
||||
#include "platform_api/network_tls_policy.h"
|
||||
|
||||
Node* NodeDialogCloud::clone_instantiate() const
|
||||
{
|
||||
@@ -66,9 +67,8 @@ void NodeDialogCloud::load_thumbs_thread()
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &res);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_data_handler);
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "https://panopainter.com/cloud/cloud-list.php");
|
||||
#ifdef __ANDROID__
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
#endif
|
||||
if (pp::platform::default_disables_network_tls_verification())
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
auto err = curl_easy_perform(curl);
|
||||
|
||||
if (err != CURLE_OK)
|
||||
|
||||
14
src/platform_api/network_tls_policy.cpp
Normal file
14
src/platform_api/network_tls_policy.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "platform_api/network_tls_policy.h"
|
||||
|
||||
namespace pp::platform {
|
||||
|
||||
bool default_disables_network_tls_verification() noexcept
|
||||
{
|
||||
#if defined(__ANDROID__)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
7
src/platform_api/network_tls_policy.h
Normal file
7
src/platform_api/network_tls_policy.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
namespace pp::platform {
|
||||
|
||||
[[nodiscard]] bool default_disables_network_tls_verification() noexcept;
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "app.h"
|
||||
#include "app_core/document_platform_io.h"
|
||||
#include "platform_api/network_tls_policy.h"
|
||||
#include "renderer_gl/opengl_capabilities.h"
|
||||
|
||||
#ifdef __ANDROID__
|
||||
@@ -451,11 +452,7 @@ public:
|
||||
|
||||
[[nodiscard]] bool disables_network_tls_verification() override
|
||||
{
|
||||
#ifdef __ANDROID__
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
return pp::platform::default_disables_network_tls_verification();
|
||||
}
|
||||
|
||||
[[nodiscard]] bool supports_sonarpen() override
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "platform_windows/windows_platform_services.h"
|
||||
|
||||
#include "log.h"
|
||||
#include "platform_api/network_tls_policy.h"
|
||||
#include "renderer_gl/opengl_capabilities.h"
|
||||
|
||||
#include <deque>
|
||||
@@ -460,7 +461,7 @@ public:
|
||||
|
||||
[[nodiscard]] bool disables_network_tls_verification() override
|
||||
{
|
||||
return false;
|
||||
return pp::platform::default_disables_network_tls_verification();
|
||||
}
|
||||
|
||||
[[nodiscard]] bool supports_sonarpen() override
|
||||
|
||||
Reference in New Issue
Block a user