Skip to content

Check openssl version and add appropriate defines#9924

Merged
cmcfarlen merged 3 commits intoapache:masterfrom
cmcfarlen:cmake_check_openssl3
Jun 28, 2023
Merged

Check openssl version and add appropriate defines#9924
cmcfarlen merged 3 commits intoapache:masterfrom
cmcfarlen:cmake_check_openssl3

Conversation

@cmcfarlen
Copy link
Contributor

No description provided.

@cmcfarlen cmcfarlen added the CMake work related to CMakes scripts or issues label Jun 28, 2023
@cmcfarlen cmcfarlen added this to the 10.0.0 milestone Jun 28, 2023
@cmcfarlen cmcfarlen self-assigned this Jun 28, 2023
Copy link
Contributor

@JosiahWI JosiahWI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like these changes, but there are some minor points that should be addressed. How is boringssl versioned? Is it possible that finding boringssl could still end up with OPENSSL_IS_OPENSSL3 getting set?

CMakeLists.txt Outdated
@@ -167,7 +167,14 @@ endif()
find_package(PCRE)

include(FindOpenSSL)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you're cleaning up the OpenSSL checks, can we remove this direct inclusion of FindOpenSSL? find_package should find the right module to include for us.

CMakeLists.txt Outdated
check_openssl_is_boringssl(OPENSSL_IS_BORINGSSL "${OPENSSL_INCLUDE_DIR}")

if(OPENSSL_VERSION VERSION_GREATER_EQUAL "3.0.0")
set(OPENSSL_IS_OPENSSL3 ON)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use TRUE for internal checks? I think it helps distinguish between options that can be toggled, and deterministic checks.

Comment on lines 106 to 110
target_sources(tscore PUBLIC HKDF_boringssl.cc)
elseif(OPENSSL_IS_OPENSSL3)
target_sources(tscore PUBLIC HKDF_openssl3.cc)
else()
target_sources(tscore PUBLIC HKDF_openssl.cc)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing a PUBLIC usage requirement for target sources is like seeing Santa Clause driving his sleigh in December without his coat on. Are we doing something fancy, or should these be PRIVATE?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't figure out which was the default for add_library so just punted. I think we need to audit these usage requirements in general.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do. I've been fixing a few here and there, but most of it will probably have to be part of the general cleanup. Regardless, we should make sure that new ones are correct.

Part of the general problem there is that the cyclic dependencies result in usage requirements being weird.


if(OPENSSL_VERSION VERSION_GREATER_EQUAL "3.0.0")
set(OPENSSL_IS_OPENSSL3 ON)
add_compile_definitions(OPENSSL_API_COMPAT=10002 OPENSSL_IS_OPENSSL3)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

./plugins/certifier/CMakeLists.txt:add_definitions(-DOPENSSL_API_COMPAT=10002)

Interesting, this is duplicated in the certifier. That's not necessarily bad because it helps decouple, but I'm wondering whether the one in certifier should also be guarded by a conditional.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how auto tools is setup when openssl3 is found. I'm not sure if its necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will remove the definition in certifier plugin. I don't think it needs to be in both. If its a problem, perhaps there is something else going on.

@cmcfarlen
Copy link
Contributor Author

I like these changes, but there are some minor points that should be addressed. How is boringssl versioned? Is it possible that finding boringssl could still end up with OPENSSL_IS_OPENSSL3 getting set?

borinssl defines OPENSSL_IS_BORINGSSL itself, so they will both be set.

Copy link
Contributor

@JosiahWI JosiahWI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, looks good.

@cmcfarlen cmcfarlen merged commit 167e869 into apache:master Jun 28, 2023
@cmcfarlen cmcfarlen deleted the cmake_check_openssl3 branch June 28, 2023 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CMake work related to CMakes scripts or issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants