Check if CMake TLS is working
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# curl -O https://gist.github.com/scivision/704fd0c7600266317748e473f7e47062/raw/3bd1a8375e107db9f14660165e107ecd7b27ab42/CheckTLS.cmake | |
# cmake -P CheckTLS.cmake | |
cmake_minimum_required(VERSION 3.20) | |
function(check_tls) | |
# some CMake may not have SSL/TLS enabled, or may have missing/broken system certificates. | |
# this is a publicly-usable service (as per their TOS) | |
set(url https://www.howsmyssl.com/a/check) | |
cmake_path(APPEND temp ${PROJECT_BINARY_DIR} check_tls.json) | |
message(STATUS "CheckTLS: ${url} => ${temp}") | |
file(DOWNLOAD ${url} ${temp} INACTIVITY_TIMEOUT 5) | |
file(READ ${temp} json) | |
string(JSON rating ERROR_VARIABLE e GET ${json} rating) | |
message(STATUS "CMake ${CMAKE_VERSION} TLS status: ${rating}") | |
if(NOT rating STREQUAL "Probably Okay") | |
message(WARNING "TLS seems to be broken. Download will probably fail. ${rating}") | |
endif() | |
endfunction(check_tls) | |
if(CMAKE_SCRIPT_MODE_FILE) | |
check_tls() | |
endif() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment