-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCheckHTTPS.cmake
81 lines (66 loc) · 1.53 KB
/
CheckHTTPS.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
cmake_minimum_required(VERSION 3.19)
option(bad "only do bad tests" off)
option(CMAKE_TLS_VERIFY "Verify TLS" on)
set(url_good
https://hsts.badssl.com
https://gitlab.kitware.com
https://github.com
https://dropbox.com
https://zenodo.org
https://bitbucket.org
https://box.com
https://www.zlib.net/
https://www.gnu.org/software/gcc/
https://drive.google.com
https://invisible-mirror.net/archives/ncurses/
https://sourceforge.net/projects/libisl/
https://gitlab.inria.fr/
https://www.python.org/downloads/source/
https://hg.nginx.org/pkg-oss/tags
)
set(url_fail
https://expired.badssl.com
https://wrong.host.badssl.com
https://self-signed.badssl.com
https://untrusted-root.badssl.com
https://null.badssl.com
https://revoked.badssl.com
https://pinning-test.badssl.com
https://tls-v1-0.badssl.com
)
# --- helper functions
function(check_url url ok)
file(DOWNLOAD ${url}
LOG log
STATUS stat
)
message(STATUS "${url} ${stat}")
list(GET stat 0 code)
if(code EQUAL 0)
set(${ok} true PARENT_SCOPE)
else()
set(${ok} false PARENT_SCOPE)
message(NOTICE "${url} ${stat}
${log}")
endif()
endfunction()
# --- main program
if(bad)
set(url_good)
message(STATUS "Skipping good URL tests")
endif()
message(STATUS "CMake ${CMAKE_VERSION}")
include(${CMAKE_CURRENT_LIST_DIR}/UserAgent.cmake)
user_agent()
foreach(u IN LISTS url_good)
check_url(${u} ok)
if(NOT ok)
message(SEND_ERROR ${u})
endif()
endforeach()
foreach(u IN LISTS url_fail)
check_url(${u} ok)
if(ok)
message(SEND_ERROR "Bad URL should have failed: ${u}")
endif()
endforeach()