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

Miscellaneous changes for OpenSSL 3.0 support #468

Merged
merged 13 commits into from
Oct 24, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ossl.c: use ERR_get_error_all() if available
OpenSSL 3.0 deprecated ERR_get_error_line_data() in favor of
ERR_get_error_all(), as part of the error queue structure changes.
rhenium committed Oct 24, 2021
commit 8e98d2ecc8981fbd2782cf19113c1d3ab90329ed
1 change: 1 addition & 0 deletions ext/openssl/extconf.rb
Original file line number Diff line number Diff line change
@@ -172,6 +172,7 @@ def find_openssl_library

# added in 3.0.0
have_func("SSL_set0_tmp_dh_pkey")
have_func("ERR_get_error_all")

Logging::message "=== Checking done. ===\n"

42 changes: 23 additions & 19 deletions ext/openssl/ossl.c
Original file line number Diff line number Diff line change
@@ -313,27 +313,31 @@ void
ossl_clear_error(void)
{
if (dOSSL == Qtrue) {
unsigned long e;
const char *file, *data, *errstr;
int line, flags;

while ((e = ERR_get_error_line_data(&file, &line, &data, &flags))) {
errstr = ERR_error_string(e, NULL);
if (!errstr)
errstr = "(null)";

if (flags & ERR_TXT_STRING) {
if (!data)
data = "(null)";
rb_warn("error on stack: %s (%s)", errstr, data);
}
else {
rb_warn("error on stack: %s", errstr);
}
}
unsigned long e;
const char *file, *data, *func, *lib, *reason;
char append[256] = "";
int line, flags;

#ifdef HAVE_ERR_GET_ERROR_ALL
while ((e = ERR_get_error_all(&file, &line, &func, &data, &flags))) {
#else
while ((e = ERR_get_error_line_data(&file, &line, &data, &flags))) {
func = ERR_func_error_string(e);
#endif
lib = ERR_lib_error_string(e);
reason = ERR_reason_error_string(e);

if (flags & ERR_TXT_STRING) {
if (!data)
data = "(null)";
snprintf(append, sizeof(append), " (%s)", data);
}
rb_warn("error on stack: error:%08lX:%s:%s:%s%s", e, lib ? lib : "",
func ? func : "", reason ? reason : "", append);
}
}
else {
ERR_clear_error();
ERR_clear_error();
}
}