Skip to content

Commit

Permalink
Fix HTTPS support on Linux systems.
Browse files Browse the repository at this point in the history
  • Loading branch information
KrzaQ committed May 16, 2023
1 parent cf1d16e commit 031c47b
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 24 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ jobs:
- name: CMake
run: |
mkdir cbuild
cmake -S . -B cbuild/ -DBUILD_EXAMPLES=TRUE -G "${{ matrix.generator }}"
cmake -S . -B cbuild/ -DCRASHPAD_BUILD_EXAMPLES=TRUE -G "${{ matrix.generator }}"
cmake --build cbuild/
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.1'
Expand All @@ -53,7 +53,7 @@ jobs:
- name: Crashpad distribution ZIP
run: |
ruby backtrace/save_artifacts.rb --output Crashpad_Linux_build.zip
- uses: actions/upload-artifact@v3
with:
name: Crashpad_Linux_build_${{ github.sha }}
Expand Down Expand Up @@ -88,7 +88,7 @@ jobs:
# run CMake (additional options like -DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE are possible)
# it is recommended to specify the compiler version used for the build
cmake -S . -B cbuild/ -DBUILD_EXAMPLES=TRUE -G "${{ matrix.generator }}" -DCMAKE_CXX_COMPILER=cl.exe -DCMAKE_C_COMPILER=cl.exe
cmake -S . -B cbuild/ -DCRASHPAD_BUILD_EXAMPLES=TRUE -G "${{ matrix.generator }}" -DCMAKE_CXX_COMPILER=cl.exe -DCMAKE_C_COMPILER=cl.exe
cmake --build cbuild/
- uses: ruby/setup-ruby@v1
Expand All @@ -105,7 +105,7 @@ jobs:
- name: Crashpad distribution ZIP
run: |
ruby backtrace/save_artifacts.rb --output Crashpad_Windows_build.zip
- uses: actions/upload-artifact@v3
with:
name: Crashpad_Windows_build_${{ github.sha }}
Expand All @@ -131,7 +131,7 @@ jobs:
- name: CMake
run: |
mkdir cbuild
cmake -S . -B cbuild/ -DBUILD_EXAMPLES=TRUE -DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} -G "${{ matrix.generator }}"
cmake -S . -B cbuild/ -DCRASHPAD_BUILD_EXAMPLES=TRUE -DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} -G "${{ matrix.generator }}"
cmake --build cbuild/
- uses: ruby/setup-ruby@v1
Expand All @@ -150,7 +150,7 @@ jobs:
- name: Crashpad distribution ZIP
run: |
ruby backtrace/save_artifacts.rb --output Crashpad_MacOs_build_${{ matrix.arch }}.zip
- uses: actions/upload-artifact@v3
with:
name: Crashpad_MacOs_build_${{ matrix.arch }}_${{ github.sha }}
Expand Down Expand Up @@ -198,13 +198,13 @@ jobs:
- name: CMake
run: |
mkdir cbuild
cmake -S . -B cbuild/ -DCMAKE_TOOLCHAIN_FILE=$ANDROID_HOME/ndk/${{ matrix.ndk }}/build/cmake/android.toolchain.cmake -DANDROID_ABI=${{ matrix.abi }} -DANDROID_PLATFORM=android-${{ matrix.apiLevel }} -DANDROID_NATIVE_API_LEVEL=${{ matrix.apiLevel }} -DANDROID_TOOLCHAIN=clang -DANDROID_SSL_MODE=${{ env.SSL_MODE }} -DBUILD_EXAMPLES=TRUE
cmake -S . -B cbuild/ -DCMAKE_TOOLCHAIN_FILE=$ANDROID_HOME/ndk/${{ matrix.ndk }}/build/cmake/android.toolchain.cmake -DANDROID_ABI=${{ matrix.abi }} -DANDROID_PLATFORM=android-${{ matrix.apiLevel }} -DANDROID_NATIVE_API_LEVEL=${{ matrix.apiLevel }} -DANDROID_TOOLCHAIN=clang -DCRASHPAD_HTTPS_TRANSPORT=${{ env.SSL_MODE }} -DCRASHPAD_BUILD_EXAMPLES=TRUE
cmake --build cbuild/
- name: Crashpad distribution ZIP
run: |
ruby backtrace/save_artifacts.rb --output Crashpad_Android_ndk${{ matrix.ndk }}_apiLevel${{ matrix.apiLevel }}_${{ matrix.abi }}_build.zip
- uses: actions/upload-artifact@v3
with:
name: Crashpad_Android_ndk${{ matrix.ndk }}_apiLevel${{ matrix.apiLevel }}_${{ matrix.abi }}_build_${{ github.sha }}
Expand Down
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ target_compile_definitions(backtrace_common INTERFACE
CRASHPAD_LSS_SOURCE_EMBEDDED)

