Fix [-Wdeprecated-declarations] warning in ERR_load_BIO_strings when building YDBEncrypt with OpenSSL 3.0
Background
-
When building YDBEncrypt on a Ubuntu 22.04 system (which has OpenSSL 3.0), we noticed the following warning.
gtm_tls_impl.c:523:9: warning: 'ERR_load_BIO_strings' is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations] 523 | ERR_load_BIO_strings(); | ^~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/openssl/cryptoerr.h:17, from /usr/include/openssl/crypto.h:38, from /usr/include/openssl/bio.h:30, from /usr/include/openssl/err.h:29, from gtm_tls_impl.c:29: /usr/include/openssl/cryptoerr_legacy.h:31:27: note: declared here 31 | OSSL_DEPRECATEDIN_3_0 int ERR_load_BIO_strings(void); | ^~~~~~~~~~~~~~~~~~~~
Issue
-
https://www.openssl.org/docs/man3.0/man7/migration_guide.html#Deprecated-function-mappings says the following about warnings in
ERR_load_BIO_strings
.-
ERR_load_*()
, ERR_func_error_string(), ERR_get_error_line(), ERR_get_error_line_data(), ERR_get_state() - OpenSSL now loads error strings automatically so these functions are not needed.
-
Fix
- The
ERR_load_BIO_strings()
invocation is now done only ifOPENSSL_VERSION_MAJOR
is less than3
.
Notes
-
Note that there were a total of 3 warnings when building YDBEncrypt using OpenSSL 3.0. Only 1 of them is fixed in this commit. The other 2 will be fixed in later commits as they involve non-trivial changes. Those warnings are pasted below for reference.
-
Warning that
SSL_set_tmp_dh_callback
is deprecated.gtm_tls_impl.c: In function 'gtm_tls_socket': gtm_tls_impl.c:1350:25: warning: 'SSL_set_tmp_dh_callback' is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations] 1350 | SSL_set_tmp_dh_callback(ssl, tmp_dh_callback); | ^~~~~~~~~~~~~~~~~~~~~~~ In file included from gtm_tls_impl.c:30: /usr/include/openssl/ssl.h:2220:6: note: declared here 2220 | void SSL_set_tmp_dh_callback(SSL *ssl, | ^~~~~~~~~~~~~~~~~~~~~~~
-
Warning that
PEM_read_bio_DHparams
is deprecated.gtm_tls_impl.c: In function 'read_dhparams': gtm_tls_impl.c:444:9: warning: 'PEM_read_bio_DHparams' is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations] 444 | if (NULL == (dh = (PEM_read_bio_DHparams(bio, NULL, NULL, NULL)))) | ^~ In file included from /usr/include/openssl/ssl.h:36, from gtm_tls_impl.c:30: /usr/include/openssl/pem.h:469:1: note: declared here 469 | DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, DHparams, DH) | ^~~~~~~~~~~~~~~~~~~