@@ -22,7 +22,7 @@ endif()
2222
2323# ##############################################################################
2424#
25- # Setup cmake enviornment and include custom config overrides
25+ # Setup cmake environment and include custom config overrides
2626#
2727# ##############################################################################
2828if (NSCP_CMAKE_CONFIG)
@@ -328,7 +328,7 @@ if(NOT HAVE_REQUIRED_DEPENDENCIES)
328328else (NOT HAVE_REQUIRED_DEPENDENCIES )
329329 message (
330330 STATUS
331- " - All required dependecies found! (some modules and features migh stil be missing though)"
331+ " - All required dependencies found! (some modules and features might still be missing though)"
332332 )
333333endif (NOT HAVE_REQUIRED_DEPENDENCIES )
334334
@@ -729,7 +729,7 @@ else(WIN32)
729729 set (MAIN_CONFIGURATION
730730 /etc/nscp/nscp.xml
731731 CACHE PATH
732- "Path for the client configurtion file"
732+ "Path for the client configuration file"
733733 )
734734 set (DEPLOYROOT /usr/bin CACHE PATH "Path to deploy examples into)" )
735735endif (WIN32 )
@@ -863,6 +863,13 @@ if(WIN32)
863863 CACHE STRING
864864 "security (certificates) folder"
865865 )
866+ # The service exports the Windows ROOT store here at boot (windows_ca_store),
867+ # so unlike unix this is a path we own rather than one the platform ships.
868+ set (CONFIG_CA_PATH
869+ "\$ {certificate-path}/windows-ca.pem"
870+ CACHE STRING
871+ "Trusted CA bundle used when a check does not name its own"
872+ )
866873 set (CONFIG_DEFAULT_CACHE_PATH
867874 "\$ {shared-path}/cache"
868875 CACHE STRING
@@ -920,8 +927,53 @@ else()
920927 set (CONFIG_CERT_FOLDER
921928 "\$ {shared-path}/security"
922929 CACHE STRING
923- "securoty (certificates) folder"
930+ "security (certificates) folder"
924931 )
932+
933+ # The trusted CA bundle belongs to the distribution, so this is an absolute
934+ # path that must NOT track CMAKE_INSTALL_PREFIX: a --prefix=/usr/local build
935+ # still reads the system bundle, not /usr/local/etc/ssl/...
936+ #
937+ # Where that bundle lives differs per family, and picking wrong is silent -
938+ # every TLS check that does not name its own CA then fails with "Failed to
939+ # load CA <path>: No such file or directory", including checks against a
940+ # local self-signed server with verification disabled, since the file is
941+ # loaded before the verify mode is considered. Detecting it here works
942+ # because a package is built in a container of the distribution it targets;
943+ # a packager who knows better can override with -DCONFIG_CA_PATH=...
944+ if (NOT CONFIG_CA_PATH)
945+ foreach (
946+ _ca_candidate
947+ "/etc/ssl/certs/ca-certificates.crt" # Debian, Ubuntu, Gentoo
948+ "/etc/pki/tls/certs/ca-bundle.crt" # RHEL, Rocky, Alma, Fedora
949+ "/etc/ssl/ca-bundle.pem" # SUSE
950+ "/etc/ssl/cert.pem" # Alpine, FreeBSD, macOS
951+ )
952+ if (EXISTS "${_ca_candidate} " )
953+ set (_ca_detected "${_ca_candidate} " )
954+ break ()
955+ endif ()
956+ endforeach ()
957+ if (NOT _ca_detected)
958+ # Nothing found: keep the historical value so the define is never
959+ # empty, and say so - a build host without a CA bundle is unusual
960+ # enough to be worth a line in the configure output.
961+ set (_ca_detected "/etc/ssl/certs/ca-certificates.crt" )
962+ message (
963+ WARNING
964+ "No system CA bundle found; defaulting ca-path to ${_ca_detected} . "
965+ "TLS checks that do not name their own CA will fail unless that file exists at runtime "
966+ "(override with -DCONFIG_CA_PATH=/path/to/bundle)."
967+ )
968+ endif ()
969+ set (CONFIG_CA_PATH
970+ "${_ca_detected} "
971+ CACHE STRING
972+ "Trusted CA bundle used when a check does not name its own"
973+ )
974+ endif ()
975+ message (STATUS "System CA bundle (ca-path): ${CONFIG_CA_PATH} " )
976+
925977 set (CONFIG_DEFAULT_CACHE_PATH
926978 "\$ {shared-path}/cache"
927979 CACHE STRING
@@ -1188,7 +1240,7 @@ set(NSCP_CLIENT_HPP
11881240
11891241# ##############################################################################
11901242#
1191- # Build everything (not already built lik libraries)!
1243+ # Build everything (not already built like libraries)!
11921244#
11931245# ##############################################################################
11941246
0 commit comments