You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by cm...@apache.org on 2023/06/28 21:56:42 UTC

[trafficserver] branch master updated: Check openssl version and add appropriate defines (#9924)

This is an automated email from the ASF dual-hosted git repository.

cmcfarlen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 167e869784 Check openssl version and add appropriate defines (#9924)
167e869784 is described below

commit 167e86978441cdb6110f9b32d24f65c835e77332
Author: Chris McFarlen <ch...@mcfarlen.us>
AuthorDate: Wed Jun 28 16:56:36 2023 -0500

    Check openssl version and add appropriate defines (#9924)
    
    * Check openssl version and add appropriate defines
    
    * move boringssl checks around
    
    * PR comments
    
    ---------
    
    Co-authored-by: Chris McFarlen <cm...@apple.com>
---
 CMakeLists.txt                   | 13 +++++++++----
 plugins/certifier/CMakeLists.txt |  1 -
 src/tscore/CMakeLists.txt        |  9 ++++++++-
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 66c1bcc657..b3f5d1ac74 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -165,8 +165,14 @@ endif()
 
 find_package(PCRE)
 
-include(FindOpenSSL)
+include(CheckOpenSSLIsBoringSSL)
 find_package(OpenSSL)
+check_openssl_is_boringssl(OPENSSL_IS_BORINGSSL "${OPENSSL_INCLUDE_DIR}")
+
+if(OPENSSL_VERSION VERSION_GREATER_EQUAL "3.0.0")
+    set(OPENSSL_IS_OPENSSL3 TRUE)
+    add_compile_definitions(OPENSSL_API_COMPAT=10002 OPENSSL_IS_OPENSSL3)
+endif()
 
 if(ENABLE_PROFILER)
     find_package(profiler REQUIRED)
@@ -192,9 +198,7 @@ if(ENABLE_QUICHE)
     set(TS_HAS_QUICHE ${quiche_FOUND})
     set(TS_USE_QUIC ${TS_HAS_QUICHE})
 
-    include(CheckOpenSSLIsBoringSSL)
-    check_openssl_is_boringssl(TS_HAVE_BORINGSSL "${OPENSSL_INCLUDE_DIR}")
-    if(NOT TS_HAVE_BORINGSSL)
+    if(NOT OPENSSL_IS_BORINGSSL)
         message(FATAL_ERROR "Use of BoringSSL is required if quiche is used.")
     endif()
 endif()
@@ -404,3 +408,4 @@ cmake_print_variables(BUILD_GROUP)
 cmake_print_variables(BUILD_MACHINE)
 cmake_print_variables(DEFAULT_STACK_SIZE)
 cmake_print_variables(CMAKE_INSTALL_RPATH)
+cmake_print_variables(OPENSSL_VERSION)
diff --git a/plugins/certifier/CMakeLists.txt b/plugins/certifier/CMakeLists.txt
index 78117acb29..6495cfeb9e 100644
--- a/plugins/certifier/CMakeLists.txt
+++ b/plugins/certifier/CMakeLists.txt
@@ -15,5 +15,4 @@
 #
 #######################
 
-add_definitions(-DOPENSSL_API_COMPAT=10002)
 add_atsplugin(certifier certifier.cc)
diff --git a/src/tscore/CMakeLists.txt b/src/tscore/CMakeLists.txt
index f7296a86ac..1ae1006b69 100644
--- a/src/tscore/CMakeLists.txt
+++ b/src/tscore/CMakeLists.txt
@@ -44,7 +44,6 @@ add_library(tscore SHARED
         Errata.cc
         EventNotify.cc
         Extendible.cc
-        HKDF_openssl.cc
         Hash.cc
         HashFNV.cc
         HashSip.cc
@@ -103,6 +102,14 @@ add_library(tscore SHARED
 )
 add_library(ts::tscore ALIAS tscore)
 
+if(OPENSSL_IS_BORINGSSL)
+    target_sources(tscore PRIVATE HKDF_boringssl.cc)
+elseif(OPENSSL_IS_OPENSSL3)
+    target_sources(tscore PRIVATE HKDF_openssl3.cc)
+else()
+    target_sources(tscore PRIVATE HKDF_openssl.cc)
+endif()
+
 add_dependencies(tscore ParseRules tscpputil)
 target_include_directories(tscore PRIVATE
         ${CMAKE_CURRENT_BINARY_DIR}