diff --git a/scripts/get-buildconfig.ps1 b/scripts/get-buildconfig.ps1 index 7515c3063..3aaafb8cf 100644 --- a/scripts/get-buildconfig.ps1 +++ b/scripts/get-buildconfig.ps1 @@ -90,6 +90,28 @@ if ("" -eq $Tls) { $Tls = "schannel" } else { $Tls = "openssl" + try { + # If no Tls was specified, try to guess it based on default OpenSSL version + # This is more complicated in attempt to silently deal with missing openssl executable + # + $pinfo = New-Object System.Diagnostics.ProcessStartInfo + $pinfo.FileName = "openssl" + $pinfo.Arguments = "version" + $pinfo.RedirectStandardError = $true + $pinfo.RedirectStandardOutput = $true + $pinfo.UseShellExecute = $false + + $p = New-Object System.Diagnostics.Process + $p.StartInfo = $pinfo + $p.Start() | Out-Null + $p.WaitForExit() + + $version = $p.StandardOutput.ReadToEnd() + if ($version -like "OpenSSL 3*") + { + $Tls = "openssl3" + } + } catch { } } } diff --git a/submodules/CMakeLists.txt b/submodules/CMakeLists.txt index 548a567b0..d0c95f0dc 100644 --- a/submodules/CMakeLists.txt +++ b/submodules/CMakeLists.txt @@ -339,7 +339,11 @@ else() if (QUIC_USE_SYSTEM_LIBCRYPTO) include(FindOpenSSL) if (OPENSSL_FOUND) - if (OPENSSL_VERSION VERSION_EQUAL EXPECTED_OPENSSL_VERSION OR OPENSSL_VERSION VERSION_GREATER EXPECTED_OPENSSL_VERSION) + # Get Major.Minor so 3.0 can match 3.0.2. + # We cannot use VERSION_GREATER as 3.0 would work for 1.1.1 but they are not compatible. + string(FIND ${OPENSSL_VERSION} "." VERSIONLEN REVERSE) + string(SUBSTRING ${OPENSSL_VERSION} 0 ${VERSIONLEN} OPENSSL_MAJORMINOR) + if (OPENSSL_VERSION VERSION_EQUAL EXPECTED_OPENSSL_VERSION OR OPENSSL_MAJORMINOR VERSION_EQUAL EXPECTED_OPENSSL_VERSION) target_link_libraries(OpenSSLQuic INTERFACE OpenSSL::Crypto) else() message(FATAL_ERROR "OpenSSL ${EXPECTED_OPENSSL_VERSION} not found, found ${OPENSSL_VERSION}")