mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-01 19:54:40 +02:00
add handshake done callback with ability to end connection
This commit is contained in:
@@ -60,6 +60,10 @@
|
|||||||
Timeval srvTo;
|
Timeval srvTo;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef NO_HANDSHAKE_DONE_CB
|
||||||
|
int myHsDoneCb(WOLFSSL* ssl, void* user_ctx);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static void NonBlockingSSL_Accept(SSL* ssl)
|
static void NonBlockingSSL_Accept(SSL* ssl)
|
||||||
{
|
{
|
||||||
@@ -534,6 +538,9 @@ while (1) { /* allow resume option */
|
|||||||
if (ssl == NULL)
|
if (ssl == NULL)
|
||||||
err_sys("unable to get SSL");
|
err_sys("unable to get SSL");
|
||||||
|
|
||||||
|
#ifndef NO_HANDSHAKE_DONE_CB
|
||||||
|
wolfSSL_SetHsDoneCb(ssl, myHsDoneCb, NULL);
|
||||||
|
#endif
|
||||||
#ifdef HAVE_CRL
|
#ifdef HAVE_CRL
|
||||||
CyaSSL_EnableCRL(ssl, 0);
|
CyaSSL_EnableCRL(ssl, 0);
|
||||||
CyaSSL_LoadCRL(ssl, crlPemDir, SSL_FILETYPE_PEM, CYASSL_CRL_MONITOR |
|
CyaSSL_LoadCRL(ssl, crlPemDir, SSL_FILETYPE_PEM, CYASSL_CRL_MONITOR |
|
||||||
@@ -712,3 +719,16 @@ while (1) { /* allow resume option */
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef NO_HANDSHAKE_DONE_CB
|
||||||
|
int myHsDoneCb(WOLFSSL* ssl, void* user_ctx)
|
||||||
|
{
|
||||||
|
(void)user_ctx;
|
||||||
|
(void)ssl;
|
||||||
|
|
||||||
|
/* printf("Notified HandShake done\n"); */
|
||||||
|
|
||||||
|
/* return negative number to end TLS connection now */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
39
src/ssl.c
39
src/ssl.c
@@ -5289,6 +5289,16 @@ int wolfSSL_dtls_got_timeout(WOLFSSL* ssl)
|
|||||||
WOLFSSL_MSG("connect state: SECOND_REPLY_DONE");
|
WOLFSSL_MSG("connect state: SECOND_REPLY_DONE");
|
||||||
|
|
||||||
case SECOND_REPLY_DONE:
|
case SECOND_REPLY_DONE:
|
||||||
|
#ifndef NO_HANDSHAKE_DONE_CB
|
||||||
|
if (ssl->hsDoneCb) {
|
||||||
|
int cbret = ssl->hsDoneCb(ssl, ssl->hsDoneCtx);
|
||||||
|
if (cbret < 0) {
|
||||||
|
ssl->error = cbret;
|
||||||
|
WOLFSSL_MSG("HandShake Done Cb don't continue error");
|
||||||
|
return SSL_FATAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* NO_HANDSHAKE_DONE_CB */
|
||||||
FreeHandshakeResources(ssl);
|
FreeHandshakeResources(ssl);
|
||||||
WOLFSSL_LEAVE("SSL_connect()", SSL_SUCCESS);
|
WOLFSSL_LEAVE("SSL_connect()", SSL_SUCCESS);
|
||||||
return SSL_SUCCESS;
|
return SSL_SUCCESS;
|
||||||
@@ -5576,6 +5586,16 @@ int wolfSSL_dtls_got_timeout(WOLFSSL* ssl)
|
|||||||
WOLFSSL_MSG("accept state ACCEPT_THIRD_REPLY_DONE");
|
WOLFSSL_MSG("accept state ACCEPT_THIRD_REPLY_DONE");
|
||||||
|
|
||||||
case ACCEPT_THIRD_REPLY_DONE :
|
case ACCEPT_THIRD_REPLY_DONE :
|
||||||
|
#ifndef NO_HANDSHAKE_DONE_CB
|
||||||
|
if (ssl->hsDoneCb) {
|
||||||
|
int cbret = ssl->hsDoneCb(ssl, ssl->hsDoneCtx);
|
||||||
|
if (cbret < 0) {
|
||||||
|
ssl->error = cbret;
|
||||||
|
WOLFSSL_MSG("HandShake Done Cb don't continue error");
|
||||||
|
return SSL_FATAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* NO_HANDSHAKE_DONE_CB */
|
||||||
FreeHandshakeResources(ssl);
|
FreeHandshakeResources(ssl);
|
||||||
WOLFSSL_LEAVE("SSL_accept()", SSL_SUCCESS);
|
WOLFSSL_LEAVE("SSL_accept()", SSL_SUCCESS);
|
||||||
return SSL_SUCCESS;
|
return SSL_SUCCESS;
|
||||||
@@ -5589,6 +5609,25 @@ int wolfSSL_dtls_got_timeout(WOLFSSL* ssl)
|
|||||||
#endif /* NO_WOLFSSL_SERVER */
|
#endif /* NO_WOLFSSL_SERVER */
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NO_HANDSHAKE_DONE_CB
|
||||||
|
|
||||||
|
int wolfSSL_SetHsDoneCb(WOLFSSL* ssl, HandShakeDoneCb cb, void* user_ctx)
|
||||||
|
{
|
||||||
|
WOLFSSL_ENTER("wolfSSL_SetHsDoneCb");
|
||||||
|
|
||||||
|
if (ssl == NULL)
|
||||||
|
return BAD_FUNC_ARG;
|
||||||
|
|
||||||
|
ssl->hsDoneCb = cb;
|
||||||
|
ssl->hsDoneCtx = user_ctx;
|
||||||
|
|
||||||
|
|
||||||
|
return SSL_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* NO_HANDSHAKE_DONE_CB */
|
||||||
|
|
||||||
|
|
||||||
int wolfSSL_Cleanup(void)
|
int wolfSSL_Cleanup(void)
|
||||||
{
|
{
|
||||||
int ret = SSL_SUCCESS;
|
int ret = SSL_SUCCESS;
|
||||||
|
@@ -2111,6 +2111,10 @@ struct WOLFSSL {
|
|||||||
void* verifyCbCtx; /* cert verify callback user ctx*/
|
void* verifyCbCtx; /* cert verify callback user ctx*/
|
||||||
VerifyCallback verifyCallback; /* cert verification callback */
|
VerifyCallback verifyCallback; /* cert verification callback */
|
||||||
void* heap; /* for user overrides */
|
void* heap; /* for user overrides */
|
||||||
|
#ifndef NO_HANDSHAKE_DONE_CB
|
||||||
|
HandShakeDoneCb hsDoneCb; /* notify user handshake done */
|
||||||
|
void* hsDoneCtx; /* user handshake cb context */
|
||||||
|
#endif
|
||||||
WOLFSSL_CIPHER cipher;
|
WOLFSSL_CIPHER cipher;
|
||||||
hmacfp hmac;
|
hmacfp hmac;
|
||||||
Ciphers encrypt;
|
Ciphers encrypt;
|
||||||
|
@@ -1375,6 +1375,12 @@ WOLFSSL_API int wolfSSL_set_SessionTicket_cb(WOLFSSL*,
|
|||||||
#define WOLFSSL_CRL_MONITOR 0x01 /* monitor this dir flag */
|
#define WOLFSSL_CRL_MONITOR 0x01 /* monitor this dir flag */
|
||||||
#define WOLFSSL_CRL_START_MON 0x02 /* start monitoring flag */
|
#define WOLFSSL_CRL_START_MON 0x02 /* start monitoring flag */
|
||||||
|
|
||||||
|
|
||||||
|
/* notify user the hanshake is done */
|
||||||
|
typedef int (*HandShakeDoneCb)(WOLFSSL*, void*);
|
||||||
|
WOLFSSL_API int wolfSSL_SetHsDoneCb(WOLFSSL*, HandShakeDoneCb, void*);
|
||||||
|
|
||||||
|
|
||||||
WOLFSSL_API int wolfSSL_PrintSessionStats(void);
|
WOLFSSL_API int wolfSSL_PrintSessionStats(void);
|
||||||
WOLFSSL_API int wolfSSL_get_session_stats(unsigned int* active,
|
WOLFSSL_API int wolfSSL_get_session_stats(unsigned int* active,
|
||||||
unsigned int* total,
|
unsigned int* total,
|
||||||
|
Reference in New Issue
Block a user