diff options
author | rhe <rhe@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-18 04:07:45 +0000 |
---|---|---|
committer | rhe <rhe@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-18 04:07:45 +0000 |
commit | d66e88dc2c9fc3b6acdf98fa88ad04ec0de82622 (patch) | |
tree | 5bd73f1b350c61fbabf6f5f31a6f451450e52ca4 /ext/openssl/ossl.c | |
parent | 3d42a665d889bfecedd94ba2534e7e7a3f3ac9eb (diff) | |
download | ruby-d66e88dc2c9fc3b6acdf98fa88ad04ec0de82622.tar.gz |
openssl: report errors in OpenSSL error queue when clear it
* ext/openssl/ossl.c (ossl_clear_error): Extracted from
ossl_make_error(). This prints errors in the OpenSSL error queue if
OpenSSL.debug is true, and clears the queue.
(ossl_make_error): use ossl_clear_error().
* ext/openssl/ossl.h: add prototype declaration of ossl_make_error().
(OSSL_BIO_reset) use ossl_clear_error() to clear the queue. Clearing
silently makes debugging difficult.
* ext/openssl/ossl_engine.c (ossl_engine_s_by_id): ditto.
* ext/openssl/ossl_ns_spki.c (ossl_spki_initialize): ditto.
* ext/openssl/ossl_pkcs7.c (ossl_pkcs7_verify): ditto.
* ext/openssl/ossl_pkey_dsa.c (ossl_dsa_initialize): ditto.
* ext/openssl/ossl_pkey_ec.c (ossl_ec_key_initialize): ditto.
(ossl_ec_group_initialize): ditto.
* ext/openssl/ossl_ssl.c (ossl_ssl_shutdown): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/openssl/ossl.c')
-rw-r--r-- | ext/openssl/ossl.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c index d03dfa7ad0..ac82815162 100644 --- a/ext/openssl/ossl.c +++ b/ext/openssl/ossl.c @@ -318,12 +318,7 @@ ossl_make_error(VALUE exc, const char *fmt, va_list args) rb_str_cat2(str, msg ? msg : "(null)"); } } - if (dOSSL == Qtrue){ /* show all errors on the stack */ - while ((e = ERR_get_error()) != 0){ - rb_warn("error on stack: %s", ERR_error_string(e, NULL)); - } - } - ERR_clear_error(); + ossl_clear_error(); if (NIL_P(str)) str = rb_str_new(0, 0); return rb_exc_new3(exc, str); @@ -351,6 +346,18 @@ ossl_exc_new(VALUE exc, const char *fmt, ...) return err; } +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)); + } + } + ERR_clear_error(); +} + /* * call-seq: * OpenSSL.errors -> [String...] |