|
|
aa64c41 |
*) In the SSL/TLS server implementation, be strict about session ID
|
|
|
aa64c41 |
context matching (which matters if an application uses a single
|
|
|
aa64c41 |
external cache for different purposes). Previously,
|
|
|
aa64c41 |
out-of-context reuse was forbidden only if SSL_VERIFY_PEER was
|
|
|
aa64c41 |
set. This did ensure strict client verification, but meant that,
|
|
|
aa64c41 |
with applications using a single external cache for quite
|
|
|
aa64c41 |
different requirements, clients could circumvent ciphersuite
|
|
|
aa64c41 |
restrictions for a given session ID context by starting a session
|
|
|
aa64c41 |
in a different context.
|
|
|
aa64c41 |
diff -up openssl-0.9.7a/ssl/ssl_sess.c.strict-matching openssl-0.9.7a/ssl/ssl_sess.c
|
|
|
aa64c41 |
--- openssl-0.9.7a/ssl/ssl_sess.c.strict-matching 2002-11-28 09:09:03.000000000 +0100
|
|
|
aa64c41 |
+++ openssl-0.9.7a/ssl/ssl_sess.c 2007-08-02 16:17:29.000000000 +0200
|
|
|
aa64c41 |
@@ -322,33 +322,35 @@ int ssl_get_prev_session(SSL *s, unsigne
|
|
|
aa64c41 |
|
|
|
aa64c41 |
/* Now ret is non-NULL, and we own one of its reference counts. */
|
|
|
aa64c41 |
|
|
|
aa64c41 |
- if((s->verify_mode&SSL_VERIFY_PEER)
|
|
|
aa64c41 |
- && (!s->sid_ctx_length || ret->sid_ctx_length != s->sid_ctx_length
|
|
|
aa64c41 |
- || memcmp(ret->sid_ctx,s->sid_ctx,ret->sid_ctx_length)))
|
|
|
aa64c41 |
- {
|
|
|
aa64c41 |
+ if (ret->sid_ctx_length != s->sid_ctx_length
|
|
|
aa64c41 |
+ || memcmp(ret->sid_ctx,s->sid_ctx,ret->sid_ctx_length))
|
|
|
aa64c41 |
+ {
|
|
|
aa64c41 |
/* We've found the session named by the client, but we don't
|
|
|
aa64c41 |
* want to use it in this context. */
|
|
|
aa64c41 |
-
|
|
|
aa64c41 |
- if (s->sid_ctx_length == 0)
|
|
|
aa64c41 |
- {
|
|
|
aa64c41 |
- /* application should have used SSL[_CTX]_set_session_id_context
|
|
|
aa64c41 |
- * -- we could tolerate this and just pretend we never heard
|
|
|
aa64c41 |
- * of this session, but then applications could effectively
|
|
|
aa64c41 |
- * disable the session cache by accident without anyone noticing */
|
|
|
aa64c41 |
|
|
|
aa64c41 |
- SSLerr(SSL_F_SSL_GET_PREV_SESSION,SSL_R_SESSION_ID_CONTEXT_UNINITIALIZED);
|
|
|
aa64c41 |
- fatal = 1;
|
|
|
aa64c41 |
- goto err;
|
|
|
aa64c41 |
- }
|
|
|
aa64c41 |
- else
|
|
|
aa64c41 |
- {
|
|
|
aa64c41 |
#if 0 /* The client cannot always know when a session is not appropriate,
|
|
|
aa64c41 |
- * so we shouldn't generate an error message. */
|
|
|
aa64c41 |
+ * so we shouldn't generate an error message. */
|
|
|
aa64c41 |
|
|
|
aa64c41 |
- SSLerr(SSL_F_SSL_GET_PREV_SESSION,SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT);
|
|
|
aa64c41 |
+ SSLerr(SSL_F_SSL_GET_PREV_SESSION,SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT);
|
|
|
aa64c41 |
#endif
|
|
|
aa64c41 |
- goto err; /* treat like cache miss */
|
|
|
aa64c41 |
- }
|
|
|
aa64c41 |
+ goto err; /* treat like cache miss */
|
|
|
aa64c41 |
+ }
|
|
|
aa64c41 |
+
|
|
|
aa64c41 |
+ if((s->verify_mode & SSL_VERIFY_PEER) && s->sid_ctx_length == 0)
|
|
|
aa64c41 |
+ {
|
|
|
aa64c41 |
+ /* We can't be sure if this session is being used out of
|
|
|
aa64c41 |
+ * context, which is especially important for SSL_VERIFY_PEER.
|
|
|
aa64c41 |
+ * The application should have used SSL[_CTX]_set_session_id_context.
|
|
|
aa64c41 |
+ *
|
|
|
aa64c41 |
+ * For this error case, we generate an error instead of treating
|
|
|
aa64c41 |
+ * the event like a cache miss (otherwise it would be easy for
|
|
|
aa64c41 |
+ * applications to effectively disable the session cache by
|
|
|
aa64c41 |
+ * accident without anyone noticing).
|
|
|
aa64c41 |
+ */
|
|
|
aa64c41 |
+
|
|
|
aa64c41 |
+ SSLerr(SSL_F_SSL_GET_PREV_SESSION,SSL_R_SESSION_ID_CONTEXT_UNINITIALIZED);
|
|
|
aa64c41 |
+ fatal = 1;
|
|
|
aa64c41 |
+ goto err;
|
|
|
aa64c41 |
}
|
|
|
aa64c41 |
|
|
|
aa64c41 |
if (ret->cipher == NULL)
|