Browse Source

Remove default_timeout hook.

Of the remaining implementations left, ssl3_, dtls1_, and ssl23_, dtls1_ is
redundant and can be folded into ssl3_. ssl23_ actually isn't; it sets 5
minutes rather than 2 hours. Two hours seems to be what everything else uses
and seems a saner default. Most consumers seem to override it anyway
(SSL_CTX_set_timeout). But it is a behavior change.

The method is called at two points:
- SSL_get_default_timeout
- SSL_CTX_new

Incidentally, the latter call actually makes the former never called internally
and the value it returns a lie. SSL_get_default_timeout returns the default
timeout of the /current/ method, but in ssl_get_new_session, the timeout is
shadowed by session_timeout on the context. That is initialized when
SSL_CTX_new is called. So, unless you go out of your way to
SSL_CTX_set_timeout(0), it always overrides. (And it actually used to a
difference because, for SSL23, the SSL_CTX's method is SSL23, but, when session
creation happens, the SSL's method is the version-specific one.)

Change-Id: I331d3fd69b726242b36492402717b6d0b521c6ee
Reviewed-on: https://boringssl-review.googlesource.com/1521
Reviewed-by: Adam Langley <agl@google.com>
kris/onging/CECPQ3_patch15
David Benjamin 10 years ago
committed by Adam Langley
parent
commit
f4501347c9
7 changed files with 7 additions and 35 deletions
  1. +2
    -1
      include/openssl/ssl.h
  2. +0
    -7
      ssl/d1_lib.c
  3. +0
    -5
      ssl/s23_lib.c
  4. +0
    -7
      ssl/s3_lib.c
  5. +2
    -2
      ssl/ssl_lib.c
  6. +0
    -8
      ssl/ssl_locl.h
  7. +3
    -5
      ssl/ssl_sess.c

+ 2
- 1
include/openssl/ssl.h View File

@@ -387,7 +387,6 @@ struct ssl_method_st
int (*num_ciphers)(void);
const SSL_CIPHER *(*get_cipher)(unsigned ncipher);
const struct ssl_method_st *(*get_ssl_method)(int version);
long (*get_timeout)(void);
struct ssl3_enc_method *ssl3_enc; /* Extra SSLv3/TLS stuff */
int (*ssl_version)(void);
long (*ssl_callback_ctrl)(SSL *s, int cb_id, void (*fp)(void));
@@ -725,6 +724,8 @@ typedef struct ssl_aead_ctx_st SSL_AEAD_CTX;

#define SSL_SESSION_CACHE_MAX_SIZE_DEFAULT (1024*20)

#define SSL_DEFAULT_SESSION_TIMEOUT (2 * 60 * 60)

/* This callback type is used inside SSL_CTX, SSL, and in the functions that set
* them. It is used to override the generation of SSL/TLS session IDs in a
* server. Return value should be zero on an error, non-zero to proceed. Also,


+ 0
- 7
ssl/d1_lib.c View File

@@ -116,13 +116,6 @@ SSL3_ENC_METHOD DTLSv1_2_enc_data={
dtls1_handshake_write
};

long dtls1_default_timeout(void)
{
/* 2 hours, the 24 hours mentioned in the DTLSv1 spec
* is way too long for http, the cache would over fill */
return(60*60*2);
}

