allow changing session timeout for ctx and ssl

pull/1/head
toddouska 2012-02-14 17:46:04 -08:00
parent f8e610493c
commit ec85d47a73
4 changed files with 33 additions and 10 deletions

View File

@ -620,6 +620,7 @@ struct CYASSL_CTX {
CallbackIOSend CBIOSend;
CallbackCACache caCacheCallback; /* CA cache addition callback */
VerifyCallback verifyCallback; /* cert verification callback */
word32 timeout; /* session timeout */
#ifdef HAVE_ECC
word16 eccTempKeySz; /* in octets 20 - 66 */
#endif
@ -1046,6 +1047,7 @@ struct CYASSL {
void* heap; /* for user overrides */
RecordLayerHeader curRL;
word16 curSize;
word32 timeout; /* session timeout */
CYASSL_CIPHER cipher;
#ifdef HAVE_LIBZ
z_stream c_stream; /* compression stream */

View File

@ -359,7 +359,6 @@ CYASSL_API void CyaSSL_CTX_set_default_passwd_cb_userdata(CYASSL_CTX*,
CYASSL_API void CyaSSL_CTX_set_default_passwd_cb(CYASSL_CTX*, pem_password_cb);
CYASSL_API long CyaSSL_CTX_set_timeout(CYASSL_CTX*, long);
CYASSL_API void CyaSSL_CTX_set_info_callback(CYASSL_CTX*, void (*)(void));
CYASSL_API unsigned long CyaSSL_ERR_peek_error(void);
@ -655,6 +654,9 @@ CYASSL_API int CyaSSL_negotiate(CYASSL* ssl);
/* turn on CyaSSL data compression */
CYASSL_API int CyaSSL_set_compression(CYASSL* ssl);
CYASSL_API int CyaSSL_set_timeout(CYASSL*, unsigned int);
CYASSL_API int CyaSSL_CTX_set_timeout(CYASSL_CTX*, unsigned int);
/* get CyaSSL peer X509_CHAIN */
CYASSL_API CYASSL_X509_CHAIN* CyaSSL_get_peer_chain(CYASSL* ssl);
/* peer chain count */

View File

@ -351,6 +351,8 @@ int InitSSL_Ctx(CYASSL_CTX* ctx, CYASSL_METHOD* method)
ctx->userdata = 0;
#endif /* OPENSSL_EXTRA */
ctx->timeout = DEFAULT_TIMEOUT;
#ifndef CYASSL_USER_IO
ctx->CBIORecv = EmbedReceive;
ctx->CBIOSend = EmbedSend;
@ -710,6 +712,7 @@ int InitSSL(CYASSL* ssl, CYASSL_CTX* ctx)
ecc_init(&ssl->eccTempKey);
#endif
ssl->timeout = ctx->timeout;
ssl->rfd = -1; /* set to invalid descriptor */
ssl->wfd = -1;
ssl->biord = 0;

View File

@ -2133,6 +2133,30 @@ void CyaSSL_flush_sessions(CYASSL_CTX* ctx, long tm)
}
/* set ssl session timeout in seconds */
int CyaSSL_set_timeout(CYASSL* ssl, unsigned int to)
{
if (ssl == NULL)
return BAD_FUNC_ARG;
ssl->timeout = to;
return SSL_SUCCESS;
}
/* set ctx session timeout in seconds */
int CyaSSL_CTX_set_timeout(CYASSL_CTX* ctx, unsigned int to)
{
if (ctx == NULL)
return BAD_FUNC_ARG;
ctx->timeout = to;
return SSL_SUCCESS;
}
CYASSL_SESSION* GetSession(CYASSL* ssl, byte* masterSecret)
{
CYASSL_SESSION* ret = 0;
@ -2216,7 +2240,7 @@ int AddSession(CYASSL* ssl)
XMEMCPY(SessionCache[row].Sessions[idx].sessionID, ssl->arrays.sessionID,
ID_LEN);
SessionCache[row].Sessions[idx].timeout = DEFAULT_TIMEOUT;
SessionCache[row].Sessions[idx].timeout = ssl->timeout;
SessionCache[row].Sessions[idx].bornOn = LowResTimer();
#ifdef SESSION_CERTS
@ -4306,14 +4330,6 @@ int CyaSSL_set_compression(CYASSL* ssl)
}
long CyaSSL_CTX_set_timeout(CYASSL_CTX* ctx, long to)
{
(void)ctx;
(void)to;
return 0;
}
void CyaSSL_CTX_set_info_callback(CYASSL_CTX* ctx, void (*f)(void))
{
(void)ctx;