aboutsummaryrefslogtreecommitdiffstats
path: root/ext/openssl/ossl.h
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-05-18 01:02:11 +0900
committerKazuki Yamaguchi <k@rhe.jp>2016-05-18 12:56:28 +0900
commitf7bfb15529d25cf247dcaaa8ccad431c11779c3e (patch)
tree5bd73f1b350c61fbabf6f5f31a6f451450e52ca4 /ext/openssl/ossl.h
parentdd644f3c01bb4a8003d70f352793b78574697d88 (diff)
downloadruby-f7bfb15529d25cf247dcaaa8ccad431c11779c3e.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.
Diffstat (limited to 'ext/openssl/ossl.h')
-rw-r--r--ext/openssl/ossl.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/openssl/ossl.h b/ext/openssl/ossl.h
index 3be01b0cb6..a31ca95194 100644
--- a/ext/openssl/ossl.h
+++ b/ext/openssl/ossl.h
@@ -154,8 +154,10 @@ int ossl_pem_passwd_cb(char *, int, int, void *);
* Clear BIO* with this in PEM/DER fallback scenarios to avoid decoding
* errors piling up in OpenSSL::Errors
*/
-#define OSSL_BIO_reset(bio) (void)BIO_reset((bio)); \
- ERR_clear_error();
+#define OSSL_BIO_reset(bio) do { \
+ (void)BIO_reset((bio)); \
+ ossl_clear_error(); \
+} while (0)
/*
* ERRor messages
@@ -163,6 +165,8 @@ int ossl_pem_passwd_cb(char *, int, int, void *);
#define OSSL_ErrMsg() ERR_reason_error_string(ERR_get_error())
NORETURN(void ossl_raise(VALUE, const char *, ...));
VALUE ossl_exc_new(VALUE, const char *, ...);
+/* Clear OpenSSL error queue. If dOSSL is set, rb_warn() them. */
+void ossl_clear_error(void);
/*
* Verify callback