Skip to content

Commit 4ba9066

Browse files
committed
Addressing comments
1 parent d5ce9a1 commit 4ba9066

1 file changed

Lines changed: 31 additions & 27 deletions

File tree

submodules/CMakeLists.txt

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,11 @@ else()
320320
COMMENT "OpenSSL build"
321321
)
322322
323-
if (QUIC_USE_SYSTEM_LIBCRYPTO AND NOT (CX_PLATFORM STREQUAL "linux" AND QUIC_TLS_LIB STREQUAL "openssl"))
323+
if (QUIC_USE_SYSTEM_LIBCRYPTO AND QUIC_TLS_LIB STREQUAL "quictls")
324324
# OpenSSL 3 uses different sources for static and dynamic libraries.
325325
# That is ok if you use either one consistently but it fails to link when we use dynamic crypto with static ssl.
326326
# To fix that we need little hackery - see quictls/ssl/build.info.
327-
# Skip only linux+openssl where both libssl and libcrypto are linked dynamically.
327+
# This is required for quictls hybrid linking when using system libcrypto.
328328
add_custom_command(
329329
OUTPUT ${LIBSSL_PATH}
330330
OUTPUT ${LIBCRYPTO_PATH}
@@ -356,36 +356,40 @@ else()
356356
)
357357
358358
if (QUIC_USE_SYSTEM_LIBCRYPTO)
359-
include(FindOpenSSL)
360-
if (OPENSSL_FOUND)
361-
# Get Major.Minor so 3.0 can match 3.0.2.
362-
# We cannot use VERSION_GREATER as 3.0 would work for 1.1.1 but they are not compatible.
363-
string(FIND ${OPENSSL_VERSION} "." VERSIONLEN REVERSE)
364-
string(SUBSTRING ${OPENSSL_VERSION} 0 ${VERSIONLEN} OPENSSL_MAJORMINOR)
365-
string(FIND ${OPENSSL_VERSION} "." VERSIONLEN)
366-
string(SUBSTRING ${OPENSSL_VERSION} 0 ${VERSIONLEN} OPENSSL_MAJOR)
367-
368-
if (OPENSSL_VERSION VERSION_EQUAL EXPECTED_OPENSSL_VERSION OR OPENSSL_MAJORMINOR VERSION_EQUAL EXPECTED_OPENSSL_VERSION OR
369-
# 3.1 is compatible with 3.0, 3.2 and beyond maybe as well.
370-
(EXPECTED_OPENSSL_VERSION VERSION_EQUAL "3.0" AND OPENSSL_MAJOR EQUAL "3"))
371-
target_link_libraries(OpenSSLQuic INTERFACE OpenSSL::Crypto)
372-
373-
if (CX_PLATFORM STREQUAL "linux" AND QUIC_TLS_LIB STREQUAL "openssl")
374-
# Linux openssl uses libssl and libcrypto system libraries dynamically.
375-
if (OPENSSL_VERSION VERSION_GREATER_EQUAL "3.5.0")
376-
target_link_libraries(OpenSSLQuic INTERFACE OpenSSL::SSL)
377-
else()
378-
message(FATAL_ERROR "OpenSSL 3.5.0 or later required for openssl TLS provider on Linux, found ${OPENSSL_VERSION}")
379-
endif()
359+
if (QUIC_TLS_LIB STREQUAL "openssl")
360+
include(FindOpenSSL)
361+
if (OPENSSL_FOUND)
362+
if (OPENSSL_VERSION VERSION_GREATER_EQUAL "3.5.0")
363+
# openssl TLS provider links both system libcrypto and libssl dynamically.
364+
target_link_libraries(OpenSSLQuic INTERFACE OpenSSL::Crypto OpenSSL::SSL)
380365
else()
381-
# Preserve existing hybrid behavior everywhere else.
366+
message(FATAL_ERROR "OpenSSL 3.5.0 or later required for openssl TLS provider, found ${OPENSSL_VERSION}")
367+
endif()
368+
else()
369+
message(FATAL_ERROR "System OpenSSL not found when requested")
370+
endif()
371+
elseif(QUIC_TLS_LIB STREQUAL "quictls")
372+
include(FindOpenSSL)
373+
if (OPENSSL_FOUND)
374+
# Get Major.Minor so 3.0 can match 3.0.2.
375+
# We cannot use VERSION_GREATER as 3.0 would work for 1.1.1 but they are not compatible.
376+
string(FIND ${OPENSSL_VERSION} "." VERSIONLEN REVERSE)
377+
string(SUBSTRING ${OPENSSL_VERSION} 0 ${VERSIONLEN} OPENSSL_MAJORMINOR)
378+
string(FIND ${OPENSSL_VERSION} "." VERSIONLEN)
379+
string(SUBSTRING ${OPENSSL_VERSION} 0 ${VERSIONLEN} OPENSSL_MAJOR)
380+
381+
if (OPENSSL_VERSION VERSION_EQUAL EXPECTED_OPENSSL_VERSION OR OPENSSL_MAJORMINOR VERSION_EQUAL EXPECTED_OPENSSL_VERSION OR
382+
# 3.1 is compatible with 3.0, 3.2 and beyond maybe as well.
383+
(EXPECTED_OPENSSL_VERSION VERSION_EQUAL "3.0" AND OPENSSL_MAJOR EQUAL "3"))
384+
target_link_libraries(OpenSSLQuic INTERFACE OpenSSL::Crypto)
385+
# Preserve existing hybrid behavior for quictls.
382386
target_link_libraries(OpenSSLQuic INTERFACE ${LIBSSL_PATH})
387+
else()
388+
message(FATAL_ERROR "OpenSSL ${EXPECTED_OPENSSL_VERSION} not found, found ${OPENSSL_VERSION}")
383389
endif()
384390
else()
385-
message(FATAL_ERROR "OpenSSL ${EXPECTED_OPENSSL_VERSION} not found, found ${OPENSSL_VERSION}")
391+
message(FATAL_ERROR "System OpenSSL not found when requested")
386392
endif()
387-
else()
388-
message(FATAL_ERROR "System OpenSSL not found when requested")
389393
endif()
390394
else()
391395
target_link_libraries(

0 commit comments

Comments
 (0)