mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 12:20:00 +01:00
LibCrypto: Print all descriptive OpenSSL errors
The code was printing one error message only, but multiple can be generated in one call. Additionally, using this builtin produces a much more descriptive output.
This commit is contained in:
parent
c580763743
commit
de6f77e7e3
|
|
@ -13,14 +13,17 @@
|
|||
|
||||
namespace Crypto {
|
||||
|
||||
static int openssl_print_errors(char const* str, size_t len, [[maybe_unused]] void* u)
|
||||
{
|
||||
dbgln("{}", StringView { str, len });
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define OPENSSL_TRY_PTR(...) \
|
||||
({ \
|
||||
auto* _temporary_result = (__VA_ARGS__); \
|
||||
if (!_temporary_result) [[unlikely]] { \
|
||||
auto err = ERR_get_error(); \
|
||||
VERIFY(err); \
|
||||
auto* err_message = ERR_error_string(err, nullptr); \
|
||||
dbgln("OpenSSL error: {}", err_message); \
|
||||
ERR_print_errors_cb(openssl_print_errors, nullptr); \
|
||||
return Error::from_string_literal(#__VA_ARGS__ " failed"); \
|
||||
} \
|
||||
_temporary_result; \
|
||||
|
|
@ -30,10 +33,7 @@ namespace Crypto {
|
|||
({ \
|
||||
auto _temporary_result = (__VA_ARGS__); \
|
||||
if (_temporary_result != 1) [[unlikely]] { \
|
||||
auto err = ERR_get_error(); \
|
||||
VERIFY(err); \
|
||||
auto* err_message = ERR_error_string(err, nullptr); \
|
||||
dbgln("OpenSSL error: {}", err_message); \
|
||||
ERR_print_errors_cb(openssl_print_errors, nullptr); \
|
||||
return Error::from_string_literal(#__VA_ARGS__ " failed"); \
|
||||
} \
|
||||
_temporary_result; \
|
||||
|
|
|
|||
|
|
@ -14,8 +14,7 @@ typedef struct evp_md_ctx_st EVP_MD_CTX;
|
|||
typedef struct evp_pkey_st EVP_PKEY;
|
||||
typedef struct evp_pkey_ctx_st EVP_PKEY_CTX;
|
||||
|
||||
long unsigned int ERR_get_error();
|
||||
char* ERR_error_string(long unsigned int, char*);
|
||||
void ERR_print_errors_cb(int (*cb)(char const* str, size_t len, void* u), void* u);
|
||||
|
||||
EVP_MD_CTX* EVP_MD_CTX_new();
|
||||
void EVP_MD_CTX_free(EVP_MD_CTX*);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user