file(DOWNLOAD|UPLOAD): Add test covering CMAKE_TLS_VERIFY cmake variable

This commit is contained in:
Brad King
2024-03-29 12:41:10 -04:00
parent 93886f5c7d
commit 8b0169fe2b
2 changed files with 28 additions and 7 deletions

View File

@@ -1 +1,5 @@
-- (60;"SSL peer certificate or SSH remote key was not OK"|35;"SSL connect error")
-- def-0: 0;"No error"
-- var-0: 0;"No error"
-- var-1: (60;"SSL peer certificate or SSH remote key was not OK"|35;"SSL connect error")
-- opt-0: 0;"No error"
-- opt-1: (60;"SSL peer certificate or SSH remote key was not OK"|35;"SSL connect error")

View File

@@ -1,6 +1,23 @@
file(DOWNLOAD https://expired.badssl.com TLS_VERIFY 1 STATUS status LOG log)
message(STATUS "${status}")
list(GET status 0 code)
if(NOT code MATCHES "^(35|60)$")
message("${log}")
endif()
function(download case)
file(DOWNLOAD https://expired.badssl.com ${ARGN} STATUS status LOG log)
message(STATUS "${case}: ${status}")
if(case MATCHES "1$" AND NOT status MATCHES "^(35|60);")
message("${log}")
endif()
endfunction()
# The default is OFF.
unset(CMAKE_TLS_VERIFY)
download(def-0)
# The cmake variable overrides the default.
set(CMAKE_TLS_VERIFY 0)
download(var-0)
set(CMAKE_TLS_VERIFY 1)
download(var-1)
# The explicit argument overrides the cmake variable.
set(CMAKE_TLS_VERIFY 1)
download(opt-0 TLS_VERIFY 0)
set(CMAKE_TLS_VERIFY 0)
download(opt-1 TLS_VERIFY 1)