From 8c70b1152873a14fac83462f3a40fdabf36b4006 Mon Sep 17 00:00:00 2001 From: toddouska Date: Fri, 14 Jun 2013 15:29:18 -0700 Subject: [PATCH] add newSession flag to SetServerID to do full handshake w/ new session --- cyassl/ssl.h | 4 ++-- src/ssl.c | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/cyassl/ssl.h b/cyassl/ssl.h index 3ed5bc457..9989674d3 100644 --- a/cyassl/ssl.h +++ b/cyassl/ssl.h @@ -217,8 +217,8 @@ CYASSL_API int CyaSSL_get_alert_history(CYASSL*, CYASSL_ALERT_HISTORY *); CYASSL_API int CyaSSL_set_session(CYASSL* ssl,CYASSL_SESSION* session); CYASSL_API CYASSL_SESSION* CyaSSL_get_session(CYASSL* ssl); CYASSL_API void CyaSSL_flush_sessions(CYASSL_CTX *ctx, long tm); -CYASSL_API int CyaSSL_SetServerID(CYASSL* ssl, const unsigned char*,int); - +CYASSL_API int CyaSSL_SetServerID(CYASSL* ssl, const unsigned char*, + int, int); typedef int (*VerifyCallback)(int, CYASSL_X509_STORE_CTX*); typedef int (*pem_password_cb)(char*, int, int, void*); diff --git a/src/ssl.c b/src/ssl.c index 3f65e6138..02f89afee 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -2788,22 +2788,25 @@ int CyaSSL_set_session(CYASSL* ssl, CYASSL_SESSION* session) #ifndef NO_CLIENT_CACHE -/* Assocaite client session with serverID, find existing or store for saving +/* Associate client session with serverID, find existing or store for saving + if newSession flag on, don't reuse existing session SSL_SUCCESS on ok */ -int CyaSSL_SetServerID(CYASSL* ssl, const byte* id, int len) +int CyaSSL_SetServerID(CYASSL* ssl, const byte* id, int len, int newSession) { - CYASSL_SESSION* session; + CYASSL_SESSION* session = NULL; CYASSL_ENTER("CyaSSL_SetServerID"); if (ssl == NULL || id == NULL || len <= 0) return BAD_FUNC_ARG; - session = GetSessionClient(ssl, id, len); - if (session) { - if (SetSession(ssl, session) != SSL_SUCCESS) { - CYASSL_MSG("SetSession failed"); - session = NULL; + if (newSession == 0) { + session = GetSessionClient(ssl, id, len); + if (session) { + if (SetSession(ssl, session) != SSL_SUCCESS) { + CYASSL_MSG("SetSession failed"); + session = NULL; + } } }