Skip to content

Commit

Permalink
Replace deprecated function for OpenSSL >= 3.0 (datastax#518)
Browse files Browse the repository at this point in the history
ERR_get_error_line_data is deprecated in OpenSSL >= 3.0.
It can be replaced by the newer function ERR_get_error_all added in
OpenSSL 3.0.
  • Loading branch information
pjgeorg authored and fsaporito committed May 9, 2023
1 parent 96dbee4 commit 8f4ba12
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/ssl/ssl_openssl_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,13 @@ static void ssl_log_errors(const char* context) {
const char* data;
int flags;
int err;
while ((err = ERR_get_error_line_data(NULL, NULL, &data, &flags)) != 0) {
while ((err =
#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
ERR_get_error_all(NULL, NULL, NULL, &data, &flags)
#else
ERR_get_error_line_data(NULL, NULL, &data, &flags)
#endif
) != 0) {
char buf[256];
ERR_error_string_n(err, buf, sizeof(buf));
LOG_ERROR("%s: %s:%s", context, buf, (flags & ERR_TXT_STRING) ? data : "");
Expand All @@ -104,7 +110,13 @@ static String ssl_error_string() {
int flags;
int err;
String error;
while ((err = ERR_get_error_line_data(NULL, NULL, &data, &flags)) != 0) {
while ((err =
#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
ERR_get_error_all(NULL, NULL, NULL, &data, &flags)
#else
ERR_get_error_line_data(NULL, NULL, &data, &flags)
#endif
) != 0) {
char buf[256];
ERR_error_string_n(err, buf, sizeof(buf));
if (!error.empty()) error.push_back(',');
Expand Down

0 comments on commit 8f4ba12

Please sign in to comment.