Bug #112209 The warning of deprecated function in openssl3 not be supressed
Submitted: 29 Aug 8:16 Modified: 13 Nov 23:17
Reporter: karry zhang (OCA) Email Updates:
Status: Closed Impact on me:
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:MySQL8.0,5.7 OS:Any
Assigned to: CPU Architecture:Any

[29 Aug 8:16] karry zhang
In MySQL 5.7.43, the linked OpenSSL library for MySQL Server has been upgraded from OpenSSL 1.1.1 to OpenSSL 3.0.  

However, because the compilation parameters were incorrectly set in ssl.cmake, some warnings were generated during compilation. This warning was caused by deprecated functions.

The compiling output is as follows:

/home/zhangqingrui.zqr/qingrui.zqr/MySQL-5.7/vio/viosslfactories.c:125:3: warning: ‘DH_new’ is deprecated (declared at /flash1/qingrui.zqr/MySQL-5.7/extra/openssl-3.0.9/include/openssl/dh.h:199): Since OpenSSL 3.0 [-Wdeprecated-declarations]
   if ((dh=DH_new()))
[ 11%] Building C object strings/CMakeFiles/strings.dir/ctype-tis620.c.o
/home/zhangqingrui.zqr/qingrui.zqr/MySQL-5.7/vio/viosslfactories.c:131:9: warning: ‘DH_set0_pqg’ is deprecated (declared at /flash1/qingrui.zqr/MySQL-5.7/extra/openssl-3.0.9/include/openssl/dh.h:255): Since OpenSSL 3.0 [-Wdeprecated-declarations]
         || !DH_set0_pqg(dh, p, NULL, g)
/home/zhangqingrui.zqr/qingrui.zqr/MySQL-5.7/vio/viosslfactories.c:135:7: warning: ‘DH_free’ is deprecated (declared at /flash1/qingrui.zqr/MySQL-5.7/extra/openssl-3.0.9/include/openssl/dh.h:200): Since OpenSSL 3.0 [-Wdeprecated-declarations]
/home/zhangqingrui.zqr/qingrui.zqr/MySQL-5.7/vio/viosslfactories.c: In function ‘report_errors’:
/home/zhangqingrui.zqr/qingrui.zqr/MySQL-5.7/vio/viosslfactories.c:157:3: warning: ‘ERR_get_error_line_data’ is deprecated (declared at /flash1/qingrui.zqr/MySQL-5.7/extra/openssl-3.0.9/include/openssl/err.h:425): Since OpenSSL 3.0 [-Wdeprecated-declarations]
   while ((l=ERR_get_error_line_data(&file,&line,&data,&flags)) != 0)
/home/zhangqingrui.zqr/qingrui.zqr/MySQL-5.7/vio/viosslfactories.c: In function ‘new_VioSSLFd’:
/home/zhangqingrui.zqr/qingrui.zqr/MySQL-5.7/vio/viosslfactories.c:680:5: warning: ‘DH_free’ is deprecated (declared at /flash1/qingrui.zqr/MySQL-5.7/extra/openssl-3.0.9/include/openssl/dh.h:200): Since OpenSSL 3.0 [-Wdeprecated-declarations]
[ 11%] Building C object extra/libedit/libedit-20210910-3.1/src/CMakeFiles/edit.dir/emacs.c.o
/home/zhangqingrui.zqr/qingrui.zqr/MySQL-5.7/vio/viosslfactories.c:685:3: warning: ‘DH_free’ is deprecated (declared at /flash1/qingrui.zqr/RDS-MySQL-5.7/extra/openssl-3.0.9/include/openssl/dh.h:200): Since OpenSSL 3.0 [-Wdeprecated-declarations]

and so on....

How to repeat:
Complile source code.

Suggested fix:
diff --git a/cmake/ssl.cmake b/cmake/ssl.cmake
index e03d9b171ad..6be69a52313 100644
--- a/cmake/ssl.cmake
+++ b/cmake/ssl.cmake
-        COMPILE_FLAGS "-Wno-error=deprecated-declarations")
+        COMPILE_FLAGS "-Wno-deprecated-declarations")
         COMPILE_FLAGS "/wd4996")
[29 Aug 8:37] karry zhang
Make sure to use openssl3, and compile the code.
[29 Aug 9:03] MySQL Verification Team
Hello karry zhang,

Thank you for the report and feedback.
IMHO this is duplicate of Bug #102405, please see Bug #102405.

Umesh Shastry
[29 Aug 11:26] karry zhang
I think it's not the same with Bug #102405. The problem I found was introduced in the latest relese code for 5.7.

The problem was introduced in WL#15614 OpenSSL 3.0 support in Cluster v7.5, 7.6/MySQL 5.7.

This issue will affect the latest version of 5.7 and I see the same problem will affect the latest version of 8.0. 

But for Bug #102405, it has been fixed in 8.0.

The essential of the problem is the compile flag -Wno-error=deprecated-declarations is invalid. You can try statically compiling openssl into mysql and you will see the warnings.
[29 Aug 12:59] MySQL Verification Team
Thank you for the feedback.
Can you please re-send the patch via contribution tab of this bug? Thank you.

Umesh Shastry
[30 Aug 1:19] karry zhang
Supress compiling warnings introduced by using deprecated functions in openssl3 

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: fix.txt (text/plain), 512 bytes.

[31 Aug 10:49] Tor Didriksen
Posted by developer:
We implemented this to explicitly show those warnings for our own code, as a reminder that it should be fixed. For 3rd pary code though, it should be silenced.
[13 Nov 23:17] Philip Olson
Posted by developer:
Fixed as of the upcoming MySQL Server 8.0.36 and 8.3.0 releases, and here's the proposed changelog entry from the documentation team:

For compiling on Linux, changed the "no-error=deprecated-declarations"
flag to "no-deprecated-declarations" for the OpenSSL 3 library.

Our thanks to karry zhang for the contribution.

Thank you for the bug report.