[MDEV-25785] Add support for OpenSSL 3.0 Created: 2021-05-26 Updated: 2023-08-07 Resolved: 2022-01-20 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Compiling |
| Fix Version/s: | 10.8.1 |
| Type: | Task | Priority: | Blocker |
| Reporter: | Honza Horak | Assignee: | Sergei Golubchik |
| Resolution: | Fixed | Votes: | 3 |
| Labels: | None | ||
| Attachments: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
|
OpenSSL 3.0 is not yet released as GA, but we already experiment with the builds in Fedora (Copr repository available: https://copr.fedorainfracloud.org/coprs/saprasad/openssl-3.0/) or in CentOS Stream 9 (https://kojihub.stream.centos.org/koji/buildinfo?buildID=7571). There are some documented changes in OpenSSL 3.0: https://wiki.openssl.org/index.php/OpenSSL_3.0 but there are also some changes that should not be visible. However, since other SW depends on some internals, the changes actually affect the compatibility more than documented. MariaDB 10.5.9 (expecting 10.6.x behaves the same) fails to build with this upcoming OpenSSL 3.0. The problem is mainly with md5, sha and crypto parts. A partial fix is proposed here: MySQL report is https://bugs.mysql.com/bug.php?id=103818 |
| Comments |
| Comment by Honza Horak [ 2021-06-17 ] |
|
OpenSSL 3.0.0 is now released as RC, so the design and functionality should not be changed any more: https://www.openssl.org/blog/blog/2021/06/17/OpenSSL3.0ReleaseCandidate/ Can I kindly ask whether "Fix versions: 10.6" means somebody is looking at this soon or what is the rough ETA? |
| Comment by Honza Horak [ 2021-06-17 ] |
|
I've asked Sahana to update the copr repository https://copr.fedorainfracloud.org/coprs/saprasad/openssl-3.0/ with this newest release, so at last for fedora users, there would be a simple way to get the openssl 3.0.0 RC soon. Is there anything else we can help with in order to make mariadb work fine with newer openssl? We can for example provide contacts to Red Hat colleagues from OpenSSL upstream if something needs to be discussed in more detail... |
| Comment by Sergei Golubchik [ 2021-06-17 ] |
|
No, at the moment nobody is looking into it. But we'll do it, of course, we cannot ignore the new major OpenSSL version. But it's not a simple task, we'll have to change the way MariaDB uses OpenSSL, it'll be a big refactoring. The problem is that for a long time, since OpenSSL 0.9, the code heavily relied on various OpenSSL contexts allocated on the stack for one function only. Like create an MD5 context, calculate the hash, destroy the context. With OpenSSL making all objects opaque, we can no longer do it. And we don't want to replace all those stack allocations with malloc(), the server tries rather hard to avoid malloc(). So, we'll need to implement an approach that will work with opaque objects created by OpenSSL and still doesn't call malloc() every time we need to encrypt or hash something. |
| Comment by Honza Horak [ 2021-06-18 ] |
|
Do you think it makes sense to start with using deprecated functionality first (which is still available) and make it work with 3.0.0 at least somehow before doing it "correctly" without the deprecated functionality? The patch I mentioned in the description makes the code compile this way, does not replace more than is necessary, and works find with many tests.. But it still does not address some other cases, mostly binlog_encryption suite fails (server crashes). It still seems quite doable without a big rewriting at least as the first step. |
| Comment by Georg Richter [ 2021-06-24 ] |
|
A simple (and faster) solution would be to reuse contexts. In current implementation every encryption or hashing operation creates a new context on stack and initializes it. Instead an existing context should be resetted (e.g. EVP_MD_CTX_reset) and reused. |
| Comment by Georg Richter [ 2021-06-24 ] |
|
After some more investigation, here is a short summary: TLS protocol
Cryptography (Hashing and Encryption)
Concerns/Possible problems
|
| Comment by Vladislav Vaintroub [ 2021-11-08 ] |
|
Not much has to be changed for OpenSSL 3.0. The biggest challenge in this version is broken EVP_CIPHER_CTX_buf_noconst, though I never found it to be documented. |
| Comment by Mingli-Yu [ 2021-11-18 ] |
|
I notice the status is changed to "IN REVIEW", is the patch available now? Thanks! |
| Comment by Jan Lindström (Inactive) [ 2021-11-18 ] |
|
I hope that before anything is pushed to main branches there is done some consideration and testing done that if server uses OpenSSL 3.0 Galera would also work (using OpenSSL x where x might not be same as 3.0 or where x = 3.0). See |
| Comment by Vladislav Vaintroub [ 2021-11-18 ] |
|
I think this hope is unfounded, jplindst The server builds with OpenSSL, with or without -DWITH_WSREP. This work won't port Galera to OpenSSL 3.0. In case of negative outcome because of Galera, what should server do? Refuse to build does not make any sense, so either Galera works with OpeSSL 3.0, or we'll allow people who do not use Galera to use OpenSSL 3.0 The Server is not even aware Galera uses SSL or OpenSSL. Even if WSREP now spread over the entire codebase, Galera is logically, a plugin, which on whatever reasons, chose to build outside of the server. |
| Comment by Jan Lindström (Inactive) [ 2021-11-18 ] |
|
Some questions:
|
| Comment by Vladislav Vaintroub [ 2021-11-18 ] |
|
SSL is network level protocol, while OpenSSL 3.0 is a library implementing this protocol. Of course, different servers can be connected to different clients, as exemplified by Schannel , or GNUTLS, or OpenSSL, or for example Java clients successfully connecting to either OpenSSL, or to WolfSSL servers. What OpenSSL Galera uses might be relevant, because it is not known (and Galera team will have to to find it out), whether 2 different OpenSSL libraries can coexist peacefully inside the same mariadbd process. |
| Comment by Vladislav Vaintroub [ 2021-11-18 ] |
|
Mingli-Yu, on the right side of this page, at least in desktop JIRA variant |
| Comment by Lukas Javorsky [ 2021-11-19 ] |
|
I would just add one note from our OpenSSL team, which we got when we tried to implement the support ourselves (keep this just as heads-up). Usage of MD5... How do you ensure that the legacy provider is loaded?
If you already knew about this new change, just ignore this comment |
| Comment by Vladislav Vaintroub [ 2021-11-20 ] |
|
I do not ensure it is loaded. It appears to work, as you can check by applying the patch. |
| Comment by Mingli-Yu [ 2021-11-22 ] |
|
Thanks Vladislav very much for your info! |
| Comment by Sergei Golubchik [ 2021-12-06 ] |
|
pushed into preview-10.8- |
| Comment by Elena Stepanova [ 2022-01-19 ] |
|
I think preview-10.8-MDEV-25785-openssl3.0 as of 7cd965af can and should be pushed into the main 10.8 and released with 10.8.1. There are some limitations and can be a lot of unknowns, depending on the variety of environments and systems, which is why we need the community feedback. Current status:
Other notes:
|
| Comment by Jan Lindström (Inactive) [ 2022-01-20 ] |
|
elenst Codership reported earlier that Galera library will build with OpenSSL 3.0 but I have not tested ( |
| Comment by Elena Stepanova [ 2022-01-20 ] |
|
Galera library is obviously out of this server task, it was also stated in advance in this comment. |