mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 18:57:27 +02:00
Add some missing logs and implement WOLFSSL_MSG_EX()
WOLFSSL_MSG_EX() uses XVSNPRINTF to allow for formatted strings to be printed. It uses a 100 byte internal stack buffer to format the log message.
This commit is contained in:
@ -12114,6 +12114,8 @@ int ProcessPeerCerts(WOLFSSL* ssl, byte* input, word32* inOutIdx,
|
||||
args->exts[args->totalCerts].buffer = input + args->idx;
|
||||
args->idx += extSz;
|
||||
listSz -= extSz + OPAQUE16_LEN;
|
||||
WOLFSSL_MSG_EX("\tParsing %d bytes of cert extensions",
|
||||
args->exts[args->totalCerts].length);
|
||||
ret = TLSX_Parse(ssl, args->exts[args->totalCerts].buffer,
|
||||
(word16)args->exts[args->totalCerts].length,
|
||||
certificate, NULL);
|
||||
@ -12601,12 +12603,15 @@ int ProcessPeerCerts(WOLFSSL* ssl, byte* input, word32* inOutIdx,
|
||||
if (args->fatal == 0 && ret == 0) {
|
||||
int doLookup = 1;
|
||||
|
||||
WOLFSSL_MSG("Checking if ocsp needed");
|
||||
|
||||
if (ssl->options.side == WOLFSSL_CLIENT_END) {
|
||||
#ifdef HAVE_CERTIFICATE_STATUS_REQUEST
|
||||
if (ssl->status_request) {
|
||||
args->fatal = (TLSX_CSR_InitRequest(ssl->extensions,
|
||||
args->dCert, ssl->heap) != 0);
|
||||
doLookup = 0;
|
||||
WOLFSSL_MSG("\tHave status request");
|
||||
#if defined(WOLFSSL_TLS13)
|
||||
if (ssl->options.tls1_3) {
|
||||
TLSX* ext = TLSX_Find(ssl->extensions,
|
||||
@ -12635,6 +12640,7 @@ int ProcessPeerCerts(WOLFSSL* ssl, byte* input, word32* inOutIdx,
|
||||
args->fatal = (TLSX_CSR2_InitRequests(ssl->extensions,
|
||||
args->dCert, 1, ssl->heap) != 0);
|
||||
doLookup = 0;
|
||||
WOLFSSL_MSG("\tHave status request v2");
|
||||
}
|
||||
#endif /* HAVE_CERTIFICATE_STATUS_REQUEST_V2 */
|
||||
}
|
||||
|
@ -2709,6 +2709,8 @@ int wolfSSL_CTX_UseTruncatedHMAC(WOLFSSL_CTX* ctx)
|
||||
|
||||
int wolfSSL_UseOCSPStapling(WOLFSSL* ssl, byte status_type, byte options)
|
||||
{
|
||||
WOLFSSL_ENTER("wolfSSL_UseOCSPStapling");
|
||||
|
||||
if (ssl == NULL || ssl->options.side != WOLFSSL_CLIENT_END)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
@ -2720,6 +2722,8 @@ int wolfSSL_UseOCSPStapling(WOLFSSL* ssl, byte status_type, byte options)
|
||||
int wolfSSL_CTX_UseOCSPStapling(WOLFSSL_CTX* ctx, byte status_type,
|
||||
byte options)
|
||||
{
|
||||
WOLFSSL_ENTER("wolfSSL_CTX_UseOCSPStapling");
|
||||
|
||||
if (ctx == NULL || ctx->method->side != WOLFSSL_CLIENT_END)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
@ -17966,6 +17970,8 @@ size_t wolfSSL_get_client_random(const WOLFSSL* ssl, unsigned char* out,
|
||||
#if defined(OPENSSL_EXTRA) || defined(WOLFSSL_WPAS_SMALL)
|
||||
int wolfSSL_clear(WOLFSSL* ssl)
|
||||
{
|
||||
WOLFSSL_ENTER("wolfSSL_clear");
|
||||
|
||||
if (ssl == NULL) {
|
||||
return WOLFSSL_FAILURE;
|
||||
}
|
||||
|
@ -364,6 +364,27 @@ static void wolfssl_log(const int logLevel, const char *const logMessage)
|
||||
}
|
||||
|
||||
#ifndef WOLFSSL_DEBUG_ERRORS_ONLY
|
||||
#ifdef __clang__
|
||||
/* tell clang argument 1 is format */
|
||||
__attribute__((__format__ (__printf__, 1, 0)))
|
||||
#endif
|
||||
#if !defined(_WIN32) && defined(XVSNPRINTF)
|
||||
#include <stdarg.h> /* for var args */
|
||||
void WOLFSSL_MSG_EX(const char* fmt, ...)
|
||||
{
|
||||
if (loggingEnabled) {
|
||||
char msg[100];
|
||||
int written;
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
written = XVSNPRINTF(msg, sizeof(msg), fmt, args);
|
||||
va_end(args);
|
||||
if (written > 0)
|
||||
wolfssl_log(INFO_LOG , msg);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void WOLFSSL_MSG(const char* msg)
|
||||
{
|
||||
if (loggingEnabled)
|
||||
|
@ -162,7 +162,11 @@ WOLFSSL_API void wolfSSL_Debugging_OFF(void);
|
||||
#define WOLFSSL_STUB(m) \
|
||||
WOLFSSL_MSG(WOLFSSL_LOG_CAT(wolfSSL Stub, m, not implemented))
|
||||
WOLFSSL_API int WOLFSSL_IS_DEBUG_ON(void);
|
||||
|
||||
#if !defined(_WIN32) && defined(XVSNPRINTF)
|
||||
WOLFSSL_API void WOLFSSL_MSG_EX(const char* fmt, ...);
|
||||
#else
|
||||
#define WOLFSSL_MSG_EX(m, ...)
|
||||
#endif
|
||||
WOLFSSL_API void WOLFSSL_MSG(const char* msg);
|
||||
WOLFSSL_API void WOLFSSL_BUFFER(const byte* buffer, word32 length);
|
||||
|
||||
@ -173,6 +177,7 @@ WOLFSSL_API void wolfSSL_Debugging_OFF(void);
|
||||
#define WOLFSSL_STUB(m)
|
||||
#define WOLFSSL_IS_DEBUG_ON() 0
|
||||
|
||||
#define WOLFSSL_MSG_EX(m, ...)
|
||||
#define WOLFSSL_MSG(m)
|
||||
#define WOLFSSL_BUFFER(b, l)
|
||||
|
||||
|
Reference in New Issue
Block a user