aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFCrypto_openssl.cc
diff options
context:
space:
mode:
authorDean Scarff <deanscarff@google.com>2020-07-02 04:40:33 +0200
committerJay Berkenbilt <jberkenbilt@users.noreply.github.com>2020-10-17 01:58:11 +0200
commit2ff84aa2c95eba295e374f239b47e314d59e59cb (patch)
tree2a21ce7bec737abb32e1ab79f9b910b60f17d3e4 /libqpdf/QPDFCrypto_openssl.cc
parent3fc7c99d02f9ba3045a7f085bf8f74132c174b59 (diff)
downloadqpdf-2ff84aa2c95eba295e374f239b47e314d59e59cb.tar.zst
Include detailed OpenSSL error messages
Fixes qpdf/qpdf#450
Diffstat (limited to 'libqpdf/QPDFCrypto_openssl.cc')
-rw-r--r--libqpdf/QPDFCrypto_openssl.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/libqpdf/QPDFCrypto_openssl.cc b/libqpdf/QPDFCrypto_openssl.cc
index b1866b5d..358040d5 100644
--- a/libqpdf/QPDFCrypto_openssl.cc
+++ b/libqpdf/QPDFCrypto_openssl.cc
@@ -2,6 +2,9 @@
#include <cstring>
#include <stdexcept>
+#include <string>
+
+#include <openssl/err.h>
#include <qpdf/QIntC.hh>
@@ -18,8 +21,15 @@ check_openssl(int status)
{
if (status != 1)
{
- throw std::runtime_error("openssl error");
+ // OpenSSL creates a "queue" of errors; copy the first (innermost)
+ // error to the exception message.
+ char buf[256] = "";
+ ERR_error_string_n(ERR_get_error(), buf, sizeof(buf));
+ std::string what = "OpenSSL error: ";
+ what += buf;
+ throw std::runtime_error(what);
}
+ ERR_clear_error();
}
QPDFCrypto_openssl::QPDFCrypto_openssl() :