Skip to content

Commit

Permalink
DRAFT: hardcoded download test file DO NOT MERGE (#2462)
Browse files Browse the repository at this point in the history
curl: set path to system certificates on Android and enable options "verifypeer" and "followlocation"
  • Loading branch information
rayw-dronesense authored Dec 8, 2024
1 parent c8b7537 commit d3cfea2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/mavsdk/core/curl_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ bool CurlWrapper::download_text(const std::string& url, std::string& content)
curl_easy_setopt(curl.get(), CURLOPT_URL, url.c_str());
curl_easy_setopt(curl.get(), CURLOPT_WRITEFUNCTION, write_callback);
curl_easy_setopt(curl.get(), CURLOPT_WRITEDATA, &readBuffer);
curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYPEER, 1L);
curl_easy_setopt(curl.get(), CURLOPT_FOLLOWLOCATION, 1L);
res = curl_easy_perform(curl.get());
content = readBuffer;

Expand Down Expand Up @@ -108,6 +110,8 @@ bool CurlWrapper::download_file_to_path(
curl_easy_setopt(curl.get(), CURLOPT_WRITEFUNCTION, NULL);
curl_easy_setopt(curl.get(), CURLOPT_WRITEDATA, fp);
curl_easy_setopt(curl.get(), CURLOPT_NOPROGRESS, 0L);
curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYPEER, 1L);
curl_easy_setopt(curl.get(), CURLOPT_FOLLOWLOCATION, 1L);
res = curl_easy_perform(curl.get());
fclose(fp);

Expand Down
7 changes: 5 additions & 2 deletions third_party/curl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ list(APPEND CMAKE_ARGS
"-DCURL_USE_LIBSSH2=OFF"
"-DBUILD_CURL_EXE=OFF"
"-DBUILD_SHARED_LIBS=OFF"
"-DCURL_CA_PATH_SET=OFF"
"-DCURL_ZLIB=OFF"
"-DHTTP_ONLY=ON"
"-DHAVE_POSIX_STRERROR_R=1"
"-DBUILD_TESTING=OFF"
)

if(IOS)
if(ANDROID)
list(APPEND CMAKE_ARGS
"-DCURL_CA_PATH=/system/etc/security/cacerts"
)
elseif(IOS)
list(APPEND CMAKE_ARGS
"-DPLATFORM=${PLATFORM}"
"-DDEPLOYMENT_TARGET=${DEPLOYMENT_TARGET}"
Expand Down

0 comments on commit d3cfea2

Please sign in to comment.