aboutsummaryrefslogtreecommitdiffstats
path: root/ext/openssl
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-10-16 22:01:59 +0900
committerKazuki Yamaguchi <k@rhe.jp>2016-10-16 22:12:56 +0900
commit9e0df41444612d794300f2a7bd26d515f6c4662c (patch)
tree4f87c54e811671cc243c8fad8df554c4f40559a8 /ext/openssl
parentc0c7db9336a4dc99e85192ce29ff549b8d92f8fc (diff)
downloadruby-openssl-9e0df41444612d794300f2a7bd26d515f6c4662c.tar.gz
Make OpenSSL.debug more verbose
Print more error data in ossl_clear_error(). OpenSSL's error queue item can additionally have an associated data. The data may contain helpful information for debugging.
Diffstat (limited to 'ext/openssl')
-rw-r--r--ext/openssl/ossl.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c
index a9000f25..07238780 100644
--- a/ext/openssl/ossl.c
+++ b/ext/openssl/ossl.c
@@ -370,12 +370,28 @@ void
ossl_clear_error(void)
{
if (dOSSL == Qtrue) {
- long e;
- while ((e = ERR_get_error())) {
- rb_warn("error on stack: %s", ERR_error_string(e, NULL));
+ 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);
+ }
}
}
- ERR_clear_error();
+ else {
+ ERR_clear_error();
+ }
}
/*