Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

THRIFT-5706: lib: cpp: Fix C++ SecurityTest compilation on OpenSSL1.x #2811

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

joemcdonnell
Copy link

A recent change modified SecurityTest.cpp/SecurityFromBufferTest.cpp to handle OpenSSL3 by using OPENSSL_VERSION_MAJOR to detect the different OpenSSL versions. OPENSSL_VERSION_MAJOR is not available on OpenSSL 1.x, so these tests no longer compile on Ubuntu 20, etc.

The underlying reason for the OpenSSL3 change is that older versions of TLS (1.0, 1.1) are only accessible when specifying @SECLEVEL=0. Some distributions with OpenSSL 1.1.1 (Ubuntu 20) make them accessible at @SECLEVEL=1, so the tests can also fail in that circumstance.

This removes the reference to OPENSSL_VERSION_MAJOR and changes the test to specify @SECLEVEL=0 for OpenSSL versions that have @SECLEVEL support (> 1.1.0).

Testing:

  • Tested SecurityTest/SecurityFromBufferTest on Ubuntu 20 and 22
  • Tested with OpenSSL 1.0.2

This fixes the build/functionality for SecurityTest/SecurityFromBufferTest after the changes in 05604e2

  • Did you create an Apache Jira ticket? (Request account here, not required for trivial changes)
  • If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"?
  • Did you squash your changes to a single commit? (not required, but preferred)
  • Did you do your best to avoid breaking changes? If one was needed, did you label the Jira ticket with "Breaking-Change"?
  • If your change does not involve any code, include [skip ci] anywhere in the commit message to free up build resources.

@Jens-G Jens-G added the c++ label Jun 4, 2023
A recent change modified SecurityTest.cpp/SecurityFromBufferTest.cpp
to handle OpenSSL3 by using OPENSSL_VERSION_MAJOR to detect the
different OpenSSL versions. OPENSSL_VERSION_MAJOR is not available
on OpenSSL 1.x, so these tests no longer compile on Ubuntu 20, etc.

The underlying reason for the OpenSSL3 change is that older versions
of TLS (1.0, 1.1) are only accessible when specifying @SECLEVEL=0.
Some distributions with OpenSSL 1.1.1 (Ubuntu 20) make them accessible
at @SECLEVEL=1, so the tests can also fail in that circumstance.

This removes the reference to OPENSSL_VERSION_MAJOR and changes the
test to specify @SECLEVEL=0 for OpenSSL versions that have @SECLEVEL
support (> 1.1.0).

Testing:
 - Tested SecurityTest/SecurityFromBufferTest on Ubuntu 20 and 22
 - Tested with OpenSSL 1.0.2
@emmenlau
Copy link
Member

@joemcdonnell can you check if this issue persists with latest thrift master? I think I fixed it, without seeing your PR before. But I did not check the details, so I may be wrong. I can say that my thrift build works with openSSL 1.x. But I may be using different options than you are. Kindly help and clarify?

thomasbruggink added a commit to thomasbruggink/thrift that referenced this pull request Feb 26, 2024
This PR fixes the Security tests to build on a clean install of ubuntu
20.04 and ubuntu 22.04 without modifications to the systems openssl
configuration.

 * Enable TLS 1.0 and TLS 1.1 on OpenSSL 1.1 with the seclevel=0 flag
 * Disable TLS 1.0 and TLS 1.1 on OpenSSL 3.0

While its technically possible to enable it on OpenSSL 3 I think because
of all the issues with these old TLS versions dropping support for it is
better.

This PR builds forth on the work done here: apache#2811
thomasbruggink added a commit to thomasbruggink/thrift that referenced this pull request Feb 26, 2024
This PR fixes the Security tests to build on a clean install of ubuntu
20.04 and ubuntu 22.04 without modifications to the systems openssl
configuration.

 * Enable TLS 1.0 and TLS 1.1 on OpenSSL 1.1 with the seclevel=0 flag
 * Disable TLS 1.0 and TLS 1.1 on OpenSSL 3.0

While its technically possible to enable it on OpenSSL 3 I think because
of all the issues with these old TLS versions dropping support for it is
better.

This PR builds forth on the work done here: apache#2811
thomasbruggink added a commit to thomasbruggink/thrift that referenced this pull request Feb 26, 2024
This PR fixes the Security tests to build on a clean install of ubuntu
20.04 and ubuntu 22.04 without modifications to the systems openssl
configuration.

 * Enable TLS 1.0 and TLS 1.1 on OpenSSL 1.1 with the seclevel=0 flag
 * Disable TLS 1.0 and TLS 1.1 on OpenSSL 3.0

While its technically possible to enable it on OpenSSL 3 I think because
of all the issues with these old TLS versions dropping support for it is
better.

This PR builds forth on the work done here: apache#2811
thomasbruggink added a commit to thomasbruggink/thrift that referenced this pull request Feb 26, 2024
This PR fixes the Security tests to build on a clean install of ubuntu
20.04 and ubuntu 22.04 without modifications to the systems openssl
configuration.

 * Enable TLS 1.0 and TLS 1.1 on OpenSSL 1.1 with the seclevel=0 flag
 * Disable TLS 1.0 and TLS 1.1 on OpenSSL 3.0

While its technically possible to enable it on OpenSSL 3 I think because
of all the issues with these old TLS versions dropping support for it is
better.

This PR builds forth on the work done here: apache#2811
thomasbruggink added a commit to thomasbruggink/thrift that referenced this pull request Feb 26, 2024
This PR fixes the Security tests to build on a clean install of ubuntu
20.04 and ubuntu 22.04 without modifications to the systems openssl
configuration.

 * Enable TLS 1.0 and TLS 1.1 on OpenSSL 1.1 with the seclevel=0 flag
 * Disable TLS 1.0 and TLS 1.1 on OpenSSL 3.0

While its technically possible to enable it on OpenSSL 3 I think because
of all the issues with these old TLS versions dropping support for it is
better.

This PR builds forth on the work done here: apache#2811

Tested with the ubuntu 20.04 (OpenSSL 1.1) and 22.04 (OpenSSL 3.0) docker containers.
All lib/cpp tests succeed in both.
thomasbruggink added a commit to thomasbruggink/thrift that referenced this pull request Feb 26, 2024
This PR fixes the Security tests to build on a clean install of ubuntu
20.04 and ubuntu 22.04 without modifications to the systems openssl
configuration.

 * Enable TLS 1.0 and TLS 1.1 on OpenSSL 1.1 with the seclevel=0 flag
 * Disable TLS 1.0 and TLS 1.1 on OpenSSL 3.0

While its technically possible to enable it on OpenSSL 3 I think because
of all the issues with these old TLS versions dropping support for it is
better.

This PR builds forth on the work done here: apache#2811

Tested with the ubuntu 20.04 (OpenSSL 1.1) and 22.04 (OpenSSL 3.0) docker containers.
All lib/cpp tests succeed in both.
thomasbruggink added a commit to thomasbruggink/thrift that referenced this pull request Feb 26, 2024
This PR fixes the Security tests to build on a clean install of ubuntu
20.04 and ubuntu 22.04 without modifications to the systems openssl
configuration.

 * Enable TLS 1.0 and TLS 1.1 on OpenSSL 1.1 with the seclevel=0 flag
 * Disable TLS 1.0 and TLS 1.1 on OpenSSL 3.0

While its technically possible to enable it on OpenSSL 3 I think because
of all the issues with these old TLS versions dropping support for it is
better.

This PR builds forth on the work done here: apache#2811

Tested with the ubuntu 20.04 (OpenSSL 1.1) and 22.04 (OpenSSL 3.0) docker containers.
All lib/cpp tests succeed in both.
@thomasbruggink
Copy link
Contributor

@emmenlau This issue is still affecting the latest master test run on a clean ubuntu 20.04 and 22.04.
I've created a small follow up to this PR here: #2940 which disables TLS1.0 and TLS1.1 on OpenSSL 3.0 since its an ancient protocol.

I can confirm that this PR also fixes the test issue so if you want to keep TLS1.0 and TLS1.1 tests enabled on OpenSSL 3.0 merging this PR and closing mine is also ok.

thomasbruggink added a commit to thomasbruggink/thrift that referenced this pull request Feb 26, 2024
This PR fixes the Security tests to build on a clean install of ubuntu
20.04 and ubuntu 22.04 without modifications to the systems openssl
configuration.

 * Enable TLS 1.0 and TLS 1.1 on OpenSSL 1.1 with the seclevel=0 flag
 * Disable TLS 1.0 and TLS 1.1 on OpenSSL 3.0

While its technically possible to enable it on OpenSSL 3 I think because
of all the issues with these old TLS versions dropping support for it is
better.

This PR builds forth on the work done here: apache#2811

Tested with the ubuntu 20.04 (OpenSSL 1.1) and 22.04 (OpenSSL 3.0) docker containers.
All lib/cpp tests succeed in both.
thomasbruggink added a commit to thomasbruggink/thrift that referenced this pull request Feb 26, 2024
This PR fixes the Security tests to build on a clean install of ubuntu
20.04 and ubuntu 22.04 without modifications to the systems openssl
configuration.

 * Enable TLS 1.0 and TLS 1.1 on OpenSSL 1.1 with the seclevel=0 flag
 * Disable TLS 1.0 and TLS 1.1 on OpenSSL 3.0

While its technically possible to enable it on OpenSSL 3 I think because
of all the issues with these old TLS versions dropping support for it is
better.

This PR builds forth on the work done here: apache#2811

Tested with the ubuntu 20.04 (OpenSSL 1.1) and 22.04 (OpenSSL 3.0) docker containers.
All lib/cpp tests succeed in both.
@emmenlau
Copy link
Member

emmenlau commented Mar 5, 2024

Thanks a lot @thomasbruggink , I think your work here is very valid and I would consider this the correct way forward. However, making backwards-incompatible changes is always hard in wide-spread projects like thrift. Therefore I have a slight preference to combine this work here with your changes suggested in #2940, so that the old SSL/TLS versions continue to be supported.

Could you kindly combine the work into a single PR here, and fix the minor conflicts? Then ping me again, and I'll try to merge it ASAP!

@thomasbruggink
Copy link
Contributor

@emmenlau thanks for the response, pushed a merged fix 🙇 3ea763e

@thomasbruggink
Copy link
Contributor

@emmenlau any concern if we merge this or my PR? I think at this point the implementation is the same.
It would be great if the test suite of cpp can pass again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants