]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: add rustls
authorJan Venekamp <1422460+jan2000@users.noreply.github.com>
Tue, 13 Aug 2024 22:05:44 +0000 (00:05 +0200)
committerViktor Szakats <commit@vsz.me>
Wed, 14 Aug 2024 13:05:53 +0000 (15:05 +0200)
Closes #14534

.github/labeler.yml
CMake/Findrustls.cmake [new file with mode: 0644]
CMakeLists.txt
Makefile.am
lib/curl_config.h.cmake

index 175176e14a899909334d88ff19968527788b1860..2554222572f94f7ce48a5918ea365024dd95d19b 100644 (file)
@@ -236,7 +236,7 @@ TLS:
   - all:
       - changed-files:
           - any-glob-to-all-files:
-              - '{CMake/FindBearSSL.cmake,CMake/FindMbedTLS.cmake,CMake/FindWolfSSL.cmake,docs/examples/ssl*,docs/examples/*ssl.*,docs/examples/*tls.*,docs/SSL*,docs/libcurl/curl_global_sslset*,docs/libcurl/opts/CURLINFO_CA*,docs/libcurl/opts/CURLINFO_CERT*,docs/libcurl/opts/CURLINFO_SSL*,docs/libcurl/opts/CURLINFO_TLS*,docs/libcurl/opts/CURLOPT_CA*,docs/libcurl/opts/CURLOPT_CERT*,docs/libcurl/opts/CURLOPT_PINNEDPUBLICKEY*,docs/libcurl/opts/CURLOPT_SSL*,docs/libcurl/opts/CURLOPT_TLS*,docs/libcurl/opts/CURLOPT_USE_SSL*,lib/vtls/**,m4/curl-bearssl.m4,m4/curl-gnutls.m4,m4/curl-mbedtls.m4,m4/curl-openssl.m4,m4/curl-rustls.m4,m4/curl-schannel.m4,m4/curl-sectransp.m4,m4/curl-wolfssl.m4}'
+              - '{CMake/FindBearSSL.cmake,CMake/FindMbedTLS.cmake,CMake/FindWolfSSL.cmake,CMake/Findrustls.cmake,docs/examples/ssl*,docs/examples/*ssl.*,docs/examples/*tls.*,docs/SSL*,docs/libcurl/curl_global_sslset*,docs/libcurl/opts/CURLINFO_CA*,docs/libcurl/opts/CURLINFO_CERT*,docs/libcurl/opts/CURLINFO_SSL*,docs/libcurl/opts/CURLINFO_TLS*,docs/libcurl/opts/CURLOPT_CA*,docs/libcurl/opts/CURLOPT_CERT*,docs/libcurl/opts/CURLOPT_PINNEDPUBLICKEY*,docs/libcurl/opts/CURLOPT_SSL*,docs/libcurl/opts/CURLOPT_TLS*,docs/libcurl/opts/CURLOPT_USE_SSL*,lib/vtls/**,m4/curl-bearssl.m4,m4/curl-gnutls.m4,m4/curl-mbedtls.m4,m4/curl-openssl.m4,m4/curl-rustls.m4,m4/curl-schannel.m4,m4/curl-sectransp.m4,m4/curl-wolfssl.m4}'
 
 URL:
   - all:
diff --git a/CMake/Findrustls.cmake b/CMake/Findrustls.cmake
new file mode 100644 (file)
index 0000000..a8d40a5
--- /dev/null
@@ -0,0 +1,48 @@
+#***************************************************************************
+#                                  _   _ ____  _
+#  Project                     ___| | | |  _ \| |
+#                             / __| | | | |_) | |
+#                            | (__| |_| |  _ <| |___
+#                             \___|\___/|_| \_\_____|
+#
+# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at https://curl.se/docs/copyright.html.
+#
+# You may opt to use, copy, modify, merge, publish, distribute and/or sell
+# copies of the Software, and permit persons to whom the Software is
+# furnished to do so, under the terms of the COPYING file.
+#
+# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+# KIND, either express or implied.
+#
+# SPDX-License-Identifier: curl
+#
+###########################################################################
+# Find the rustls library
+#
+# Result Variables:
+#
+# RUSTLS_FOUND         System has rustls
+# RUSTLS_INCLUDE_DIRS  The rustls include directories
+# RUSTLS_LIBRARIES     The rustls library names
+
+find_path(RUSTLS_INCLUDE_DIR "rustls.h")
+
+find_library(RUSTLS_LIBRARY "rustls")
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(rustls
+  REQUIRED_VARS
+    RUSTLS_INCLUDE_DIR
+    RUSTLS_LIBRARY
+)
+
+if(RUSTLS_FOUND)
+  set(RUSTLS_INCLUDE_DIRS ${RUSTLS_INCLUDE_DIR})
+  set(RUSTLS_LIBRARIES    ${RUSTLS_LIBRARY})
+endif()
+
+mark_as_advanced(RUSTLS_INCLUDE_DIR RUSTLS_LIBRARY)
index 36616b0b0b7a6b28f544c65cffccdffb372dd376..0d248a91832ce3a2b5326bfb08be097622594c8d 100644 (file)
@@ -458,6 +458,7 @@ cmake_dependent_option(CURL_USE_MBEDTLS "Enable mbedTLS for SSL/TLS" OFF CURL_EN
 cmake_dependent_option(CURL_USE_BEARSSL "Enable BearSSL for SSL/TLS" OFF CURL_ENABLE_SSL OFF)
 cmake_dependent_option(CURL_USE_WOLFSSL "Enable wolfSSL for SSL/TLS" OFF CURL_ENABLE_SSL OFF)
 cmake_dependent_option(CURL_USE_GNUTLS "Enable GnuTLS for SSL/TLS" OFF CURL_ENABLE_SSL OFF)
+cmake_dependent_option(CURL_USE_RUSTLS "Enable rustls for SSL/TLS" OFF CURL_ENABLE_SSL OFF)
 
 set(_openssl_default ON)
 if(WIN32 OR CURL_USE_SECTRANSP OR CURL_USE_SCHANNEL OR CURL_USE_MBEDTLS OR CURL_USE_WOLFSSL)
@@ -474,6 +475,7 @@ count_true(_enabled_ssl_options_count
   CURL_USE_BEARSSL
   CURL_USE_WOLFSSL
   CURL_USE_GNUTLS
+  CURL_USE_RUSTLS
 )
 if(_enabled_ssl_options_count GREATER 1)
   set(CURL_WITH_MULTI_SSL ON)
@@ -614,6 +616,20 @@ if(CURL_USE_GNUTLS)
   endif()
 endif()
 
+if(CURL_USE_RUSTLS)
+  find_package(rustls REQUIRED)
+  set(_ssl_enabled ON)
+  set(USE_RUSTLS ON)
+  list(APPEND CURL_LIBS ${RUSTLS_LIBRARIES})
+  list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "rustls")
+  include_directories(${RUSTLS_INCLUDE_DIRS})
+
+  if(CURL_DEFAULT_SSL_BACKEND AND CURL_DEFAULT_SSL_BACKEND STREQUAL "rustls")
+    set(valid_default_ssl_backend TRUE)
+  endif()
+  set(curl_ca_bundle_supported TRUE)
+endif()
+
 if(CURL_DEFAULT_SSL_BACKEND AND NOT _valid_default_ssl_backend)
   message(FATAL_ERROR "CURL_DEFAULT_SSL_BACKEND '${CURL_DEFAULT_SSL_BACKEND}' not enabled.")
 endif()
@@ -1866,6 +1882,7 @@ if(NOT CURL_DISABLE_INSTALL)
   _add_if("BearSSL"          _ssl_enabled AND USE_BEARSSL)
   _add_if("wolfSSL"          _ssl_enabled AND USE_WOLFSSL)
   _add_if("GnuTLS"           _ssl_enabled AND USE_GNUTLS)
+  _add_if("rustls"           _ssl_enabled AND USE_RUSTLS)
 
   if(_items)
     if(NOT CMAKE_VERSION VERSION_LESS 3.13)
index 0a25f213b89c9603e57d95a6f1f6b37b92425b7a..ee844268fac480f842323230a4abf327f4d0f593 100644 (file)
@@ -47,6 +47,7 @@ CMAKE_DIST =                                    \
  CMake/FindQUICHE.cmake                         \
  CMake/FindWolfSSL.cmake                        \
  CMake/FindZstd.cmake                           \
+ CMake/Findrustls.cmake                         \
  CMake/Macros.cmake                             \
  CMake/OtherTests.cmake                         \
  CMake/PickyWarnings.cmake                      \
index aa89c600ddd48fea4d51e417e3c511d1c1d0237e..611e8dcffbd0c3e6137acd700f7dccadcfe3fa35 100644 (file)
@@ -689,6 +689,9 @@ ${SIZEOF_TIME_T_CODE}
 /* if BearSSL is enabled */
 #cmakedefine USE_BEARSSL 1
 
+/* if rustls is enabled */
+#cmakedefine USE_RUSTLS 1
+
 /* if wolfSSL is enabled */
 #cmakedefine USE_WOLFSSL 1