if (ANDROID)
option(ANDROID_SSL_MODE "Android SSL mode" "OPENSSL")
if (ANDROID_SSL_MODE STREQUAL "OPENSSL")
option(CRASHPAD_HTTPS_TRANSPORT "Crashpad HTTPS transport" "OPENSSL")
if (CRASHPAD_HTTPS_TRANSPORT STREQUAL "OPENSSL")
add_subdirectory(third_party/openssl-android-binary)
endif()
elseif (APPLE)
Expand All @@ -70,6 +70,6 @@ add_subdirectory(client)
add_subdirectory(handler)
add_subdirectory(tools)

if (BUILD_EXAMPLES)
if (CRASHPAD_BUILD_EXAMPLES)
add_subdirectory(examples)
endif (BUILD_EXAMPLES)
endif (CRASHPAD_BUILD_EXAMPLES)
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ export GTEST=${NDK}/sources/third_party/googletest
export API_VERSION=21
# other supported are: armeabi-v7a, x86_64. x86 (32-bit) is NOT supported
export ABI=arm64-v8a
# use OPENSSL or NONE
export HTTPS_TRANSPORT=OPENSSL
```

Build:
Expand Down
56 changes: 45 additions & 11 deletions util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ if (LINUX)
./misc/capture_context_linux.S
./misc/paths_linux.cc
./misc/time_linux.cc
./net/http_transport_socket.cc
./posix/process_info_linux.cc
./posix/scoped_mmap.cc
./process/process_memory_linux.cc
Expand Down Expand Up @@ -309,6 +308,35 @@ if (WIN32)
endif ()
endif (WIN32)

if (LINUX)
if (NOT DEFINED CRASHPAD_HTTPS_TRANSPORT)
if (OPENSSL_FOUND)
set(CRASHPAD_HTTPS_TRANSPORT "OPENSSL" CACHE STRING "HTTPS transport to use")
else ()
set(CRASHPAD_HTTPS_TRANSPORT "CURL" CACHE STRING "HTTPS transport to use")
endif ()
endif (NOT DEFINED CRASHPAD_HTTPS_TRANSPORT)

if (CRASHPAD_HTTPS_TRANSPORT STREQUAL "OPENSSL")
message (STATUS "Using OpenSSL for HTTPS transport")
list(APPEND CRASHPAD_UTIL_LIBRARY_FILES
./net/http_transport_socket.cc
)
elseif (CRASHPAD_HTTPS_TRANSPORT STREQUAL "CURL")
message (STATUS "Using libcurl for HTTPS transport")
list(APPEND CRASHPAD_UTIL_LIBRARY_FILES
./net/http_transport_libcurl.cc
)
elseif (CRASHPAD_HTTPS_TRANSPORT STREQUAL "NONE")
message (STATUS "HTTPS transport disabled (HTTP only)")
list(APPEND CRASHPAD_UTIL_LIBRARY_FILES
./net/http_transport_socket.cc
)
else ()
message(FATAL_ERROR "Unknown HTTPS transport: ${CRASHPAD_HTTPS_TRANSPORT}")
endif ()
endif (LINUX)

if (ANDROID)
list(APPEND CRASHPAD_UTIL_LIBRARY_FILES
./backtrace/android_cert_store.cc
Expand Down Expand Up @@ -367,12 +395,19 @@ if (APPLE)
target_link_libraries(util PUBLIC bsm)
endif (APPLE)

if (ANDROID)
if (ANDROID_SSL_MODE STREQUAL "OPENSSL")

if (CRASHPAD_HTTPS_TRANSPORT STREQUAL "OPENSSL")
if (NOT ANDROID)
find_package(OpenSSL REQUIRED)
target_compile_definitions(util PUBLIC CRASHPAD_USE_BORINGSSL)
target_link_libraries(util PUBLIC OpenSSL::SSL OpenSSL::Crypto)
else()
target_link_libraries(util PUBLIC openssl-android-binary)
elseif(ANDROID_SSL_MODE STREQUAL "NONE")
endif ()
endif (ANDROID)
target_compile_definitions(util PUBLIC CRASHPAD_USE_BORINGSSL)
endif()
elseif (CRASHPAD_HTTPS_TRANSPORT STREQUAL "CURL")
target_link_libraries(util PUBLIC CURL::libcurl)
endif ()

if (UNIX)
target_link_libraries(util PUBLIC dl)
Expand All @@ -399,12 +434,11 @@ else ()
endif ()

if (ANDROID)
if (ANDROID_SSL_MODE STREQUAL "OPENSSL")
target_link_libraries(util PUBLIC openssl-android-binary)
target_compile_definitions(util PUBLIC CRASHPAD_USE_BORINGSSL)
elseif(ANDROID_SSL_MODE STREQUAL "NONE")
if (CRASHPAD_HTTPS_TRANSPORT STREQUAL "OPENSSL")
# handled above
elseif(CRASHPAD_HTTPS_TRANSPORT STREQUAL "NONE")
else()
message(FATAL_ERROR "Unknown value for ANDROID_SSL_MODE: ${ANDROID_SSL_MODE}")
message(FATAL_ERROR "Unknown value for CRASHPAD_HTTPS_TRANSPORT: ${CRASHPAD_HTTPS_TRANSPORT}")
endif ()
endif (ANDROID)

Expand Down

0 comments on commit 031c47b

Please sign in to comment.