mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 12:14:38 +02:00
add ctx set msg callback
This commit is contained in:
@@ -6309,6 +6309,12 @@ int InitSSL(WOLFSSL* ssl, WOLFSSL_CTX* ctx, int writeDup)
|
|||||||
XMEMCPY(ssl->sessionCtx, ctx->sessionCtx, ctx->sessionCtxSz);
|
XMEMCPY(ssl->sessionCtx, ctx->sessionCtx, ctx->sessionCtxSz);
|
||||||
ssl->cbioFlag = ctx->cbioFlag;
|
ssl->cbioFlag = ctx->cbioFlag;
|
||||||
|
|
||||||
|
ssl->protoMsgCb = ctx->protoMsgCb;
|
||||||
|
ssl->protoMsgCtx = ctx->protoMsgCtx;
|
||||||
|
|
||||||
|
if (ctx->protoMsgCb != NULL) {
|
||||||
|
ssl->toInfoOn = 1;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
InitCiphers(ssl);
|
InitCiphers(ssl);
|
||||||
|
37
src/ssl.c
37
src/ssl.c
@@ -47894,15 +47894,25 @@ int wolfSSL_set1_curves_list(WOLFSSL* ssl, const char* names)
|
|||||||
#endif /* OPENSSL_EXTRA && HAVE_ECC */
|
#endif /* OPENSSL_EXTRA && HAVE_ECC */
|
||||||
|
|
||||||
#ifdef OPENSSL_EXTRA
|
#ifdef OPENSSL_EXTRA
|
||||||
#ifndef NO_WOLFSSL_STUB
|
/* Sets a callback for when sending and receiving protocol messages.
|
||||||
|
* This callback is copied to all WOLFSSL objects created from the ctx.
|
||||||
|
*
|
||||||
|
* ctx WOLFSSL_CTX structure to set callback in
|
||||||
|
* cb callback to use
|
||||||
|
*
|
||||||
|
* return WOLFSSL_SUCCESS on success and SSL_FAILURE with error case
|
||||||
|
*/
|
||||||
int wolfSSL_CTX_set_msg_callback(WOLFSSL_CTX *ctx, SSL_Msg_Cb cb)
|
int wolfSSL_CTX_set_msg_callback(WOLFSSL_CTX *ctx, SSL_Msg_Cb cb)
|
||||||
{
|
{
|
||||||
WOLFSSL_STUB("SSL_CTX_set_msg_callback");
|
WOLFSSL_ENTER("wolfSSL_CTX_set_msg_callback");
|
||||||
(void)ctx;
|
if (ctx == NULL) {
|
||||||
(void)cb;
|
WOLFSSL_MSG("Null ctx passed in");
|
||||||
return WOLFSSL_FAILURE;
|
return WOLFSSL_FAILURE;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
ctx->protoMsgCb = cb;
|
||||||
|
return WOLFSSL_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Sets a callback for when sending and receiving protocol messages.
|
/* Sets a callback for when sending and receiving protocol messages.
|
||||||
@@ -47927,15 +47937,22 @@ int wolfSSL_set_msg_callback(WOLFSSL *ssl, SSL_Msg_Cb cb)
|
|||||||
ssl->protoMsgCb = cb;
|
ssl->protoMsgCb = cb;
|
||||||
return WOLFSSL_SUCCESS;
|
return WOLFSSL_SUCCESS;
|
||||||
}
|
}
|
||||||
#ifndef NO_WOLFSSL_STUB
|
|
||||||
|
|
||||||
|
/* set the user argument to pass to the msg callback when called
|
||||||
|
* return WOLFSSL_SUCCESS on success */
|
||||||
int wolfSSL_CTX_set_msg_callback_arg(WOLFSSL_CTX *ctx, void* arg)
|
int wolfSSL_CTX_set_msg_callback_arg(WOLFSSL_CTX *ctx, void* arg)
|
||||||
{
|
{
|
||||||
WOLFSSL_STUB("SSL_CTX_set_msg_callback_arg");
|
WOLFSSL_ENTER("wolfSSL_CTX_set_msg_callback_arg");
|
||||||
(void)ctx;
|
if (ctx == NULL) {
|
||||||
(void)arg;
|
WOLFSSL_MSG("Null WOLFSSL_CTX passed in");
|
||||||
return WOLFSSL_FAILURE;
|
return WOLFSSL_FAILURE;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
ctx->protoMsgCtx = arg;
|
||||||
|
return WOLFSSL_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int wolfSSL_set_msg_callback_arg(WOLFSSL *ssl, void* arg)
|
int wolfSSL_set_msg_callback_arg(WOLFSSL *ssl, void* arg)
|
||||||
{
|
{
|
||||||
|
@@ -31959,6 +31959,7 @@ static void test_wolfSSL_set_options(void)
|
|||||||
#endif
|
#endif
|
||||||
AssertTrue(SSL_CTX_use_certificate_file(ctx, svrCertFile, SSL_FILETYPE_PEM));
|
AssertTrue(SSL_CTX_use_certificate_file(ctx, svrCertFile, SSL_FILETYPE_PEM));
|
||||||
AssertTrue(SSL_CTX_use_PrivateKey_file(ctx, svrKeyFile, SSL_FILETYPE_PEM));
|
AssertTrue(SSL_CTX_use_PrivateKey_file(ctx, svrKeyFile, SSL_FILETYPE_PEM));
|
||||||
|
AssertTrue(SSL_CTX_set_msg_callback(ctx, msg_cb) == SSL_SUCCESS);
|
||||||
|
|
||||||
AssertNotNull(ssl = SSL_new(ctx));
|
AssertNotNull(ssl = SSL_new(ctx));
|
||||||
#if defined(HAVE_EX_DATA) || defined(FORTRESS)
|
#if defined(HAVE_EX_DATA) || defined(FORTRESS)
|
||||||
|
@@ -2916,6 +2916,10 @@ struct WOLFSSL_CTX {
|
|||||||
CertVerifyCallback verifyCertCb;
|
CertVerifyCallback verifyCertCb;
|
||||||
void* verifyCertCbArg;
|
void* verifyCertCbArg;
|
||||||
#endif /* OPENSSL_ALL */
|
#endif /* OPENSSL_ALL */
|
||||||
|
#ifdef OPENSSL_EXTRA
|
||||||
|
SSL_Msg_Cb protoMsgCb; /* inspect protocol message callback */
|
||||||
|
void* protoMsgCtx; /* user set context with msg callback */
|
||||||
|
#endif
|
||||||
word32 timeout; /* session timeout */
|
word32 timeout; /* session timeout */
|
||||||
#if defined(HAVE_ECC) || defined(HAVE_CURVE25519) || defined(HAVE_ED448)
|
#if defined(HAVE_ECC) || defined(HAVE_CURVE25519) || defined(HAVE_ED448)
|
||||||
word32 ecdhCurveOID; /* curve Ecc_Sum */
|
word32 ecdhCurveOID; /* curve Ecc_Sum */
|
||||||
|
Reference in New Issue
Block a user