-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbad_ssl.cmake
51 lines (36 loc) · 1.04 KB
/
bad_ssl.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
cmake_minimum_required(VERSION 3.19)
set(CMAKE_TLS_VERIFY ON)
include(${CMAKE_CURRENT_LIST_DIR}/UserAgent.cmake)
user_agent()
message(STATUS "TLS_CAINFO: ${CMAKE_TLS_CAINFO}
SSL_CERT_DIR: $ENV{SSL_CERT_DIR}
SSL_CERT_FILE: $ENV{SSL_CERT_FILE}"
)
function(ssl url retval)
file(DOWNLOAD ${url} STATUS ret LOG log)
list(GET ret 0 status)
list(GET ret 1 msg)
message(STATUS "${url}:${status}: ${msg}")
if(NOT status EQUAL 0)
message(NOTICE "${log}")
endif()
set(${retval} ${status} PARENT_SCOPE)
endfunction(ssl)
message(STATUS "These tests should fail.")
foreach(url IN ITEMS https://expired.badssl.com/ https://untrusted-root.badssl.com/)
ssl(${url} status)
if(status EQUAL 0)
message(SEND_ERROR "FAIL: ${url}")
else()
message(STATUS "OK: ${url}")
endif()
endforeach()
message(STATUS "These tests should work OK.")
foreach(url IN ITEMS https://hsts.badssl.com/ https://sha256.badssl.com/)
ssl(${url} status)
if(status EQUAL 0)
message(STATUS "OK: ${url}")
else()
message(SEND_ERROR "FAIL: ${url}")
endif()
endforeach()