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

mbedtls: fix v3.1.0 build private access #8214

Closed
wants to merge 4 commits into from
Closed

mbedtls: fix v3.1.0 build private access #8214

wants to merge 4 commits into from

Conversation

trackpadpro
Copy link
Contributor

"As a last resort, you can access the field foo of a structure bar by writing bar.MBEDTLS_PRIVATE(foo). Note that you do so at your own risk, since such code is likely to break in a future minor version of Mbed TLS." - https://github.com/ARMmbed/mbedtls/blob/f2d1199edc5834df4297f247f213e614f7782d1d/docs/3.0-migration-guide.md

That future minor version is v3.1.0. I set the >= to == for the version checks relevant to the private members because v3.1.0 is an MbedTLS release, and I am not sure when the private designation was reverted after v3.0.0. The change made to support v3.0.0 causes builds to break for v3.1.0.

Build errors are included in the extended description of the latest commit. I do not believe this error would be exclusive to CMake, but that is what I am using for my project.

-- curl version=[7.81.0-DEV]
CMake Warning (dev) at /usr/share/cmake-3.22.1/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (MBEDTLS)
  does not match the name of the calling package (MbedTLS).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  deps/curl/CMake/FindMbedTLS.cmake:31 (find_package_handle_standard_args)
  deps/curl/CMakeLists.txt:473 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.
"As a last resort, you can access the field foo of a structure bar by writing bar.MBEDTLS_PRIVATE(foo). Note that you do so at your own risk, since such code is likely to break in a future minor version of Mbed TLS." - https://github.com/ARMmbed/mbedtls/blob/f2d1199edc5834df4297f247f213e614f7782d1d/docs/3.0-migration-guide.md

That future minor version is v3.1.0. I set the >= to == for the version checks because v3.1.0 is a release, and I am not sure when the private designation was reverted after v3.0.0. The change made to support v3.0.0 causes builds to break for v3.1.0 with the following errors:

[ 81%] Building C object deps/curl/lib/CMakeFiles/libcurl.dir/vtls/mbedtls.c.o
In file included from /c/Users/Valentin/Downloads/stateSpaceSolver/deps/mbedtls-3.1.0/build/include/mbedtls/net_sockets.h:40,
/c/Users/Valentin/Downloads/stateSpaceSolver/deps/curl/lib/vtls/mbedtls.c: In function 'mbed_connect_step2':
/c/Users/Valentin/Downloads/stateSpaceSolver/deps/mbedtls-3.1.0/build/include/mbedtls/private_access.h:27:33: error: 'mbedtls_x509_crt' has no member named 'private_raw'; did you mean 'private_sig'?
   27 | #define MBEDTLS_PRIVATE(member) private_##member
      |                                 ^~~~~~~~
/c/Users/Valentin/Downloads/stateSpaceSolver/deps/curl/lib/vtls/mbedtls.c:703:32: note: in expansion of macro 'MBEDTLS_PRIVATE'
  703 |     if(!peercert || !peercert->MBEDTLS_PRIVATE(raw).MBEDTLS_PRIVATE(p) ||
      |                                ^~~~~~~~~~~~~~~
/c/Users/Valentin/Downloads/stateSpaceSolver/deps/mbedtls-3.1.0/build/include/mbedtls/private_access.h:27:33: error: 'mbedtls_x509_crt' has no member named 'private_raw'; did you mean 'private_sig'?
   27 | #define MBEDTLS_PRIVATE(member) private_##member
      |                                 ^~~~~~~~
/c/Users/Valentin/Downloads/stateSpaceSolver/deps/curl/lib/vtls/mbedtls.c:704:19: note: in expansion of macro 'MBEDTLS_P      |                   ^~~~~~~~~~~~~~~
/c/Users/Valentin/Downloads/stateSpaceSolver/deps/mbedtls-3.1.0/build/include/mbedtls/private_access.h:27:33: error: 'mb   27 | #define MBEDTLS_PRIVATE(member) private_##member
      |                                 ^~~~~~~~
/c/Users/Valentin/Downloads/stateSpaceSolver/deps/curl/lib/vtls/mbedtls.c:731:35: note: in expansion of macro 'MBEDTLS_PRIVATE'
  731 |                         peercert->MBEDTLS_PRIVATE(raw).MBEDTLS_PRIVATE(p),
      |                                   ^~~~~~~~~~~~~~~
/c/Users/Valentin/Downloads/stateSpaceSolver/deps/mbedtls-3.1.0/build/include/mbedtls/private_access.h:27:33: error: 'mbedtls_x509_crt' has no member named 'private_raw'; did you mean 'private_sig'?
   27 | #define MBEDTLS_PRIVATE(member) private_##member
      |                                 ^~~~~~~~
/c/Users/Valentin/Downloads/stateSpaceSolver/deps/curl/lib/vtls/mbedtls.c:732:35: note: in expansion of macro 'MBEDTLS_PRIVATE'
  732 |                         peercert->MBEDTLS_PRIVATE(raw).MBEDTLS_PRIVATE(len))) {
      |                                   ^~~~~~~~~~~~~~~
/c/Users/Valentin/Downloads/stateSpaceSolver/deps/mbedtls-3.1.0/build/include/mbedtls/private_access.h:27:33: error: 'mbedtls_x509_crt' has no member named 'private_pk'; did you mean 'private_sig'?
   27 | #define MBEDTLS_PRIVATE(member) private_##member
      |                                 ^~~~~~~~
/c/Users/Valentin/Downloads/stateSpaceSolver/deps/curl/lib/vtls/mbedtls.c:742:44: note: in expansion of macro 'MBEDTLS_PRIVATE'
  742 |     size = mbedtls_pk_write_pubkey_der(&p->MBEDTLS_PRIVATE(pk), pubkey,
      |                                            ^~~~~~~~~~~~~~~
make[2]: *** [deps/curl/lib/CMakeFiles/libcurl.dir/build.make:1994: deps/curl/lib/CMakeFiles/libcurl.dir/vtls/mbedtls.c.o] Error 1
@bagder bagder added the TLS label Jan 2, 2022
@bagder
Copy link
Member

bagder commented Jan 3, 2022

Seems fair. I'll bump the mbedtls CI job in #8215 to use 3.1.0 once this is merged.

@bagder
Copy link
Member

bagder commented Jan 3, 2022

Can you rebase/force-push this to remove the irrelevant commits already merged from #8207?

@bagder
Copy link
Member

bagder commented Jan 3, 2022

Never mind, I'll do that.

@bagder bagder closed this in 75b832c Jan 3, 2022
@bagder
Copy link
Member

bagder commented Jan 3, 2022

Thanks!

@trackpadpro
Copy link
Contributor Author

I have actually been wondering what the proper pull request format is. Will read into rebase and force push a bit to see if I can fix it in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

2 participants