int dtls1_new(SSL *s)
{
DTLS1_STATE *d1;


+ 0
- 5
ssl/s23_lib.c View File

@@ -61,11 +61,6 @@

#include "ssl_locl.h"

long ssl23_default_timeout(void)
{
return(300);
}

int ssl23_read(SSL *s, void *buf, int len)
{
int n;


+ 0
- 7
ssl/s3_lib.c View File

@@ -1754,13 +1754,6 @@ SSL3_ENC_METHOD SSLv3_enc_data={
ssl3_handshake_write
};

long ssl3_default_timeout(void)
{
/* 2 hours, the 24 hours mentioned in the SSLv3 spec
* is way too long for http, the cache would over fill */
return(60*60*2);
}

int ssl3_num_ciphers(void)
{
return(SSL3_NUM_CIPHERS);


+ 2
- 2
ssl/ssl_lib.c View File

@@ -1033,7 +1033,7 @@ int SSL_connect(SSL *s)

long SSL_get_default_timeout(const SSL *s)
{
return(s->method->get_timeout());
return SSL_DEFAULT_SESSION_TIMEOUT;
}

int SSL_read(SSL *s,void *buf,int num)
@@ -1929,7 +1929,7 @@ SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth)
ret->session_cache_tail=NULL;

/* We take the system default */
ret->session_timeout=meth->get_timeout();
ret->session_timeout = SSL_DEFAULT_SESSION_TIMEOUT;

ret->new_session_cb=0;
ret->remove_session_cb=0;


+ 0
- 8
ssl/ssl_locl.h View File

@@ -729,7 +729,6 @@ const SSL_METHOD *func_name(void) \
ssl3_num_ciphers, \
ssl3_get_cipher, \
s_get_meth, \
ssl3_default_timeout, \
&enc_data, \
ssl_undefined_void_function, \
ssl3_callback_ctrl, \
@@ -764,7 +763,6 @@ const SSL_METHOD *func_name(void) \
ssl3_num_ciphers, \
ssl3_get_cipher, \
s_get_meth, \
ssl3_default_timeout, \
&SSLv3_enc_data, \
ssl_undefined_void_function, \
ssl3_callback_ctrl, \
@@ -799,7 +797,6 @@ const SSL_METHOD *func_name(void) \
ssl3_num_ciphers, \
ssl3_get_cipher, \
s_get_meth, \
ssl23_default_timeout, \
&TLSv1_2_enc_data, \
ssl_undefined_void_function, \
ssl3_callback_ctrl, \
@@ -835,7 +832,6 @@ const SSL_METHOD *func_name(void) \
ssl3_num_ciphers, \
dtls1_get_cipher, \
s_get_meth, \
dtls1_default_timeout, \
&enc_data, \
ssl_undefined_void_function, \
ssl3_callback_ctrl, \
@@ -963,7 +959,6 @@ int ssl3_pending(const SSL *s);

void ssl3_record_sequence_update(unsigned char *seq);
int ssl3_do_change_cipher_spec(SSL *ssl);
long ssl3_default_timeout(void );

void ssl3_set_handshake_header(SSL *s, int htype, unsigned long len);
int ssl3_handshake_write(SSL *s);
@@ -971,9 +966,7 @@ int ssl3_handshake_write(SSL *s);
int ssl23_read(SSL *s, void *buf, int len);
int ssl23_peek(SSL *s, void *buf, int len);
int ssl23_write(SSL *s, const void *buf, int len);
long ssl23_default_timeout(void );

long tls1_default_timeout(void);
int dtls1_do_write(SSL *s,int type);
int ssl3_read_n(SSL *s, int n, int max, int extend);
int dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek);
@@ -999,7 +992,6 @@ void dtls1_clear_record_buffer(SSL *s);
void dtls1_get_message_header(unsigned char *data, struct hm_header_st *msg_hdr);
void dtls1_get_ccs_header(unsigned char *data, struct ccs_header_st *ccs_hdr);
void dtls1_reset_seq_numbers(SSL *s, int rw);
long dtls1_default_timeout(void);
int dtls1_check_timeout_num(SSL *s);
int dtls1_handle_timeout(SSL *s);
const SSL_CIPHER *dtls1_get_cipher(unsigned int u);


+ 3
- 5
ssl/ssl_sess.c View File

@@ -209,7 +209,7 @@ SSL_SESSION *SSL_SESSION_new(void)

ss->verify_result = 1; /* avoid 0 (= X509_V_OK) just in case */
ss->references=1;
ss->timeout=60*5+4; /* 5 minute timeout by default */
ss->timeout = SSL_DEFAULT_SESSION_TIMEOUT;
ss->time=(unsigned long)time(NULL);
ss->prev=NULL;
ss->next=NULL;
@@ -282,10 +282,8 @@ int ssl_get_new_session(SSL *s, int session)

if ((ss=SSL_SESSION_new()) == NULL) return(0);

/* If the context has a default timeout, use it */
if (s->session_ctx->session_timeout == 0)
ss->timeout=SSL_get_default_timeout(s);
else
/* If the context has a default timeout, use it over the default. */
if (s->session_ctx->session_timeout != 0)
ss->timeout=s->session_ctx->session_timeout;

if (s->session != NULL)


Loading…
Cancel
Save