summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/manager/common/openssl-error-handler.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/manager/common/openssl-error-handler.cpp b/src/manager/common/openssl-error-handler.cpp
index 40c3d2b4..e8649c10 100644
--- a/src/manager/common/openssl-error-handler.cpp
+++ b/src/manager/common/openssl-error-handler.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2017 - 2019 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,6 +33,7 @@
#include <sstream>
#include <string>
#include <utility>
+#include <vector>
#define OPENSSL_SUCCESS 1
@@ -57,19 +58,19 @@ const char *ckm_debug_translate_error(int err)
void errorDump()
{
- BIO *bio = BIO_new(BIO_s_mem());
- ERR_print_errors(bio);
- char *buf = NULL;
- long len = BIO_get_mem_data(bio, &buf);
- if(len < 0) {
- LogError("Fail in BIO_get_mem_data()");
+ typedef std::unique_ptr<BIO, std::function<void(BIO *)>> BioUniquePtr;
+ BioUniquePtr bio(BIO_new(BIO_s_mem()), BIO_free_all);
+ if (!bio.get())
return;
+
+ ERR_print_errors(bio.get());
+
+ std::vector<char> message(1024);
+ int len = BIO_read(bio.get(), message.data(), message.size());
+ if (len > 0) {
+ message.resize(len);
+ LogError(std::string(message.begin(), message.end()));
}
- size_t length = static_cast<size_t>(len);
- BIO_free(bio);
- std::string ret(buf, length);
- free(buf);
- LogError(ret);
}
void errorHandle(const char *file, int line, const char *function, int openssl_ret)